From e04139c0c16ac628a09c1fe5d454575c1c0b7c19 Mon Sep 17 00:00:00 2001 From: m20arcusk Date: Tue, 30 Jul 2024 11:57:59 -0700 Subject: [PATCH 1/9] achieved front-end view for pop up. just need to plan how the data will be taken from backend --- src/components/RegistrationTable/EditCell.tsx | 15 ++-- .../editCellPopUp.tsx/userInfo.tsx | 74 +++++++++++++++++++ .../editCellPopUp.tsx/userPopupEdit.tsx | 60 +++++++++++++++ .../editCellPopUp.tsx/userResponses.tsx | 34 +++++++++ 4 files changed, 178 insertions(+), 5 deletions(-) create mode 100644 src/components/RegistrationTable/editCellPopUp.tsx/userInfo.tsx create mode 100644 src/components/RegistrationTable/editCellPopUp.tsx/userPopupEdit.tsx create mode 100644 src/components/RegistrationTable/editCellPopUp.tsx/userResponses.tsx diff --git a/src/components/RegistrationTable/EditCell.tsx b/src/components/RegistrationTable/EditCell.tsx index 67869ac..6cdcc72 100644 --- a/src/components/RegistrationTable/EditCell.tsx +++ b/src/components/RegistrationTable/EditCell.tsx @@ -11,6 +11,8 @@ import { Row, Table } from "@tanstack/react-table" import { Attendee } from "./columns" import Image from "next/image"; import PopoutIcon from "../../../public/assets/icons/popout_icon.svg"; +import UserInfo from "./editCellPopUp.tsx/userInfo" +import UserResponses from './editCellPopUp.tsx/userResponses' interface EditCellProps { row: Row @@ -32,17 +34,20 @@ export const EditCell: React.FC = ({ row }) => { - + {row.original.firstName} {row.original.lastName} - Form Responses + Form Responses {/* divider */} -
- +
+ +
+ +
+
- ) diff --git a/src/components/RegistrationTable/editCellPopUp.tsx/userInfo.tsx b/src/components/RegistrationTable/editCellPopUp.tsx/userInfo.tsx new file mode 100644 index 0000000..2690a7f --- /dev/null +++ b/src/components/RegistrationTable/editCellPopUp.tsx/userInfo.tsx @@ -0,0 +1,74 @@ +import React, { ChangeEvent, useState } from 'react' +import { Button } from "@/components/ui/button" +import { + Dialog, + DialogContent, + DialogHeader, + DialogTitle, + DialogTrigger, +} from "@/components/ui/dialog" +import { Row, Table } from "@tanstack/react-table" +import { Attendee } from "../columns" +import { ColumnMeta } from "../columns" +import { Input } from "@/components/ui/input" +import SelectCell from './userPopupEdit' + +interface EditCellProps { + row: Row, +} + +const UserInfo: React.FC = ({ row }) => { + // const handleEdit = () => { + // // Handle edit logic here + // console.log("Editing row:", row.original) + // // close the dialog + // } + const fieldsToDisplay = Object.keys(row.original).filter(key => key !== 'shouldNotDisplay'); + + const fieldLabels: { [key: string]: string } = { + appStatus: "Application Status", + dynamicField1: "Dynamic Field", + email: "Email", + faculty: "Faculty", + firstName: "First Name", + id: "ID", + lastName: "Last Name", + points: "Points", + regStatus: "Registration Status", + studentNumber: "Student Number" + }; + + const dropDownList: { [key: string]: string[] } = { + regStatus: [ + "Registered", + "Checked-In", + "Cancelled", + "Incomplete" + ], + appStatus: [ + "Accepted", + "Rejected" + ], + }; + + + return ( +
+ {fieldsToDisplay.map((key) => ( +
+ + {key === 'regStatus' || key === 'appStatus' ? ( + + ) : key === 'points' ? ( + + ) : ( + {row.original[key]} + )} +
+ ))} +
+ ) +} + +export default UserInfo + diff --git a/src/components/RegistrationTable/editCellPopUp.tsx/userPopupEdit.tsx b/src/components/RegistrationTable/editCellPopUp.tsx/userPopupEdit.tsx new file mode 100644 index 0000000..82cd11d --- /dev/null +++ b/src/components/RegistrationTable/editCellPopUp.tsx/userPopupEdit.tsx @@ -0,0 +1,60 @@ +import { Select, SelectContent, SelectGroup, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select" +import { Input } from "@/components/ui/input" +import React, { useState } from 'react' + + +interface SelectCellProps { + originalValue: string | number, + dropDownList: string[] +} + +const SelectCell: React.FC = ({ originalValue, dropDownList }) => { + const [value, setValue] = useState(originalValue) + + const onSelectChange = (newValue: string) => { + setValue(newValue) + console.log("TODO - update data") + // tableMeta?.updateData(row.index, column.id, newValue) + } + + // Handle input changes + const handleChange = (e: React.ChangeEvent) => { + // Update the state with the new value + setValue(e.target.value); + }; + + + return ( +
+ {dropDownList ? ( + + ) : ( + + )} +
+ ); +} + +export default SelectCell; + diff --git a/src/components/RegistrationTable/editCellPopUp.tsx/userResponses.tsx b/src/components/RegistrationTable/editCellPopUp.tsx/userResponses.tsx new file mode 100644 index 0000000..e9fd092 --- /dev/null +++ b/src/components/RegistrationTable/editCellPopUp.tsx/userResponses.tsx @@ -0,0 +1,34 @@ +import React from 'react' + +const qaDict = +{ + "LinkedIn Profile (optional)": "https://www.linkedin.com/in/marcuskam20/", + "If you are a senior student (3rd year and above) - you will be paired up to act as a mentor for a 1st or 2nd year student. This will give you the opportunity to become a \"Senior Mentee\". By participating in the mentorship program, you are expected to agree to volunteer as a senior mentor as well if a 1st or 2nd year student states and demonstrates a need for a senior student as their mentor.": "Tick this if you are a 1st or 2nd year student ;)", + "Please upload your resume in the following format and indicate your intended role (Junior or Senior): Role_FirstName_LastName.pdf (i.e Senior_Kam_Marcus.pdf)": "https://drive.google.com/file/d/1EOvaSpJNmmEof2oa1aUfTn-hwaQMQL79/view?usp=drivesdk", + "What motivated you to apply for this mentorship program? (500 characters max)": "Back in my first year, I applied for the tri-mentorship program with Biztech and had such an outstanding experience that I knew I had to apply again! I've always found applying for jobs and starting my own projects kind of intimidating, and my mentor was so experienced, and patient with all my questions. It was especially great that my upper year mentor was in the same year as me, and it helped to further personalize the guidance to a greater level.", + "What does mentorship mean to you? What specific goals or areas of your personal or professional development are you hoping to address through this mentorship program (can include specific projects)? (750 characters max)": "To me, mentorship means the opportunity to connect someone more experienced, with someone who can learn from them. The relationship seemingly is one way, but often the upper year mentor is able to gain valuable experience as well through the act of teaching, explaining, and managing and younger mentee. Personally, I hope to be able to address the processes of job applications specific to the tech industry, and tackle harder side projects knowing I have a mentor I can refer to. For example, one project I'd really like to try is a web scraper that searches for houses on a real estate website. I don't have a lot of experience in this area, but I think it would be a great project to attempt.", + "One of the goals of the mentorship program this year is to grow a tight-knit community of tech and business enthusiasts. How will you connect with other individuals in the program or spread the program's impact to the UBC community given the resources available to you? (450 characters max)": "When I was a junior mentee in first year, I made lots of great connections with other junior mentees during the events. I noticed that mentees had great experiences to share and we could refer our upper year mentors/professionals to each other based on what skills or experience they were looking for. I think overall being in the same program with like-minded people already fosters a great community within and outside of the program.", + "Choose 1 to answer: Outside of school and career, what 3 topics are you likely to win a debate about? Why? --OR-- Open your Youtube account and check the categories (see image below). What are the top 3-5 categories that most represent you and your interests? Why? (300 characters max)": "The top three categories that represent me and my interests from Youtube are Roundnet (spikeball), Music, and Teamfight Tactics. Outside of school, I feel like you can always find me doing one of these three things. I thoroughly enjoy each of these and think they carry my mental health.", + "Rank your top 3 industry interests: Entrepreneurship, software dev, gaming, data analytics, finance, consulting, sales and marketing, cyber security, product management, UI/UX Design, Other (name your own)": "1. Software Dev 2. Gaming 3. Product Management", + "Workshops/Fireside chat topics you would be interested in (choose 4):": "Networking and Relationship Building, Time management and Productivity, Industry-Specific Workshops, Technology Skills", + "Is there anything else you'd like us to know about you or your interests that might help us match you with a suitable mentor? (optional, 500 characters)": "My interests are music, soccer, spikeball, gaming, and I also speak Cantonese.", + "Please confirm that you are free on the following dates of the program events.": "Friday October 27th (Evening) - Kick-Off Event, Friday January 26th (Evening) - Midway Event", + "Please note we will be hosting workshop/social hybrid events with professionals. What days do you prefer?": "Wednesday evenings, Thursday evenings", + "Any questions or concerns?": "Thanks for reviewing my application!" +}; + +const UserResponses = () => { + return ( +
+ {Object.entries(qaDict).map(([question, answer], index) => ( +
+

{question}

+

{answer}

+
+ ))} +
+ ); +}; + +export default UserResponses; + From 8b3ce41b529174f94264af9bbd2b9b29e0b2dfa2 Mon Sep 17 00:00:00 2001 From: m20arcusk Date: Fri, 2 Aug 2024 11:18:02 -0700 Subject: [PATCH 2/9] frontend visuals achieved, just need to refactor the method the data is stored to handle dynamic fields --- src/components/RegistrationTable/EditCell.tsx | 15 ++-- .../editCellPopUp.tsx/userInfo.tsx | 6 +- .../editCellPopUp.tsx/userPopupEdit.tsx | 5 +- .../editCellPopUp.tsx/userResponses.tsx | 76 ++++++++++++++----- 4 files changed, 68 insertions(+), 34 deletions(-) diff --git a/src/components/RegistrationTable/EditCell.tsx b/src/components/RegistrationTable/EditCell.tsx index 6cdcc72..253e056 100644 --- a/src/components/RegistrationTable/EditCell.tsx +++ b/src/components/RegistrationTable/EditCell.tsx @@ -40,14 +40,17 @@ export const EditCell: React.FC = ({ row }) => { Form Responses {/* divider */} -
+
- -
- + +
+
-
- +
+ {/* Added DialogTrigger here to close dialog upon button click */} + + + ) diff --git a/src/components/RegistrationTable/editCellPopUp.tsx/userInfo.tsx b/src/components/RegistrationTable/editCellPopUp.tsx/userInfo.tsx index 2690a7f..77db992 100644 --- a/src/components/RegistrationTable/editCellPopUp.tsx/userInfo.tsx +++ b/src/components/RegistrationTable/editCellPopUp.tsx/userInfo.tsx @@ -18,11 +18,7 @@ interface EditCellProps { } const UserInfo: React.FC = ({ row }) => { - // const handleEdit = () => { - // // Handle edit logic here - // console.log("Editing row:", row.original) - // // close the dialog - // } + const fieldsToDisplay = Object.keys(row.original).filter(key => key !== 'shouldNotDisplay'); const fieldLabels: { [key: string]: string } = { diff --git a/src/components/RegistrationTable/editCellPopUp.tsx/userPopupEdit.tsx b/src/components/RegistrationTable/editCellPopUp.tsx/userPopupEdit.tsx index 82cd11d..4228275 100644 --- a/src/components/RegistrationTable/editCellPopUp.tsx/userPopupEdit.tsx +++ b/src/components/RegistrationTable/editCellPopUp.tsx/userPopupEdit.tsx @@ -17,8 +17,7 @@ const SelectCell: React.FC = ({ originalValue, dropDownList }) // tableMeta?.updateData(row.index, column.id, newValue) } - // Handle input changes - const handleChange = (e: React.ChangeEvent) => { + const handleInputChange = (e: React.ChangeEvent) => { // Update the state with the new value setValue(e.target.value); }; @@ -49,7 +48,7 @@ const SelectCell: React.FC = ({ originalValue, dropDownList }) className="p3 rounded-none bg-events-active-tab-bg text-white p-0 border-0 border-b-2 border-b-baby-blue" type="number" value={value} - onChange={handleChange} + onChange={handleInputChange} /> )}
diff --git a/src/components/RegistrationTable/editCellPopUp.tsx/userResponses.tsx b/src/components/RegistrationTable/editCellPopUp.tsx/userResponses.tsx index e9fd092..964205f 100644 --- a/src/components/RegistrationTable/editCellPopUp.tsx/userResponses.tsx +++ b/src/components/RegistrationTable/editCellPopUp.tsx/userResponses.tsx @@ -1,26 +1,39 @@ -import React from 'react' - -const qaDict = -{ - "LinkedIn Profile (optional)": "https://www.linkedin.com/in/marcuskam20/", - "If you are a senior student (3rd year and above) - you will be paired up to act as a mentor for a 1st or 2nd year student. This will give you the opportunity to become a \"Senior Mentee\". By participating in the mentorship program, you are expected to agree to volunteer as a senior mentor as well if a 1st or 2nd year student states and demonstrates a need for a senior student as their mentor.": "Tick this if you are a 1st or 2nd year student ;)", - "Please upload your resume in the following format and indicate your intended role (Junior or Senior): Role_FirstName_LastName.pdf (i.e Senior_Kam_Marcus.pdf)": "https://drive.google.com/file/d/1EOvaSpJNmmEof2oa1aUfTn-hwaQMQL79/view?usp=drivesdk", - "What motivated you to apply for this mentorship program? (500 characters max)": "Back in my first year, I applied for the tri-mentorship program with Biztech and had such an outstanding experience that I knew I had to apply again! I've always found applying for jobs and starting my own projects kind of intimidating, and my mentor was so experienced, and patient with all my questions. It was especially great that my upper year mentor was in the same year as me, and it helped to further personalize the guidance to a greater level.", - "What does mentorship mean to you? What specific goals or areas of your personal or professional development are you hoping to address through this mentorship program (can include specific projects)? (750 characters max)": "To me, mentorship means the opportunity to connect someone more experienced, with someone who can learn from them. The relationship seemingly is one way, but often the upper year mentor is able to gain valuable experience as well through the act of teaching, explaining, and managing and younger mentee. Personally, I hope to be able to address the processes of job applications specific to the tech industry, and tackle harder side projects knowing I have a mentor I can refer to. For example, one project I'd really like to try is a web scraper that searches for houses on a real estate website. I don't have a lot of experience in this area, but I think it would be a great project to attempt.", - "One of the goals of the mentorship program this year is to grow a tight-knit community of tech and business enthusiasts. How will you connect with other individuals in the program or spread the program's impact to the UBC community given the resources available to you? (450 characters max)": "When I was a junior mentee in first year, I made lots of great connections with other junior mentees during the events. I noticed that mentees had great experiences to share and we could refer our upper year mentors/professionals to each other based on what skills or experience they were looking for. I think overall being in the same program with like-minded people already fosters a great community within and outside of the program.", - "Choose 1 to answer: Outside of school and career, what 3 topics are you likely to win a debate about? Why? --OR-- Open your Youtube account and check the categories (see image below). What are the top 3-5 categories that most represent you and your interests? Why? (300 characters max)": "The top three categories that represent me and my interests from Youtube are Roundnet (spikeball), Music, and Teamfight Tactics. Outside of school, I feel like you can always find me doing one of these three things. I thoroughly enjoy each of these and think they carry my mental health.", - "Rank your top 3 industry interests: Entrepreneurship, software dev, gaming, data analytics, finance, consulting, sales and marketing, cyber security, product management, UI/UX Design, Other (name your own)": "1. Software Dev 2. Gaming 3. Product Management", - "Workshops/Fireside chat topics you would be interested in (choose 4):": "Networking and Relationship Building, Time management and Productivity, Industry-Specific Workshops, Technology Skills", - "Is there anything else you'd like us to know about you or your interests that might help us match you with a suitable mentor? (optional, 500 characters)": "My interests are music, soccer, spikeball, gaming, and I also speak Cantonese.", - "Please confirm that you are free on the following dates of the program events.": "Friday October 27th (Evening) - Kick-Off Event, Friday January 26th (Evening) - Midway Event", - "Please note we will be hosting workshop/social hybrid events with professionals. What days do you prefer?": "Wednesday evenings, Thursday evenings", - "Any questions or concerns?": "Thanks for reviewing my application!" -}; +import React, { useEffect, useState } from 'react' +import { Attendee } from '../columns'; +import { Row } from '@tanstack/react-table'; +import router, { useRouter } from 'next/router'; + + +interface Dictionary { + [key: string]: string; +} + +// Row is needed to know which user to make the query for +// Likely will need to know which event to query for as well +interface EditCellProps { + row: Row, +} + +const UserResponses: React.FC = ({ row }) => { + const router = useRouter() + const [data, setData] = useState({}); + + useEffect(() => { + if (router.isReady) { + const eventId = router.query.eventId; + const attendeeId = row.original.id; + + if (eventId && attendeeId) { + getQAData(attendeeId, eventId).then(d => { + setData(d) + }) + } + } + },[router.isReady, router.query.eventId, row.original.id]); -const UserResponses = () => { return (
- {Object.entries(qaDict).map(([question, answer], index) => ( + {Object.entries(data).map(([question, answer], index) => (

{question}

{answer}

@@ -30,5 +43,28 @@ const UserResponses = () => { ); }; +async function getQAData (attendeeId: string, eventId: string | string[]) { + // TODO: Handle query logic here + // My frontend code is configured to work with a dictionary of question keys and answer values, + // but can be open to change depending on how data is retrieved + const qaDict = + { + "LinkedIn Profile (optional)": "https://www.linkedin.com/in/marcuskam20/", + "If you are a senior student (3rd year and above) - you will be paired up to act as a mentor for a 1st or 2nd year student. This will give you the opportunity to become a \"Senior Mentee\". By participating in the mentorship program, you are expected to agree to volunteer as a senior mentor as well if a 1st or 2nd year student states and demonstrates a need for a senior student as their mentor.": "Tick this if you are a 1st or 2nd year student ;)", + "Please upload your resume in the following format and indicate your intended role (Junior or Senior): Role_FirstName_LastName.pdf (i.e Senior_Kam_Marcus.pdf)": "https://drive.google.com/file/d/1EOvaSpJNmmEof2oa1aUfTn-hwaQMQL79/view?usp=drivesdk", + "What motivated you to apply for this mentorship program? (500 characters max)": "Back in my first year, I applied for the tri-mentorship program with Biztech and had such an outstanding experience that I knew I had to apply again! I've always found applying for jobs and starting my own projects kind of intimidating, and my mentor was so experienced, and patient with all my questions. It was especially great that my upper year mentor was in the same year as me, and it helped to further personalize the guidance to a greater level.", + "What does mentorship mean to you? What specific goals or areas of your personal or professional development are you hoping to address through this mentorship program (can include specific projects)? (750 characters max)": "To me, mentorship means the opportunity to connect someone more experienced, with someone who can learn from them. The relationship seemingly is one way, but often the upper year mentor is able to gain valuable experience as well through the act of teaching, explaining, and managing and younger mentee. Personally, I hope to be able to address the processes of job applications specific to the tech industry, and tackle harder side projects knowing I have a mentor I can refer to. For example, one project I'd really like to try is a web scraper that searches for houses on a real estate website. I don't have a lot of experience in this area, but I think it would be a great project to attempt.", + "One of the goals of the mentorship program this year is to grow a tight-knit community of tech and business enthusiasts. How will you connect with other individuals in the program or spread the program's impact to the UBC community given the resources available to you? (450 characters max)": "When I was a junior mentee in first year, I made lots of great connections with other junior mentees during the events. I noticed that mentees had great experiences to share and we could refer our upper year mentors/professionals to each other based on what skills or experience they were looking for. I think overall being in the same program with like-minded people already fosters a great community within and outside of the program.", + "Choose 1 to answer: Outside of school and career, what 3 topics are you likely to win a debate about? Why? --OR-- Open your Youtube account and check the categories (see image below). What are the top 3-5 categories that most represent you and your interests? Why? (300 characters max)": "The top three categories that represent me and my interests from Youtube are Roundnet (spikeball), Music, and Teamfight Tactics. Outside of school, I feel like you can always find me doing one of these three things. I thoroughly enjoy each of these and think they carry my mental health.", + "Rank your top 3 industry interests: Entrepreneurship, software dev, gaming, data analytics, finance, consulting, sales and marketing, cyber security, product management, UI/UX Design, Other (name your own)": "1. Software Dev 2. Gaming 3. Product Management", + "Workshops/Fireside chat topics you would be interested in (choose 4):": "Networking and Relationship Building, Time management and Productivity, Industry-Specific Workshops, Technology Skills", + "Is there anything else you'd like us to know about you or your interests that might help us match you with a suitable mentor? (optional, 500 characters)": "My interests are music, soccer, spikeball, gaming, and I also speak Cantonese.", + "Please confirm that you are free on the following dates of the program events.": "Friday October 27th (Evening) - Kick-Off Event, Friday January 26th (Evening) - Midway Event", + "Please note we will be hosting workshop/social hybrid events with professionals. What days do you prefer?": "Wednesday evenings, Thursday evenings", + "Any questions or concerns?": "Thanks for reviewing my application!" + }; + return qaDict; +} + export default UserResponses; From 0960883d550e7be29dfd759cde0b765200daa825 Mon Sep 17 00:00:00 2001 From: m20arcusk Date: Thu, 8 Aug 2024 14:50:19 -0700 Subject: [PATCH 3/9] updated and imported some types for the questions and respones as well as the styling for smaller devices. --- src/components/RegistrationTable/EditCell.tsx | 68 +++++++++++++-- src/components/RegistrationTable/columns.tsx | 10 +++ .../editCellPopUp.tsx/userInfo.tsx | 84 +++++++++--------- .../editCellPopUp.tsx/userPopupEdit.tsx | 2 - .../editCellPopUp.tsx/userResponses.tsx | 85 +++++-------------- src/types.ts | 47 +++++++--- 6 files changed, 175 insertions(+), 121 deletions(-) diff --git a/src/components/RegistrationTable/EditCell.tsx b/src/components/RegistrationTable/EditCell.tsx index 253e056..8438fbd 100644 --- a/src/components/RegistrationTable/EditCell.tsx +++ b/src/components/RegistrationTable/EditCell.tsx @@ -1,4 +1,4 @@ -import React from 'react' +import React, { useEffect, useState } from 'react' import { Button } from "@/components/ui/button" import { Dialog, @@ -13,13 +13,36 @@ import Image from "next/image"; import PopoutIcon from "../../../public/assets/icons/popout_icon.svg"; import UserInfo from "./editCellPopUp.tsx/userInfo" import UserResponses from './editCellPopUp.tsx/userResponses' +import { RegQuestionData, UserQuestionIDs, UserResponse } from '@/types' +import router from 'next/router' interface EditCellProps { row: Row table: Table } -export const EditCell: React.FC = ({ row }) => { +export const EditCell: React.FC = ({ row, table }) => { + const [questions, setQuestions] = useState([]); + const [responses, setResponses] = useState<{ [key: string]: UserResponse }>({}); + + useEffect(() => { + if (router.isReady) { + const eventId = router.query.eventId as string; + const attendeeId = row.original.id; + const eventYear = router.query.year as string; + + if (eventId && attendeeId && eventYear) { + fetchQuestionsAndResponses(attendeeId, eventId, eventYear).then(data => { + setQuestions(data.questions); + setResponses(data.responses); + }).catch(error => { + console.error("Error fetching questions and responses:", error); + }); + } + } + }, [row.original.id]); + + const handleEdit = () => { // Handle edit logic here console.log("Editing row:", row.original) @@ -34,17 +57,18 @@ export const EditCell: React.FC = ({ row }) => { - + {row.original.firstName} {row.original.lastName} Form Responses {/* divider */} -
-
- -
- +
+
+ +
+ +
{/* Added DialogTrigger here to close dialog upon button click */} @@ -55,3 +79,31 @@ export const EditCell: React.FC = ({ row }) => { ) } + +const fetchQuestionsAndResponses = async (attendeeId: string, eventId: string, eventYear: string) => { + // TODO: Replace mock data with actual backend call + const mockQuestions: RegQuestionData[] = + [ { "M" : { "questionImageUrl" : { "S" : "" }, "label" : { "S" : "What school do you attend?" }, "questionId" : { "S" : "bede9713-17cf-4bb9-b362-8c30a1e5b543" }, "type" : { "S" : "SELECT" }, "choices" : { "S" : "UBC,SFU,KPU,Douglas,High School,..." }, "required" : { "BOOL" : true } } }, { "M" : { "label" : { "S" : "Do you have any accessibility/mobility needs that you would need us to know about?" }, "questionId" : { "S" : "49512eca-eec6-4639-b70c-f60f2e0a9371" }, "type" : { "S" : "SELECT" }, "choices" : { "S" : "Yes,No" }, "required" : { "BOOL" : true } } }, { "M" : { "label" : { "S" : "If you answered \"Yes\" to the question above, please let us know of any accommodations you will need below:" }, "questionId" : { "S" : "ee2b5b93-3792-4332-ba83-24b995f12094" }, "type" : { "S" : "TEXT" }, "choices" : { "S" : "" }, "required" : { "BOOL" : false } } }, { "M" : { "label" : { "S" : "LinkedIn URL:" }, "questionId" : { "S" : "013bb98c-4286-4649-bbb9-fbc27185925c" }, "type" : { "S" : "TEXT" }, "choices" : { "S" : "" }, "required" : { "BOOL" : false } } }, { "M" : { "label" : { "S" : "Resume:" }, "questionId" : { "S" : "ea4a8fa7-7bcf-4f86-af60-27ac61c7680b" }, "type" : { "S" : "UPLOAD" }, "choices" : { "S" : "" }, "required" : { "BOOL" : false } } }, { "M" : { "label" : { "S" : "Do you consent to us sharing your resume with our attending partners? (If you didn't upload one, select N/A)" }, "questionId" : { "S" : "f33ba987-6a5f-4ea2-9ba9-ca5f087e6fef" }, "type" : { "S" : "SELECT" }, "choices" : { "S" : "Yes,No,N/A" }, "required" : { "BOOL" : true } } }, { "M" : { "label" : { "S" : "Do you consent to having your email added to our sponsors' mailing lists? " }, "questionId" : { "S" : "a04e1064-65b2-4873-bede-9c4d5cbd32c3" }, "type" : { "S" : "SELECT" }, "choices" : { "S" : "Yes,No" }, "required" : { "BOOL" : true } } }, { "M" : { "label" : { "S" : "Would you be interested in getting your headshot taken at the conference?" }, "questionId" : { "S" : "24f0b385-d92e-43be-92a3-2b225964a778" }, "type" : { "S" : "SELECT" }, "choices" : { "S" : "Yes,No" }, "required" : { "BOOL" : true } } }, { "M" : { "label" : { "S" : "What's the first thing that comes to mind when you hear \"Digital Disruptions\"?" }, "questionId" : { "S" : "04f58eea-1861-4da3-8e4c-8d8e994ce8ba" }, "type" : { "S" : "TEXT" }, "choices" : { "S" : "" }, "required" : { "BOOL" : true } } }, { "M" : { "label" : { "S" : "Would you like to participate in our Attendee Showcase (view the event description above for more info)? If so, please complete ALL of the questions from this point on, otherwise, you may skip them." }, "questionId" : { "S" : "cb1a1e83-f581-473c-97e0-48e9a88d7d20" }, "type" : { "S" : "SELECT" }, "choices" : { "S" : "I would like to participate,I would not like to participate" }, "required" : { "BOOL" : true } } }, { "M" : { "label" : { "S" : "[A/S] Project Name" }, "questionId" : { "S" : "16ce18ff-9e88-4988-8965-b3edc172437a" }, "type" : { "S" : "TEXT" }, "choices" : { "S" : "" }, "required" : { "BOOL" : false } } }, { "M" : { "label" : { "S" : "[A/S] Full names of those who contributed to this project (you may only submit projects with up to 4 contributors MAX)" }, "questionId" : { "S" : "0836c57c-6163-4905-acb5-6578510b5a63" }, "type" : { "S" : "TEXT" }, "choices" : { "S" : "" }, "required" : { "BOOL" : false } } }, { "M" : { "label" : { "S" : "[A/S] Brief description of your project" }, "charLimit" : { "N" : "350" }, "questionId" : { "S" : "5328b778-e593-4077-bd58-d7b0f7cd1752" }, "type" : { "S" : "TEXT" }, "choices" : { "S" : "" }, "required" : { "BOOL" : false } } }, { "M" : { "label" : { "S" : "[A/S] Key technologies used to create your project" }, "questionId" : { "S" : "10231b92-5503-4a22-a205-25d99bee580b" }, "type" : { "S" : "TEXT" }, "choices" : { "S" : "" }, "required" : { "BOOL" : false } } }, { "M" : { "label" : { "S" : "[A/S] Relevant photo of your project (i.e. logo, screenshot of webpage, photo of prototype, etc)" }, "questionId" : { "S" : "e44b5fea-b18a-41bf-b6f2-e685b88d74da" }, "type" : { "S" : "UPLOAD" }, "choices" : { "S" : "" }, "required" : { "BOOL" : false } } }, { "M" : { "label" : { "S" : "[A/S] Link to your project/to learn more about your project (i.e. Github repo, website link, etc)" }, "questionId" : { "S" : "1099caf7-6e25-4c9a-97ab-c7628d1507e9" }, "type" : { "S" : "TEXT" }, "choices" : { "S" : "" }, "required" : { "BOOL" : false } } }, { "M" : { "label" : { "S" : "I confirm that the project I submitted abides by Blueprint's Attendee Showcase requirements (stated in this form's description)" }, "questionId" : { "S" : "f83944a8-97e2-421c-903c-aac91106fe34" }, "type" : { "S" : "SELECT" }, "choices" : { "S" : "I confirm,I didn't submit a project" }, "required" : { "BOOL" : true } } } ] + ; + // The 'test' user from the database was used here for the responses + const mockResponses: UserQuestionIDs = { + "ee2b5b93-3792-4332-ba83-24b995f12094": { S: "asdf" }, + "04f58eea-1861-4da3-8e4c-8d8e994ce8ba": { S: "asdf" }, + "bede9713-17cf-4bb9-b362-8c30a1e5b543": { S: "UBC" }, + "cb1a1e83-f581-473c-97e0-48e9a88d7d20": { S: "I would not like to participate" }, + "ea4a8fa7-7bcf-4f86-af60-27ac61c7680b": { S: "https://drive.google.com/file/d/1Q60JBkifak4gSrZL65KvafCPVA2HwcZ4/view?usp=drivesdk" }, + "013bb98c-4286-4649-bbb9-fbc27185925c": { S: "asdf" }, + "24f0b385-d92e-43be-92a3-2b225964a778": { S: "No" }, + "a04e1064-65b2-4873-bede-9c4d5cbd32c3": { S: "No" }, + "49512eca-eec6-4639-b70c-f60f2e0a9371": { S: "No" }, + "f33ba987-6a5f-4ea2-9ba9-ca5f087e6fef": { S: "No" }, + "f83944a8-97e2-421c-903c-aac91106fe34": { S: "I didn't submit a project" } + }; + + return { + questions: mockQuestions, + responses: mockResponses, + }; +}; + + diff --git a/src/components/RegistrationTable/columns.tsx b/src/components/RegistrationTable/columns.tsx index 20c8c31..f041455 100644 --- a/src/components/RegistrationTable/columns.tsx +++ b/src/components/RegistrationTable/columns.tsx @@ -72,6 +72,16 @@ export const columns: ColumnDef[] = [ accessorKey: "appStatus", header: "App. Status", cell: TableCell, + meta: { + type: "select", + options: [ // These values were inferred from the + { value: "Accepted", label: "Accepted" }, + { value: "Reviewing", label: "Reviewing" }, + { value: "Waitlist", label: "Waitlist" }, + { value: "Rejected", label: "Rejected" }, + ], + } as ColumnMeta, + size: 200, }, { accessorKey: "firstName", diff --git a/src/components/RegistrationTable/editCellPopUp.tsx/userInfo.tsx b/src/components/RegistrationTable/editCellPopUp.tsx/userInfo.tsx index 77db992..c33b76f 100644 --- a/src/components/RegistrationTable/editCellPopUp.tsx/userInfo.tsx +++ b/src/components/RegistrationTable/editCellPopUp.tsx/userInfo.tsx @@ -1,56 +1,62 @@ -import React, { ChangeEvent, useState } from 'react' -import { Button } from "@/components/ui/button" -import { - Dialog, - DialogContent, - DialogHeader, - DialogTitle, - DialogTrigger, -} from "@/components/ui/dialog" +import React, { ChangeEvent, useEffect, useState } from 'react' import { Row, Table } from "@tanstack/react-table" import { Attendee } from "../columns" -import { ColumnMeta } from "../columns" -import { Input } from "@/components/ui/input" import SelectCell from './userPopupEdit' +import { ColumnMeta } from '../columns' interface EditCellProps { row: Row, + table: Table } -const UserInfo: React.FC = ({ row }) => { +const UserInfo: React.FC = ({ row, table }) => { + const [fieldLabels, setFieldLabels] = useState<{ [key: string]: string }>({}); + const [dropDownList, setDropDownList] = useState<{ [key: string]: string[] }>({}); - const fieldsToDisplay = Object.keys(row.original).filter(key => key !== 'shouldNotDisplay'); + useEffect(() => { + const generateFieldLabels = () => { + const columns = table.getAllColumns(); + const labels: { [key: string]: string } = {}; - const fieldLabels: { [key: string]: string } = { - appStatus: "Application Status", - dynamicField1: "Dynamic Field", - email: "Email", - faculty: "Faculty", - firstName: "First Name", - id: "ID", - lastName: "Last Name", - points: "Points", - regStatus: "Registration Status", - studentNumber: "Student Number" - }; + columns.forEach((column) => { + const accessorKey = column.id; + const header = column.columnDef.header; - const dropDownList: { [key: string]: string[] } = { - regStatus: [ - "Registered", - "Checked-In", - "Cancelled", - "Incomplete" - ], - appStatus: [ - "Accepted", - "Rejected" - ], - }; + if (accessorKey && typeof header === 'string') { + labels[accessorKey] = header; + } + }); + return labels; + }; + + setFieldLabels(generateFieldLabels()); + + const generateDropDownList = () => { + const columns = table.getAllColumns(); + const options: { [key: string]: string[] } = {}; + columns.forEach(column => { + // had to import meta as Column Meta or else encountered errors + const meta = column.columnDef.meta as ColumnMeta | undefined; + + if (meta?.type === 'select') { + options[column.id] = meta.options?.map(opt => opt.value) || []; + } + }); + + return options; + }; + + setDropDownList(generateDropDownList()); + + }, [table]); + console.log(fieldLabels); + + const fieldsToDisplay = Object.keys(row.original).filter(key => key !== 'shouldNotDisplay' && key !== 'id'); return ( -
- {fieldsToDisplay.map((key) => ( +
+ {fieldsToDisplay?.map((key) => (
{key === 'regStatus' || key === 'appStatus' ? ( diff --git a/src/components/RegistrationTable/editCellPopUp.tsx/userPopupEdit.tsx b/src/components/RegistrationTable/editCellPopUp.tsx/userPopupEdit.tsx index 4228275..3f360f0 100644 --- a/src/components/RegistrationTable/editCellPopUp.tsx/userPopupEdit.tsx +++ b/src/components/RegistrationTable/editCellPopUp.tsx/userPopupEdit.tsx @@ -14,11 +14,9 @@ const SelectCell: React.FC = ({ originalValue, dropDownList }) const onSelectChange = (newValue: string) => { setValue(newValue) console.log("TODO - update data") - // tableMeta?.updateData(row.index, column.id, newValue) } const handleInputChange = (e: React.ChangeEvent) => { - // Update the state with the new value setValue(e.target.value); }; diff --git a/src/components/RegistrationTable/editCellPopUp.tsx/userResponses.tsx b/src/components/RegistrationTable/editCellPopUp.tsx/userResponses.tsx index 964205f..4f219cf 100644 --- a/src/components/RegistrationTable/editCellPopUp.tsx/userResponses.tsx +++ b/src/components/RegistrationTable/editCellPopUp.tsx/userResponses.tsx @@ -1,70 +1,31 @@ -import React, { useEffect, useState } from 'react' -import { Attendee } from '../columns'; -import { Row } from '@tanstack/react-table'; -import router, { useRouter } from 'next/router'; +import React from 'react'; +import { RegQuestionData, UserResponse } from '../../../types'; - -interface Dictionary { - [key: string]: string; -} - -// Row is needed to know which user to make the query for -// Likely will need to know which event to query for as well -interface EditCellProps { - row: Row, +interface UserResponsesProps { + questions: RegQuestionData[]; + responses: { [key: string]: UserResponse }; } -const UserResponses: React.FC = ({ row }) => { - const router = useRouter() - const [data, setData] = useState({}); - - useEffect(() => { - if (router.isReady) { - const eventId = router.query.eventId; - const attendeeId = row.original.id; - - if (eventId && attendeeId) { - getQAData(attendeeId, eventId).then(d => { - setData(d) - }) - } - } - },[router.isReady, router.query.eventId, row.original.id]); - +const UserResponses: React.FC = ({ questions, responses }) => { + console.log(questions); return ( -
- {Object.entries(data).map(([question, answer], index) => ( -
-

{question}

-

{answer}

-
- ))} +
+ {questions.map((question, index) => { + const questionData = question.M; + + const label = questionData.label.S; + const questionId = questionData.questionId.S; + const answer = responses[questionId]?.S || 'No response'; + + return ( +
+

{label}

+

{answer}

+
+ ); + })}
); }; -async function getQAData (attendeeId: string, eventId: string | string[]) { - // TODO: Handle query logic here - // My frontend code is configured to work with a dictionary of question keys and answer values, - // but can be open to change depending on how data is retrieved - const qaDict = - { - "LinkedIn Profile (optional)": "https://www.linkedin.com/in/marcuskam20/", - "If you are a senior student (3rd year and above) - you will be paired up to act as a mentor for a 1st or 2nd year student. This will give you the opportunity to become a \"Senior Mentee\". By participating in the mentorship program, you are expected to agree to volunteer as a senior mentor as well if a 1st or 2nd year student states and demonstrates a need for a senior student as their mentor.": "Tick this if you are a 1st or 2nd year student ;)", - "Please upload your resume in the following format and indicate your intended role (Junior or Senior): Role_FirstName_LastName.pdf (i.e Senior_Kam_Marcus.pdf)": "https://drive.google.com/file/d/1EOvaSpJNmmEof2oa1aUfTn-hwaQMQL79/view?usp=drivesdk", - "What motivated you to apply for this mentorship program? (500 characters max)": "Back in my first year, I applied for the tri-mentorship program with Biztech and had such an outstanding experience that I knew I had to apply again! I've always found applying for jobs and starting my own projects kind of intimidating, and my mentor was so experienced, and patient with all my questions. It was especially great that my upper year mentor was in the same year as me, and it helped to further personalize the guidance to a greater level.", - "What does mentorship mean to you? What specific goals or areas of your personal or professional development are you hoping to address through this mentorship program (can include specific projects)? (750 characters max)": "To me, mentorship means the opportunity to connect someone more experienced, with someone who can learn from them. The relationship seemingly is one way, but often the upper year mentor is able to gain valuable experience as well through the act of teaching, explaining, and managing and younger mentee. Personally, I hope to be able to address the processes of job applications specific to the tech industry, and tackle harder side projects knowing I have a mentor I can refer to. For example, one project I'd really like to try is a web scraper that searches for houses on a real estate website. I don't have a lot of experience in this area, but I think it would be a great project to attempt.", - "One of the goals of the mentorship program this year is to grow a tight-knit community of tech and business enthusiasts. How will you connect with other individuals in the program or spread the program's impact to the UBC community given the resources available to you? (450 characters max)": "When I was a junior mentee in first year, I made lots of great connections with other junior mentees during the events. I noticed that mentees had great experiences to share and we could refer our upper year mentors/professionals to each other based on what skills or experience they were looking for. I think overall being in the same program with like-minded people already fosters a great community within and outside of the program.", - "Choose 1 to answer: Outside of school and career, what 3 topics are you likely to win a debate about? Why? --OR-- Open your Youtube account and check the categories (see image below). What are the top 3-5 categories that most represent you and your interests? Why? (300 characters max)": "The top three categories that represent me and my interests from Youtube are Roundnet (spikeball), Music, and Teamfight Tactics. Outside of school, I feel like you can always find me doing one of these three things. I thoroughly enjoy each of these and think they carry my mental health.", - "Rank your top 3 industry interests: Entrepreneurship, software dev, gaming, data analytics, finance, consulting, sales and marketing, cyber security, product management, UI/UX Design, Other (name your own)": "1. Software Dev 2. Gaming 3. Product Management", - "Workshops/Fireside chat topics you would be interested in (choose 4):": "Networking and Relationship Building, Time management and Productivity, Industry-Specific Workshops, Technology Skills", - "Is there anything else you'd like us to know about you or your interests that might help us match you with a suitable mentor? (optional, 500 characters)": "My interests are music, soccer, spikeball, gaming, and I also speak Cantonese.", - "Please confirm that you are free on the following dates of the program events.": "Friday October 27th (Evening) - Kick-Off Event, Friday January 26th (Evening) - Midway Event", - "Please note we will be hosting workshop/social hybrid events with professionals. What days do you prefer?": "Wednesday evenings, Thursday evenings", - "Any questions or concerns?": "Thanks for reviewing my application!" - }; - return qaDict; -} - -export default UserResponses; - +export default UserResponses; \ No newline at end of file diff --git a/src/types.ts b/src/types.ts index 07a8f87..5206eea 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1,10 +1,37 @@ -export type BasicInformation = { - fname: string - lname: string - major: string - gender: string - year: string - diet: string - heardFrom: string - faculty: string -} \ No newline at end of file +export type RegQuestionAttributes = { + label: { + S: string; + }; + charLimit?: { + N: string; + }, + questionId: { + S: string; + }; + type: { + S: string; + }; + choices: { + S: string; + }; + required: { + BOOL: boolean; + }; + questionImageUrl?: { + S?: string; + }; +} + +export type RegQuestionData = { + M: RegQuestionAttributes; +} + +export type UserResponse = { + S: string; +}; + +export type UserQuestionIDs = { + [key: string]: UserResponse; +}; + + From 7a29faaa46d2e81df19539846a0b027e629d4a80 Mon Sep 17 00:00:00 2001 From: m20arcusk Date: Thu, 8 Aug 2024 14:59:52 -0700 Subject: [PATCH 4/9] small fix on a comment --- src/components/RegistrationTable/columns.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/RegistrationTable/columns.tsx b/src/components/RegistrationTable/columns.tsx index f041455..0591a9d 100644 --- a/src/components/RegistrationTable/columns.tsx +++ b/src/components/RegistrationTable/columns.tsx @@ -74,7 +74,7 @@ export const columns: ColumnDef[] = [ cell: TableCell, meta: { type: "select", - options: [ // These values were inferred from the + options: [ // These values were inferred from the database { value: "Accepted", label: "Accepted" }, { value: "Reviewing", label: "Reviewing" }, { value: "Waitlist", label: "Waitlist" }, From a519108bc31a4c0dbc5107b17cf048bce075e15f Mon Sep 17 00:00:00 2001 From: m20arcusk Date: Thu, 8 Aug 2024 15:09:09 -0700 Subject: [PATCH 5/9] didn't mean to delete BasicInformation in types.ts so I added it back --- src/types.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/types.ts b/src/types.ts index 5206eea..d3ccdf6 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1,3 +1,14 @@ +export type BasicInformation = { + fname: string + lname: string + major: string + gender: string + year: string + diet: string + heardFrom: string + faculty: string +} + export type RegQuestionAttributes = { label: { S: string; From bdf2754efa2cb0b4f3c663b4420d720f211a7f4b Mon Sep 17 00:00:00 2001 From: m20arcusk Date: Tue, 13 Aug 2024 18:40:09 -0700 Subject: [PATCH 6/9] removed console.log testing lines and updated tailwind with divider colour --- src/components/RegistrationTable/EditCell.tsx | 12 +++++++++--- .../RegistrationTable/editCellPopUp.tsx/userInfo.tsx | 1 - .../editCellPopUp.tsx/userResponses.tsx | 1 - tailwind.config.ts | 1 + 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/components/RegistrationTable/EditCell.tsx b/src/components/RegistrationTable/EditCell.tsx index 8438fbd..1a9c232 100644 --- a/src/components/RegistrationTable/EditCell.tsx +++ b/src/components/RegistrationTable/EditCell.tsx @@ -25,6 +25,9 @@ export const EditCell: React.FC = ({ row, table }) => { const [questions, setQuestions] = useState([]); const [responses, setResponses] = useState<{ [key: string]: UserResponse }>({}); + // TESTING + console.log(row.original); + useEffect(() => { if (router.isReady) { const eventId = router.query.eventId as string; @@ -63,14 +66,17 @@ export const EditCell: React.FC = ({ row, table }) => { Form Responses {/* divider */} -
+
+
-
+ {/* divider */} +
-
+ {/* divider */} +
{/* Added DialogTrigger here to close dialog upon button click */} diff --git a/src/components/RegistrationTable/editCellPopUp.tsx/userInfo.tsx b/src/components/RegistrationTable/editCellPopUp.tsx/userInfo.tsx index c33b76f..fdb261c 100644 --- a/src/components/RegistrationTable/editCellPopUp.tsx/userInfo.tsx +++ b/src/components/RegistrationTable/editCellPopUp.tsx/userInfo.tsx @@ -49,7 +49,6 @@ const UserInfo: React.FC = ({ row, table }) => { setDropDownList(generateDropDownList()); }, [table]); - console.log(fieldLabels); const fieldsToDisplay = Object.keys(row.original).filter(key => key !== 'shouldNotDisplay' && key !== 'id'); diff --git a/src/components/RegistrationTable/editCellPopUp.tsx/userResponses.tsx b/src/components/RegistrationTable/editCellPopUp.tsx/userResponses.tsx index 4f219cf..3095814 100644 --- a/src/components/RegistrationTable/editCellPopUp.tsx/userResponses.tsx +++ b/src/components/RegistrationTable/editCellPopUp.tsx/userResponses.tsx @@ -7,7 +7,6 @@ interface UserResponsesProps { } const UserResponses: React.FC = ({ questions, responses }) => { - console.log(questions); return (
{questions.map((question, index) => { diff --git a/tailwind.config.ts b/tailwind.config.ts index 76b0eed..aef1045 100644 --- a/tailwind.config.ts +++ b/tailwind.config.ts @@ -55,6 +55,7 @@ const config: Config = { 'light-red': '#FF8686', 'black': "#000000", 'white': "#ffffff", + 'divider': '#8DA1D1', border: "hsl(var(--border))", input: "hsl(var(--input))", ring: "hsl(var(--ring))", From d16fc21accbae011762d417a66d0f753f0447011 Mon Sep 17 00:00:00 2001 From: m20arcusk Date: Tue, 13 Aug 2024 19:27:52 -0700 Subject: [PATCH 7/9] updated the fetchQuestion function to use async and await --- src/components/RegistrationTable/EditCell.tsx | 37 ++++++++++--------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/src/components/RegistrationTable/EditCell.tsx b/src/components/RegistrationTable/EditCell.tsx index 1a9c232..4b9c184 100644 --- a/src/components/RegistrationTable/EditCell.tsx +++ b/src/components/RegistrationTable/EditCell.tsx @@ -25,25 +25,28 @@ export const EditCell: React.FC = ({ row, table }) => { const [questions, setQuestions] = useState([]); const [responses, setResponses] = useState<{ [key: string]: UserResponse }>({}); - // TESTING - console.log(row.original); - useEffect(() => { - if (router.isReady) { - const eventId = router.query.eventId as string; - const attendeeId = row.original.id; - const eventYear = router.query.year as string; - - if (eventId && attendeeId && eventYear) { - fetchQuestionsAndResponses(attendeeId, eventId, eventYear).then(data => { - setQuestions(data.questions); - setResponses(data.responses); - }).catch(error => { - console.error("Error fetching questions and responses:", error); - }); + const fetchData = async () => { + if (router.isReady) { + const eventId = router.query.eventId as string; + const attendeeId = row.original.id; + const eventYear = router.query.year as string; + + if (eventId && attendeeId && eventYear) { + try { + const data = await fetchQuestionsAndResponses(attendeeId, eventId, eventYear); + setQuestions(data.questions); + setResponses(data.responses); + } catch (error) { + console.error("Error fetching questions and responses:", error); + } + } } - } + }; + + fetchData(); }, [row.original.id]); + const handleEdit = () => { @@ -86,7 +89,7 @@ export const EditCell: React.FC = ({ row, table }) => { ) } -const fetchQuestionsAndResponses = async (attendeeId: string, eventId: string, eventYear: string) => { +async function fetchQuestionsAndResponses (attendeeId: string, eventId: string, eventYear: string) { // TODO: Replace mock data with actual backend call const mockQuestions: RegQuestionData[] = [ { "M" : { "questionImageUrl" : { "S" : "" }, "label" : { "S" : "What school do you attend?" }, "questionId" : { "S" : "bede9713-17cf-4bb9-b362-8c30a1e5b543" }, "type" : { "S" : "SELECT" }, "choices" : { "S" : "UBC,SFU,KPU,Douglas,High School,..." }, "required" : { "BOOL" : true } } }, { "M" : { "label" : { "S" : "Do you have any accessibility/mobility needs that you would need us to know about?" }, "questionId" : { "S" : "49512eca-eec6-4639-b70c-f60f2e0a9371" }, "type" : { "S" : "SELECT" }, "choices" : { "S" : "Yes,No" }, "required" : { "BOOL" : true } } }, { "M" : { "label" : { "S" : "If you answered \"Yes\" to the question above, please let us know of any accommodations you will need below:" }, "questionId" : { "S" : "ee2b5b93-3792-4332-ba83-24b995f12094" }, "type" : { "S" : "TEXT" }, "choices" : { "S" : "" }, "required" : { "BOOL" : false } } }, { "M" : { "label" : { "S" : "LinkedIn URL:" }, "questionId" : { "S" : "013bb98c-4286-4649-bbb9-fbc27185925c" }, "type" : { "S" : "TEXT" }, "choices" : { "S" : "" }, "required" : { "BOOL" : false } } }, { "M" : { "label" : { "S" : "Resume:" }, "questionId" : { "S" : "ea4a8fa7-7bcf-4f86-af60-27ac61c7680b" }, "type" : { "S" : "UPLOAD" }, "choices" : { "S" : "" }, "required" : { "BOOL" : false } } }, { "M" : { "label" : { "S" : "Do you consent to us sharing your resume with our attending partners? (If you didn't upload one, select N/A)" }, "questionId" : { "S" : "f33ba987-6a5f-4ea2-9ba9-ca5f087e6fef" }, "type" : { "S" : "SELECT" }, "choices" : { "S" : "Yes,No,N/A" }, "required" : { "BOOL" : true } } }, { "M" : { "label" : { "S" : "Do you consent to having your email added to our sponsors' mailing lists? " }, "questionId" : { "S" : "a04e1064-65b2-4873-bede-9c4d5cbd32c3" }, "type" : { "S" : "SELECT" }, "choices" : { "S" : "Yes,No" }, "required" : { "BOOL" : true } } }, { "M" : { "label" : { "S" : "Would you be interested in getting your headshot taken at the conference?" }, "questionId" : { "S" : "24f0b385-d92e-43be-92a3-2b225964a778" }, "type" : { "S" : "SELECT" }, "choices" : { "S" : "Yes,No" }, "required" : { "BOOL" : true } } }, { "M" : { "label" : { "S" : "What's the first thing that comes to mind when you hear \"Digital Disruptions\"?" }, "questionId" : { "S" : "04f58eea-1861-4da3-8e4c-8d8e994ce8ba" }, "type" : { "S" : "TEXT" }, "choices" : { "S" : "" }, "required" : { "BOOL" : true } } }, { "M" : { "label" : { "S" : "Would you like to participate in our Attendee Showcase (view the event description above for more info)? If so, please complete ALL of the questions from this point on, otherwise, you may skip them." }, "questionId" : { "S" : "cb1a1e83-f581-473c-97e0-48e9a88d7d20" }, "type" : { "S" : "SELECT" }, "choices" : { "S" : "I would like to participate,I would not like to participate" }, "required" : { "BOOL" : true } } }, { "M" : { "label" : { "S" : "[A/S] Project Name" }, "questionId" : { "S" : "16ce18ff-9e88-4988-8965-b3edc172437a" }, "type" : { "S" : "TEXT" }, "choices" : { "S" : "" }, "required" : { "BOOL" : false } } }, { "M" : { "label" : { "S" : "[A/S] Full names of those who contributed to this project (you may only submit projects with up to 4 contributors MAX)" }, "questionId" : { "S" : "0836c57c-6163-4905-acb5-6578510b5a63" }, "type" : { "S" : "TEXT" }, "choices" : { "S" : "" }, "required" : { "BOOL" : false } } }, { "M" : { "label" : { "S" : "[A/S] Brief description of your project" }, "charLimit" : { "N" : "350" }, "questionId" : { "S" : "5328b778-e593-4077-bd58-d7b0f7cd1752" }, "type" : { "S" : "TEXT" }, "choices" : { "S" : "" }, "required" : { "BOOL" : false } } }, { "M" : { "label" : { "S" : "[A/S] Key technologies used to create your project" }, "questionId" : { "S" : "10231b92-5503-4a22-a205-25d99bee580b" }, "type" : { "S" : "TEXT" }, "choices" : { "S" : "" }, "required" : { "BOOL" : false } } }, { "M" : { "label" : { "S" : "[A/S] Relevant photo of your project (i.e. logo, screenshot of webpage, photo of prototype, etc)" }, "questionId" : { "S" : "e44b5fea-b18a-41bf-b6f2-e685b88d74da" }, "type" : { "S" : "UPLOAD" }, "choices" : { "S" : "" }, "required" : { "BOOL" : false } } }, { "M" : { "label" : { "S" : "[A/S] Link to your project/to learn more about your project (i.e. Github repo, website link, etc)" }, "questionId" : { "S" : "1099caf7-6e25-4c9a-97ab-c7628d1507e9" }, "type" : { "S" : "TEXT" }, "choices" : { "S" : "" }, "required" : { "BOOL" : false } } }, { "M" : { "label" : { "S" : "I confirm that the project I submitted abides by Blueprint's Attendee Showcase requirements (stated in this form's description)" }, "questionId" : { "S" : "f83944a8-97e2-421c-903c-aac91106fe34" }, "type" : { "S" : "SELECT" }, "choices" : { "S" : "I confirm,I didn't submit a project" }, "required" : { "BOOL" : true } } } ] From f81770922ee9145d858749236a40f26f8d8d1d50 Mon Sep 17 00:00:00 2001 From: m20arcusk Date: Fri, 16 Aug 2024 16:49:23 -0700 Subject: [PATCH 8/9] changed to use async and await and now grabbing user responses from row. Still fetching the reg questions for event --- src/components/RegistrationTable/EditCell.tsx | 152 +++++++++++++++--- .../editCellPopUp.tsx/userInfo.tsx | 4 +- .../editCellPopUp.tsx/userResponses.tsx | 11 +- src/pages/admin/event/[eventId]/[year].tsx | 15 +- src/types.ts | 43 ++--- 5 files changed, 163 insertions(+), 62 deletions(-) diff --git a/src/components/RegistrationTable/EditCell.tsx b/src/components/RegistrationTable/EditCell.tsx index 4b9c184..36e06cd 100644 --- a/src/components/RegistrationTable/EditCell.tsx +++ b/src/components/RegistrationTable/EditCell.tsx @@ -13,7 +13,7 @@ import Image from "next/image"; import PopoutIcon from "../../../public/assets/icons/popout_icon.svg"; import UserInfo from "./editCellPopUp.tsx/userInfo" import UserResponses from './editCellPopUp.tsx/userResponses' -import { RegQuestionData, UserQuestionIDs, UserResponse } from '@/types' +import { RegistrationQuestion } from '@/types' import router from 'next/router' interface EditCellProps { @@ -22,8 +22,7 @@ interface EditCellProps { } export const EditCell: React.FC = ({ row, table }) => { - const [questions, setQuestions] = useState([]); - const [responses, setResponses] = useState<{ [key: string]: UserResponse }>({}); + const [questions, setQuestions] = useState([]); useEffect(() => { const fetchData = async () => { @@ -36,7 +35,6 @@ export const EditCell: React.FC = ({ row, table }) => { try { const data = await fetchQuestionsAndResponses(attendeeId, eventId, eventYear); setQuestions(data.questions); - setResponses(data.responses); } catch (error) { console.error("Error fetching questions and responses:", error); } @@ -75,7 +73,7 @@ export const EditCell: React.FC = ({ row, table }) => { {/* divider */}
- +
{/* divider */} @@ -91,27 +89,133 @@ export const EditCell: React.FC = ({ row, table }) => { async function fetchQuestionsAndResponses (attendeeId: string, eventId: string, eventYear: string) { // TODO: Replace mock data with actual backend call - const mockQuestions: RegQuestionData[] = - [ { "M" : { "questionImageUrl" : { "S" : "" }, "label" : { "S" : "What school do you attend?" }, "questionId" : { "S" : "bede9713-17cf-4bb9-b362-8c30a1e5b543" }, "type" : { "S" : "SELECT" }, "choices" : { "S" : "UBC,SFU,KPU,Douglas,High School,..." }, "required" : { "BOOL" : true } } }, { "M" : { "label" : { "S" : "Do you have any accessibility/mobility needs that you would need us to know about?" }, "questionId" : { "S" : "49512eca-eec6-4639-b70c-f60f2e0a9371" }, "type" : { "S" : "SELECT" }, "choices" : { "S" : "Yes,No" }, "required" : { "BOOL" : true } } }, { "M" : { "label" : { "S" : "If you answered \"Yes\" to the question above, please let us know of any accommodations you will need below:" }, "questionId" : { "S" : "ee2b5b93-3792-4332-ba83-24b995f12094" }, "type" : { "S" : "TEXT" }, "choices" : { "S" : "" }, "required" : { "BOOL" : false } } }, { "M" : { "label" : { "S" : "LinkedIn URL:" }, "questionId" : { "S" : "013bb98c-4286-4649-bbb9-fbc27185925c" }, "type" : { "S" : "TEXT" }, "choices" : { "S" : "" }, "required" : { "BOOL" : false } } }, { "M" : { "label" : { "S" : "Resume:" }, "questionId" : { "S" : "ea4a8fa7-7bcf-4f86-af60-27ac61c7680b" }, "type" : { "S" : "UPLOAD" }, "choices" : { "S" : "" }, "required" : { "BOOL" : false } } }, { "M" : { "label" : { "S" : "Do you consent to us sharing your resume with our attending partners? (If you didn't upload one, select N/A)" }, "questionId" : { "S" : "f33ba987-6a5f-4ea2-9ba9-ca5f087e6fef" }, "type" : { "S" : "SELECT" }, "choices" : { "S" : "Yes,No,N/A" }, "required" : { "BOOL" : true } } }, { "M" : { "label" : { "S" : "Do you consent to having your email added to our sponsors' mailing lists? " }, "questionId" : { "S" : "a04e1064-65b2-4873-bede-9c4d5cbd32c3" }, "type" : { "S" : "SELECT" }, "choices" : { "S" : "Yes,No" }, "required" : { "BOOL" : true } } }, { "M" : { "label" : { "S" : "Would you be interested in getting your headshot taken at the conference?" }, "questionId" : { "S" : "24f0b385-d92e-43be-92a3-2b225964a778" }, "type" : { "S" : "SELECT" }, "choices" : { "S" : "Yes,No" }, "required" : { "BOOL" : true } } }, { "M" : { "label" : { "S" : "What's the first thing that comes to mind when you hear \"Digital Disruptions\"?" }, "questionId" : { "S" : "04f58eea-1861-4da3-8e4c-8d8e994ce8ba" }, "type" : { "S" : "TEXT" }, "choices" : { "S" : "" }, "required" : { "BOOL" : true } } }, { "M" : { "label" : { "S" : "Would you like to participate in our Attendee Showcase (view the event description above for more info)? If so, please complete ALL of the questions from this point on, otherwise, you may skip them." }, "questionId" : { "S" : "cb1a1e83-f581-473c-97e0-48e9a88d7d20" }, "type" : { "S" : "SELECT" }, "choices" : { "S" : "I would like to participate,I would not like to participate" }, "required" : { "BOOL" : true } } }, { "M" : { "label" : { "S" : "[A/S] Project Name" }, "questionId" : { "S" : "16ce18ff-9e88-4988-8965-b3edc172437a" }, "type" : { "S" : "TEXT" }, "choices" : { "S" : "" }, "required" : { "BOOL" : false } } }, { "M" : { "label" : { "S" : "[A/S] Full names of those who contributed to this project (you may only submit projects with up to 4 contributors MAX)" }, "questionId" : { "S" : "0836c57c-6163-4905-acb5-6578510b5a63" }, "type" : { "S" : "TEXT" }, "choices" : { "S" : "" }, "required" : { "BOOL" : false } } }, { "M" : { "label" : { "S" : "[A/S] Brief description of your project" }, "charLimit" : { "N" : "350" }, "questionId" : { "S" : "5328b778-e593-4077-bd58-d7b0f7cd1752" }, "type" : { "S" : "TEXT" }, "choices" : { "S" : "" }, "required" : { "BOOL" : false } } }, { "M" : { "label" : { "S" : "[A/S] Key technologies used to create your project" }, "questionId" : { "S" : "10231b92-5503-4a22-a205-25d99bee580b" }, "type" : { "S" : "TEXT" }, "choices" : { "S" : "" }, "required" : { "BOOL" : false } } }, { "M" : { "label" : { "S" : "[A/S] Relevant photo of your project (i.e. logo, screenshot of webpage, photo of prototype, etc)" }, "questionId" : { "S" : "e44b5fea-b18a-41bf-b6f2-e685b88d74da" }, "type" : { "S" : "UPLOAD" }, "choices" : { "S" : "" }, "required" : { "BOOL" : false } } }, { "M" : { "label" : { "S" : "[A/S] Link to your project/to learn more about your project (i.e. Github repo, website link, etc)" }, "questionId" : { "S" : "1099caf7-6e25-4c9a-97ab-c7628d1507e9" }, "type" : { "S" : "TEXT" }, "choices" : { "S" : "" }, "required" : { "BOOL" : false } } }, { "M" : { "label" : { "S" : "I confirm that the project I submitted abides by Blueprint's Attendee Showcase requirements (stated in this form's description)" }, "questionId" : { "S" : "f83944a8-97e2-421c-903c-aac91106fe34" }, "type" : { "S" : "SELECT" }, "choices" : { "S" : "I confirm,I didn't submit a project" }, "required" : { "BOOL" : true } } } ] - ; - // The 'test' user from the database was used here for the responses - const mockResponses: UserQuestionIDs = { - "ee2b5b93-3792-4332-ba83-24b995f12094": { S: "asdf" }, - "04f58eea-1861-4da3-8e4c-8d8e994ce8ba": { S: "asdf" }, - "bede9713-17cf-4bb9-b362-8c30a1e5b543": { S: "UBC" }, - "cb1a1e83-f581-473c-97e0-48e9a88d7d20": { S: "I would not like to participate" }, - "ea4a8fa7-7bcf-4f86-af60-27ac61c7680b": { S: "https://drive.google.com/file/d/1Q60JBkifak4gSrZL65KvafCPVA2HwcZ4/view?usp=drivesdk" }, - "013bb98c-4286-4649-bbb9-fbc27185925c": { S: "asdf" }, - "24f0b385-d92e-43be-92a3-2b225964a778": { S: "No" }, - "a04e1064-65b2-4873-bede-9c4d5cbd32c3": { S: "No" }, - "49512eca-eec6-4639-b70c-f60f2e0a9371": { S: "No" }, - "f33ba987-6a5f-4ea2-9ba9-ca5f087e6fef": { S: "No" }, - "f83944a8-97e2-421c-903c-aac91106fe34": { S: "I didn't submit a project" } - }; + const mockQuestions: RegistrationQuestion[] = + [ + { + "questionImageUrl": "", + "label": "What school do you attend?", + "questionId": "bede9713-17cf-4bb9-b362-8c30a1e5b543", + "type": "SELECT", + "choices": ["UBC", "SFU", "KPU", "Douglas", "High School", "..."], + "required": true + }, + { + "label": "Do you have any accessibility/mobility needs that you would need us to know about?", + "questionId": "49512eca-eec6-4639-b70c-f60f2e0a9371", + "type": "SELECT", + "choices": ["Yes", "No"], + "required": true + }, + { + "label": "If you answered 'Yes' to the question above, please let us know of any accommodations you will need below:", + "questionId": "ee2b5b93-3792-4332-ba83-24b995f12094", + "type": "TEXT", + "choices": [], + "required": false + }, + { + "label": "LinkedIn URL:", + "questionId": "013bb98c-4286-4649-bbb9-fbc27185925c", + "type": "TEXT", + "choices": [], + "required": false + }, + { + "label": "Resume:", + "questionId": "ea4a8fa7-7bcf-4f86-af60-27ac61c7680b", + "type": "UPLOAD", + "choices": [], + "required": false + }, + { + "label": "Do you consent to us sharing your resume with our attending partners? (If you didn't upload one, select N/A)", + "questionId": "f33ba987-6a5f-4ea2-9ba9-ca5f087e6fef", + "type": "SELECT", + "choices": ["Yes", "No", "N/A"], + "required": true + }, + { + "label": "Do you consent to having your email added to our sponsors' mailing lists?", + "questionId": "a04e1064-65b2-4873-bede-9c4d5cbd32c3", + "type": "SELECT", + "choices": ["Yes", "No"], + "required": true + }, + { + "label": "Would you be interested in getting your headshot taken at the conference?", + "questionId": "24f0b385-d92e-43be-92a3-2b225964a778", + "type": "SELECT", + "choices": ["Yes", "No"], + "required": true + }, + { + "label": "What's the first thing that comes to mind when you hear 'Digital Disruptions'?", + "questionId": "04f58eea-1861-4da3-8e4c-8d8e994ce8ba", + "type": "TEXT", + "choices": [], + "required": true + }, + { + "label": "Would you like to participate in our Attendee Showcase (view the event description above for more info)? If so, please complete ALL of the questions from this point on, otherwise, you may skip them.", + "questionId": "cb1a1e83-f581-473c-97e0-48e9a88d7d20", + "type": "SELECT", + "choices": ["I would like to participate", "I would not like to participate"], + "required": true + }, + { + "label": "[A/S] Project Name", + "questionId": "16ce18ff-9e88-4988-8965-b3edc172437a", + "type": "TEXT", + "choices": [], + "required": false + }, + { + "label": "[A/S] Full names of those who contributed to this project (you may only submit projects with up to 4 contributors MAX)", + "questionId": "0836c57c-6163-4905-acb5-6578510b5a63", + "type": "TEXT", + "choices": [], + "required": false + }, + { + "label": "[A/S] Brief description of your project", + "charLimit": 350, + "questionId": "5328b778-e593-4077-bd58-d7b0f7cd1752", + "type": "TEXT", + "choices": [], + "required": false + }, + { + "label": "[A/S] Key technologies used to create your project", + "questionId": "10231b92-5503-4a22-a205-25d99bee580b", + "type": "TEXT", + "choices": [], + "required": false + }, + { + "label": "[A/S] Relevant photo of your project (i.e. logo, screenshot of webpage, photo of prototype, etc)", + "questionId": "e44b5fea-b18a-41bf-b6f2-e685b88d74da", + "type": "UPLOAD", + "choices": [], + "required": false + }, + { + "label": "[A/S] Link to your project/to learn more about your project (i.e. Github repo, website link, etc)", + "questionId": "1099caf7-6e25-4c9a-97ab-c7628d1507e9", + "type": "TEXT", + "choices": [], + "required": false + }, + { + "label": "I confirm that the project I submitted abides by Blueprint's Attendee Showcase requirements (stated in this form's description)", + "questionId": "f83944a8-97e2-421c-903c-aac91106fe34", + "type": "SELECT", + "choices": ["I confirm", "I didn't submit a project"], + "required": true + } + ]; return { - questions: mockQuestions, - responses: mockResponses, + questions: mockQuestions }; }; diff --git a/src/components/RegistrationTable/editCellPopUp.tsx/userInfo.tsx b/src/components/RegistrationTable/editCellPopUp.tsx/userInfo.tsx index fdb261c..5acbc01 100644 --- a/src/components/RegistrationTable/editCellPopUp.tsx/userInfo.tsx +++ b/src/components/RegistrationTable/editCellPopUp.tsx/userInfo.tsx @@ -50,8 +50,8 @@ const UserInfo: React.FC = ({ row, table }) => { }, [table]); - const fieldsToDisplay = Object.keys(row.original).filter(key => key !== 'shouldNotDisplay' && key !== 'id'); - + const fieldsToDisplay = Object.keys(row.original).filter(key => key !== 'shouldNotDisplay' && key !== 'id' && key != 'dynamicResponses'); + return (
diff --git a/src/components/RegistrationTable/editCellPopUp.tsx/userResponses.tsx b/src/components/RegistrationTable/editCellPopUp.tsx/userResponses.tsx index 3095814..b2b71c3 100644 --- a/src/components/RegistrationTable/editCellPopUp.tsx/userResponses.tsx +++ b/src/components/RegistrationTable/editCellPopUp.tsx/userResponses.tsx @@ -1,19 +1,18 @@ import React from 'react'; -import { RegQuestionData, UserResponse } from '../../../types'; +import { RegistrationQuestion, UserResponseList } from '../../../types'; interface UserResponsesProps { - questions: RegQuestionData[]; - responses: { [key: string]: UserResponse }; + questions: RegistrationQuestion[]; + responses: UserResponseList; } const UserResponses: React.FC = ({ questions, responses }) => { return (
{questions.map((question, index) => { - const questionData = question.M; - const label = questionData.label.S; - const questionId = questionData.questionId.S; + const label = question.label; + const questionId = question.questionId; const answer = responses[questionId]?.S || 'No response'; return ( diff --git a/src/pages/admin/event/[eventId]/[year].tsx b/src/pages/admin/event/[eventId]/[year].tsx index 8848aab..c8e94f6 100644 --- a/src/pages/admin/event/[eventId]/[year].tsx +++ b/src/pages/admin/event/[eventId]/[year].tsx @@ -97,7 +97,20 @@ async function fetchRegistationData(eventId: string, year: string) { studentNumber: "12345678", faculty: "Comm...", dynamicField1: "aa...", - shouldNotDisplay: "THIS SHOULD NOT BE DISPLAYING." + shouldNotDisplay: "THIS SHOULD NOT BE DISPLAYING.", + dynamicResponses: { + "ee2b5b93-3792-4332-ba83-24b995f12094": { S: "asdf" }, + "04f58eea-1861-4da3-8e4c-8d8e994ce8ba": { S: "asdf" }, + "bede9713-17cf-4bb9-b362-8c30a1e5b543": { S: "UBC" }, + "cb1a1e83-f581-473c-97e0-48e9a88d7d20": { S: "I would not like to participate" }, + "ea4a8fa7-7bcf-4f86-af60-27ac61c7680b": { S: "https://drive.google.com/file/d/1Q60JBkifak4gSrZL65KvafCPVA2HwcZ4/view?usp=drivesdk" }, + "013bb98c-4286-4649-bbb9-fbc27185925c": { S: "asdf" }, + "24f0b385-d92e-43be-92a3-2b225964a778": { S: "No" }, + "a04e1064-65b2-4873-bede-9c4d5cbd32c3": { S: "No" }, + "49512eca-eec6-4639-b70c-f60f2e0a9371": { S: "No" }, + "f33ba987-6a5f-4ea2-9ba9-ca5f087e6fef": { S: "No" }, + "f83944a8-97e2-421c-903c-aac91106fe34": { S: "I didn't submit a project" } + } }) } diff --git a/src/types.ts b/src/types.ts index d3ccdf6..2cfeec6 100644 --- a/src/types.ts +++ b/src/types.ts @@ -9,40 +9,25 @@ export type BasicInformation = { faculty: string } -export type RegQuestionAttributes = { - label: { - S: string; - }; - charLimit?: { - N: string; - }, - questionId: { - S: string; - }; - type: { - S: string; - }; - choices: { - S: string; - }; - required: { - BOOL: boolean; - }; - questionImageUrl?: { - S?: string; - }; +export type RegistrationQuestion = { + label: string; + questionId: string; + type: string; + required: boolean; + choices?: string[]; + charLimit?: number; + questionImageUrl?: string; + participantCap?: string; + isSkillsQuestion?: boolean; } -export type RegQuestionData = { - M: RegQuestionAttributes; -} - -export type UserResponse = { +type UserResponse = { S: string; }; -export type UserQuestionIDs = { - [key: string]: UserResponse; +// Type for the mapping of question IDs to responses +export type UserResponseList = { + [questionId: string]: UserResponse; }; From edbbf146e2206fa966aa9c8822c5cd2822696850 Mon Sep 17 00:00:00 2001 From: m20arcusk Date: Fri, 16 Aug 2024 22:39:26 -0700 Subject: [PATCH 9/9] updated userResponse type and changed how it is accessed in userResponses.tsx --- .../editCellPopUp.tsx/userResponses.tsx | 2 +- src/pages/admin/event/[eventId]/[year].tsx | 27 ++++++++++--------- src/types.ts | 6 +---- 3 files changed, 16 insertions(+), 19 deletions(-) diff --git a/src/components/RegistrationTable/editCellPopUp.tsx/userResponses.tsx b/src/components/RegistrationTable/editCellPopUp.tsx/userResponses.tsx index b2b71c3..863a672 100644 --- a/src/components/RegistrationTable/editCellPopUp.tsx/userResponses.tsx +++ b/src/components/RegistrationTable/editCellPopUp.tsx/userResponses.tsx @@ -13,7 +13,7 @@ const UserResponses: React.FC = ({ questions, responses }) = const label = question.label; const questionId = question.questionId; - const answer = responses[questionId]?.S || 'No response'; + const answer = responses[questionId] || 'No response'; return (
diff --git a/src/pages/admin/event/[eventId]/[year].tsx b/src/pages/admin/event/[eventId]/[year].tsx index c8e94f6..368781d 100644 --- a/src/pages/admin/event/[eventId]/[year].tsx +++ b/src/pages/admin/event/[eventId]/[year].tsx @@ -98,19 +98,20 @@ async function fetchRegistationData(eventId: string, year: string) { faculty: "Comm...", dynamicField1: "aa...", shouldNotDisplay: "THIS SHOULD NOT BE DISPLAYING.", - dynamicResponses: { - "ee2b5b93-3792-4332-ba83-24b995f12094": { S: "asdf" }, - "04f58eea-1861-4da3-8e4c-8d8e994ce8ba": { S: "asdf" }, - "bede9713-17cf-4bb9-b362-8c30a1e5b543": { S: "UBC" }, - "cb1a1e83-f581-473c-97e0-48e9a88d7d20": { S: "I would not like to participate" }, - "ea4a8fa7-7bcf-4f86-af60-27ac61c7680b": { S: "https://drive.google.com/file/d/1Q60JBkifak4gSrZL65KvafCPVA2HwcZ4/view?usp=drivesdk" }, - "013bb98c-4286-4649-bbb9-fbc27185925c": { S: "asdf" }, - "24f0b385-d92e-43be-92a3-2b225964a778": { S: "No" }, - "a04e1064-65b2-4873-bede-9c4d5cbd32c3": { S: "No" }, - "49512eca-eec6-4639-b70c-f60f2e0a9371": { S: "No" }, - "f33ba987-6a5f-4ea2-9ba9-ca5f087e6fef": { S: "No" }, - "f83944a8-97e2-421c-903c-aac91106fe34": { S: "I didn't submit a project" } - } + dynamicResponses: + { + "ee2b5b93-3792-4332-ba83-24b995f12094": "asdf", + "04f58eea-1861-4da3-8e4c-8d8e994ce8ba": "asdf", + "bede9713-17cf-4bb9-b362-8c30a1e5b543": "UBC", + "cb1a1e83-f581-473c-97e0-48e9a88d7d20": "I would not like to participate", + "ea4a8fa7-7bcf-4f86-af60-27ac61c7680b": "https://drive.google.com/file/d/1Q60JBkifak4gSrZL65KvafCPVA2HwcZ4/view?usp=drivesdk", + "013bb98c-4286-4649-bbb9-fbc27185925c": "asdf", + "24f0b385-d92e-43be-92a3-2b225964a778": "No", + "a04e1064-65b2-4873-bede-9c4d5cbd32c3": "No", + "49512eca-eec6-4639-b70c-f60f2e0a9371": "No", + "f33ba987-6a5f-4ea2-9ba9-ca5f087e6fef": "No", + "f83944a8-97e2-421c-903c-aac91106fe34": "I didn't submit a project" + }, }) } diff --git a/src/types.ts b/src/types.ts index 2cfeec6..472289b 100644 --- a/src/types.ts +++ b/src/types.ts @@ -21,13 +21,9 @@ export type RegistrationQuestion = { isSkillsQuestion?: boolean; } -type UserResponse = { - S: string; -}; - // Type for the mapping of question IDs to responses export type UserResponseList = { - [questionId: string]: UserResponse; + [questionId: string]: string; };