Skip to content

Commit 14bcbf4

Browse files
committed
added upload notes button
1 parent 44edcc4 commit 14bcbf4

File tree

4 files changed

+78
-22
lines changed

4 files changed

+78
-22
lines changed

src/app/page.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type { Metadata } from 'next';
22
import NavBar from '@components/NavBar';
3+
import UploadNotes from '@components/uploadnotes';
34

45
export const metadata: Metadata = {
56
alternates: {
@@ -11,6 +12,7 @@ const Home = () => {
1112
return (
1213
<>
1314
<NavBar />
15+
<UploadNotes />
1416
</>
1517
);
1618
};

src/components/uploadnotes.tsx

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
'use client';
2+
import React from 'react';
3+
import { useState } from 'react';
4+
5+
export default function UploadNotes() {
6+
const [isOpen, setIsOpen] = useState(false);
7+
8+
return (
9+
<>
10+
<button
11+
onClick={() => setIsOpen(true)}
12+
className="inline-block cursor-pointer hover:underline"
13+
>
14+
Upload Notes
15+
</button>
16+
17+
{isOpen && (
18+
<div className="fixed inset-0 flex items-center justify-center">
19+
<div className="w-80 bg-white p-6 text-center">
20+
<h2 className="mb-4 text-xl font-semibold text-black">
21+
Upload Notes
22+
</h2>
23+
<p className="mb-6 border-black text-black">
24+
Enter Filename:{' '}
25+
<input
26+
type="text"
27+
className="mt-2 w-full border border-black px-2 py-1"
28+
/>
29+
</p>
30+
<p className="mb-6 border-black text-black">
31+
Section Dropdown:{' '}
32+
<select className="mt-2 w-full border border-black px-2 py-1 text-black">
33+
<option value="">Select a section</option>
34+
<option value="section1">CS 1200</option>
35+
<option value="section2">CS 1436</option>
36+
<option value="section3">CS 1337</option>
37+
</select>
38+
</p>
39+
<div className="flex justify-center gap-4">
40+
<button
41+
onClick={() => setIsOpen(false)}
42+
className="border border-black px-2 py-1 text-black"
43+
>
44+
Cancel
45+
</button>
46+
<button
47+
onClick={() => setIsOpen(false)}
48+
className="border border-black px-2 py-1 text-black"
49+
>
50+
Upload
51+
</button>
52+
</div>
53+
</div>
54+
</div>
55+
)}
56+
</>
57+
);
58+
}

src/server/db/schema/file.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
import { relations, sql } from 'drizzle-orm';
2-
import {
3-
pgTable,
4-
text,
5-
} from 'drizzle-orm/pg-core';
2+
import { pgTable, text } from 'drizzle-orm/pg-core';
63
import { user } from './user';
74
import { section } from './section';
85

@@ -26,4 +23,4 @@ export const fileRelations = relations(file, ({ one }) => ({
2623
fields: [file.sectionId],
2724
references: [section.id],
2825
}),
29-
}));
26+
}));

src/server/db/schema/section.ts

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -22,27 +22,20 @@ export const section = pgTable(
2222
.primaryKey(),
2323

2424
// "CS" or "CE", short and indexable
25-
prefix: varchar('prefix', { length: 4 })
26-
.notNull(),
25+
prefix: varchar('prefix', { length: 4 }).notNull(),
2726

2827
// Course number like 1200
29-
number: varchar('number', { length: 4 })
30-
.notNull(),
28+
number: varchar('number', { length: 4 }).notNull(),
3129

3230
// Section code like "001"
33-
sectionCode: varchar('section_code', { length: 3 })
34-
.notNull(),
31+
sectionCode: varchar('section_code', { length: 3 }).notNull(),
3532

3633
// Semester split into term + year for better filtering
37-
term: termEnum('term')
38-
.notNull(),
39-
year: smallint('year')
40-
.notNull(),
34+
term: termEnum('term').notNull(),
35+
year: smallint('year').notNull(),
4136

4237
professor: text('professor'),
43-
numberOfNotes: integer('number_of_notes')
44-
.notNull()
45-
.default(0),
38+
numberOfNotes: integer('number_of_notes').notNull().default(0),
4639

4740
// Not required, but good practice usually
4841
createdAt: timestamp('created_at', { withTimezone: true })
@@ -52,14 +45,20 @@ export const section = pgTable(
5245
.notNull()
5346
.defaultNow(),
5447
},
55-
(t) => ([
56-
uniqueIndex('section_unique_idx').on(t.prefix, t.number, t.sectionCode, t.term, t.year),
48+
(t) => [
49+
uniqueIndex('section_unique_idx').on(
50+
t.prefix,
51+
t.number,
52+
t.sectionCode,
53+
t.term,
54+
t.year,
55+
),
5756
index('section_by_course_idx').on(t.prefix, t.number),
5857
index('section_by_professor_idx').on(t.professor),
5958
index('section_by_semester_idx').on(t.term, t.year),
60-
]),
59+
],
6160
);
6261

6362
export const sectionRelations = relations(section, ({ many }) => ({
6463
files: many(file),
65-
}));
64+
}));

0 commit comments

Comments
 (0)