diff --git a/components/PageHeader.vue b/components/PageHeader.vue index 4120f89..c76069a 100644 --- a/components/PageHeader.vue +++ b/components/PageHeader.vue @@ -85,11 +85,13 @@ const props = defineProps(['userRole']); text-align: center; font-size: medium; transition: .3s ease; + display: none; } .off-screen-menu.active { background-color: #122C4F; right: 0; + display: flex; } .ham-menu { diff --git a/import.ts b/import.ts new file mode 100644 index 0000000..e69de29 diff --git a/nuxt.config.ts b/nuxt.config.ts index 08f404e..9e8cd8b 100644 --- a/nuxt.config.ts +++ b/nuxt.config.ts @@ -17,11 +17,6 @@ export default defineNuxtConfig({ AUTH0_CLIENT_SECRET: "", AUTH0_BASE_URL: "", AUTH0_ISSUER_BASE_URL: "", - AUTH0_ISSUER_BASE_URL: "", - STRIPE_PUBLIC: '', - STRIPE_SECRET: '', - AWS_S3_BUCKET_NAME: '', - EMAIL_SOURCE_ADDRESS: '', AUTH0_PUB_KEY_PATH: './cert-dev.pem', }, build: { diff --git a/pages/database.vue b/pages/database.vue index f337761..8a95142 100644 --- a/pages/database.vue +++ b/pages/database.vue @@ -248,12 +248,19 @@ import Notification from "~/components/Notification.vue"; import Loading from "~/components/LoadingOverlay.vue"; import Modal from "~/components/Modal.vue"; -import { ref } from "vue"; import * as XLSX from 'xlsx'; import * as Papa from 'papaparse'; const editButtonPressed = ref(false); +const isError = ref(false); +const errorMessage = ref(''); + +const sortingOption = ref(''); + +const isLoading = ref(false); +const importedDataRef = ref(null); + const exportData = () => { students.value.forEach(student => { const columns = Object.keys(student); @@ -288,7 +295,6 @@ const handleFileImport = async (event) => { } else if (fileType === 'csv') { jsonData = await parseCsvFile(file); } - // Now you have jsonData containing the data from the file // Process and add the data to the Prisma database await addDataToDatabase(jsonData); @@ -312,6 +318,14 @@ const isImportSuccessful = ref(false); const successMessage = ref(''); +const { data: students, refresh:refreshStudents } = await useFetch('/api/student', { + method: 'GET', + params: { + orderOption: sortingOption.value + }, +}) + + const handleFileSelect = async (event) => { const file = event.target.files[0]; @@ -341,13 +355,6 @@ const clearSuccessMessage = () => { successMessage.value = ''; }; -const isError = ref(false); -const errorMessage = ref(''); - -const sortingOption = ref(''); - -const isLoading = ref(false); -const importedDataRef = ref(null); const importData = async () => { try { isLoading.value = true; @@ -448,7 +455,7 @@ const addDataToDatabase = async (jsonData) => { } // Refresh the list of students after importing data - students.value = await getStudents(); + refreshStudents() }; const isModalVisible = ref(false); @@ -463,7 +470,6 @@ function closeModal() { -const students = ref(null); const student = ref({ firstName: null, lastName: null, @@ -495,27 +501,6 @@ const editedStudent = ref({ birthDay: null, }); -students.value = await getStudents(); - - - -/** - * @desc get users - */ -async function getStudents() { - console.log("Sorting option: " + sortingOption.value); - const studentList = await $fetch('/api/student', { - method: 'GET', - params: { - orderOption: sortingOption.value - }, - }); - students.value = studentList; - return studentList; -} - - - /** * @desc edit student @param editedStudent student object @@ -543,7 +528,7 @@ async function editStudent(editedStudent) { } }); - if (student) students.value = await getStudents(); + if (student) refreshStudents() } async function goToEdit(studentId) { @@ -576,7 +561,7 @@ const removeStudent = async (id) => { }, 3000); // Refresh the list of students after removing one - students.value = await getStudents(); + refreshStudents() } catch (error) { isError.value = true; // Show error notification errorMessage.value = 'An error occurred while removing the student. Please check the console for details.'; diff --git a/pages/index.vue b/pages/index.vue index 0ca5763..1dcd188 100644 --- a/pages/index.vue +++ b/pages/index.vue @@ -11,9 +11,6 @@ diff --git a/prisma/dev.db b/prisma/dev.db index d8143f1..3a929e1 100644 Binary files a/prisma/dev.db and b/prisma/dev.db differ diff --git a/prisma/dev.db-journal b/prisma/dev.db-journal deleted file mode 100644 index c5a4611..0000000 Binary files a/prisma/dev.db-journal and /dev/null differ diff --git a/prisma/migrations/20250415174034_initial/migration.sql b/prisma/migrations/20250427182820_initial/migration.sql similarity index 78% rename from prisma/migrations/20250415174034_initial/migration.sql rename to prisma/migrations/20250427182820_initial/migration.sql index 6021068..e46f571 100644 --- a/prisma/migrations/20250415174034_initial/migration.sql +++ b/prisma/migrations/20250427182820_initial/migration.sql @@ -1,5 +1,5 @@ -- CreateTable -CREATE TABLE "students" ( +CREATE TABLE "Student" ( "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, "firstName" TEXT NOT NULL, "lastName" TEXT NOT NULL, @@ -16,11 +16,11 @@ CREATE TABLE "students" ( "studentEmail" TEXT, "schoolName" TEXT NOT NULL, "birthDay" TEXT NOT NULL, - CONSTRAINT "students_authorId_fkey" FOREIGN KEY ("authorId") REFERENCES "users" ("id") ON DELETE RESTRICT ON UPDATE CASCADE + CONSTRAINT "Student_authorId_fkey" FOREIGN KEY ("authorId") REFERENCES "User" ("id") ON DELETE RESTRICT ON UPDATE CASCADE ); -- CreateTable -CREATE TABLE "users" ( +CREATE TABLE "User" ( "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, "firstName" TEXT NOT NULL, "lastName" TEXT NOT NULL, @@ -31,4 +31,4 @@ CREATE TABLE "users" ( ); -- CreateIndex -CREATE UNIQUE INDEX "users_email_key" ON "users"("email"); +CREATE UNIQUE INDEX "User_email_key" ON "User"("email"); diff --git a/server/api/student.post.ts b/server/api/student.post.ts index fdaa3a2..309b62e 100644 --- a/server/api/student.post.ts +++ b/server/api/student.post.ts @@ -1,39 +1,34 @@ - - - - export default defineEventHandler(async(event) => { - - const body = await readBody(event) - if (body.firstName && body.lastName && body.streetAddress && body.city && body.zipCode && body.county && body.schoolName && body.birthDay) { - try{ - const student = await event.context.client.student.create({ - data: { - author: { - connect: { - id: body.authorId - } - }, - firstName: body.firstName, - lastName: body.lastName, - streetNumber: body.streetNumber, - streetAddress: body.streetAddress, - city: body.city, - zipCode: body.zipCode, - county: body.county, - phoneNumber: body.phoneNumber, - studentEmail: body.studentEmail, - schoolName: body.schoolName, - birthDay: body.birthDay, - }, - }) - - return { - student: student + const body = await readBody(event) + if (body.firstName && body.lastName && body.streetAddress && body.city && body.zipCode && body.county && body.schoolName && body.birthDay) { + try{ + const student = await event.context.client.student.create({ + data: { + author: { + connect: { + id: body.authorId } - } catch(err){ - console.log(err) - return createError({statusCode: 500, statusMessage: "Server Post Error"}) - } + }, + firstName: body.firstName, + lastName: body.lastName, + streetNumber: body.streetNumber, + streetAddress: body.streetAddress, + city: body.city, + zipCode: body.zipCode, + county: body.county, + phoneNumber: body.phoneNumber, + studentEmail: body.studentEmail, + schoolName: body.schoolName, + birthDay: body.birthDay, + }, + }) + + return { + student: student + } + } catch(err){ + console.log(err) + return createError({statusCode: 500, statusMessage: "Server Post Error"}) } + } }) \ No newline at end of file diff --git a/server/api/user.get.ts b/server/api/user.get.ts index 1f1e09f..76b9787 100644 --- a/server/api/user.get.ts +++ b/server/api/user.get.ts @@ -1,7 +1,3 @@ - - - - -export default defineEventHandler(async() => { +export default defineEventHandler(async(event) => { return await event.context.client.user.findMany() }) \ No newline at end of file