From 908135902a8bfdb118ab8cf71edf8ec968e69305 Mon Sep 17 00:00:00 2001 From: avenmia Date: Thu, 5 Sep 2024 20:00:32 -0500 Subject: [PATCH] Adding initial summary page (#215) * Adding initial summary page * Fixing styling * Adding island and county areas * Code cleanup --- src/components/ProgressBar.tsx | 1 + src/components/SummaryQuestionAnswer.tsx | 20 +++ src/components/survey/demographicssurvey.tsx | 2 +- src/pages/querysummary.tsx | 169 +++++++++++++++++++ src/server/api/routers/user.ts | 10 ++ 5 files changed, 201 insertions(+), 1 deletion(-) create mode 100644 src/components/SummaryQuestionAnswer.tsx create mode 100644 src/pages/querysummary.tsx diff --git a/src/components/ProgressBar.tsx b/src/components/ProgressBar.tsx index d96c8e6..952331b 100644 --- a/src/components/ProgressBar.tsx +++ b/src/components/ProgressBar.tsx @@ -11,6 +11,7 @@ const ProgressBar = ({ completed }: ProgressBarProps) => { backgroundColor: "yellowGreen", borderRadius: "inherit", transition: "width 1s ease-in-out", + minHeight: "100%", }; return ( diff --git a/src/components/SummaryQuestionAnswer.tsx b/src/components/SummaryQuestionAnswer.tsx new file mode 100644 index 0000000..a521ebc --- /dev/null +++ b/src/components/SummaryQuestionAnswer.tsx @@ -0,0 +1,20 @@ +import { Key } from "react"; + +interface SummaryQuestionAnswerProps { + question: string; + answer: string; + key?: Key; +} + +export default function SummaryQuestionAnswer({ + question, + answer, + key, +}: SummaryQuestionAnswerProps) { + return ( +
  • +

    {question}

    +

    {answer}

    +
  • + ); +} diff --git a/src/components/survey/demographicssurvey.tsx b/src/components/survey/demographicssurvey.tsx index cd7fbe4..00f7c83 100644 --- a/src/components/survey/demographicssurvey.tsx +++ b/src/components/survey/demographicssurvey.tsx @@ -172,7 +172,7 @@ export default function DemographicsSurvey() { > Retake demographic survey - + + +
    +
    +
    +

    Location Questions

    +
      + + + + + +
    +
    +
    +

    Demographic Questions

    +
      + {sortedDemoQuestions.map((question, index) => { + let userAnswer = "No Answer"; + if (answersResult) { + userAnswer = answersResult[index + 1] ?? "No answer"; + } + return ( + + ); + })} +
    +
    +
    +
    +
    +
    + + + + + + +
    +
    + + + +
    +
    + + + ); +}; + +export default QuerySummary; diff --git a/src/server/api/routers/user.ts b/src/server/api/routers/user.ts index 8631bb5..be2e89f 100644 --- a/src/server/api/routers/user.ts +++ b/src/server/api/routers/user.ts @@ -104,4 +104,14 @@ export const userRouter = createTRPCRouter({ }, }); }), + getDemoSurveyAnswers: publicProcedure.query(async ({ ctx }) => { + if (!ctx.session) { + console.log("Not authenticated"); + return null; + } + const { id: userId } = ctx.session.user; + return ctx.prisma.userSurveyAnswers.findMany({ + where: { userId: userId }, + }); + }), });