From f69cf01c18fe99f6927e4cf98019aefa6d762b5b Mon Sep 17 00:00:00 2001 From: pariah Date: Tue, 22 Jul 2025 09:54:10 -0500 Subject: [PATCH] misc tweaks --- components/PageHeader.vue | 2 + import.ts | 0 nuxt.config.ts | 5 -- pages/database.vue | 53 +++++--------- pages/index.vue | 3 - prisma/dev.db | Bin 28672 -> 28672 bytes prisma/dev.db-journal | Bin 8720 -> 0 bytes .../migration.sql | 8 +-- server/api/student.post.ts | 65 ++++++++---------- server/api/user.get.ts | 6 +- 10 files changed, 56 insertions(+), 86 deletions(-) create mode 100644 import.ts delete mode 100644 prisma/dev.db-journal rename prisma/migrations/{20250415174034_initial => 20250427182820_initial}/migration.sql (78%) 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 d8143f1cfcedaf5017146417439704f108347eff..3a929e1764d3bef0b76d50701251e7dc77e86620 100644 GIT binary patch delta 713 zcma)3&rcIU6rO3J%hoi*hBOVSiAy;kFG{erT_nO64ZAaJTMzyj|VqTdTZD>y6b7 zz7wB>xkYED;>gwV!u_fvFO=tVvO3d^OQq!5I5ndt~>n`DL z$z>fn;nXCiTVqr=>{`t-IJXU*susmHjG4w<__F=@^fgv-N!78bS=hqrYTd5~bt*Kv zm*o%gcU1fzEg1j+M27$!Mv{Dh_O_q|M#q67{ugsw>!(HERmnQ$$O5KYR|*d8gAUl7^ELo#}`Fh<^Ye C%+VbH delta 508 zcmZp8z}WDBae_1>%S0JxNfrjZssdjA9}H}q;tagk_&0NXH#3{b9aXv?VBpaK! zwm4&bW?o8aMQL$rQE_}~ZenIme0FLjn9J@QdroS8+*cN@`w7F^pzG=mlwo32)ZrwqoLd@h0c-nzDke+Ps|ivS7V=qDiu0 zVydNXa-yM`u8F0QrEXG6s)4SVNvcV*iKTIhkwJ=OqOqA_YNAO>YNC;av5{$-X^Mq; zvSp%$L83)cYD!{KnyE!fqIoKiXPRV^Vwh%;Y-VO+Xpoegn37~^VZu1gs`L7FBLgE- z0~142Lvs@YW0UyIyv&l!MD`r8WalP@JN#P2xP_Mi2n03@CfwtnI6;ODKbH$dF#w}C BnTh}a diff --git a/prisma/dev.db-journal b/prisma/dev.db-journal deleted file mode 100644 index c5a461134f481ead43399b91e5cda56d489d6a30..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 8720 zcmeI$F>1sx5Cu>Uv-KNMPw%WCUsLP zF_N>nh-OaYtq+!5a3k4)-sjKxGRsHveO!OnGhf@S+T#ykUiT}BOAvqn1Rwwb2tWV= T5P$##AOHaf{5^r6uiNPkxw { - - 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