Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions components/PageHeader.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Empty file added import.ts
Empty file.
5 changes: 0 additions & 5 deletions nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
53 changes: 19 additions & 34 deletions pages/database.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -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];

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -463,7 +470,6 @@ function closeModal() {



const students = ref(null);
const student = ref({
firstName: null,
lastName: null,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -543,7 +528,7 @@ async function editStudent(editedStudent) {
}
});

if (student) students.value = await getStudents();
if (student) refreshStudents()
}

async function goToEdit(studentId) {
Expand Down Expand Up @@ -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.';
Expand Down
3 changes: 0 additions & 3 deletions pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@
</template>

<script setup>

import {ref} from 'vue'
const cvuser = useCookie('cvuser')
const name = cvuser.value.firstName
console.log(name)
</script>
Binary file modified prisma/dev.db
Binary file not shown.
Binary file removed prisma/dev.db-journal
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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,
Expand All @@ -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");
65 changes: 30 additions & 35 deletions server/api/student.post.ts
Original file line number Diff line number Diff line change
@@ -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"})
}
}
})
6 changes: 1 addition & 5 deletions server/api/user.get.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@




export default defineEventHandler(async() => {
export default defineEventHandler(async(event) => {
return await event.context.client.user.findMany()
})
Loading