diff --git a/app/[locale]/[investigation]/[...uriSegments]/page.tsx b/app/[locale]/[investigation]/[...uriSegments]/page.tsx index 49862425..990240e3 100644 --- a/app/[locale]/[investigation]/[...uriSegments]/page.tsx +++ b/app/[locale]/[investigation]/[...uriSegments]/page.tsx @@ -77,7 +77,12 @@ const UriSegments: (props: { const user = getUserFromJwt(craftToken); return ( - + {user && ( <>

User: {JSON.stringify(user)}

diff --git a/components/answers/SaveForm/SaveForm.tsx b/components/answers/SaveForm/SaveForm.tsx index 2476db55..090819dc 100644 --- a/components/answers/SaveForm/SaveForm.tsx +++ b/components/answers/SaveForm/SaveForm.tsx @@ -11,15 +11,22 @@ import { getUserFromJwt } from "@/components/auth/serverHelpers"; export default function SaveForm({ investigationId, user, + userStatus, }: { investigationId: InvestigationId; user?: ReturnType; + userStatus?: string; }) { const { t } = useTranslation(); const [status, setStatus] = useState< - "emptyError" | "refreshError" | "mutationError" | "success" | null - >(null); + | "emptyError" + | "refreshError" + | "mutationError" + | "statusError" + | "success" + | null + >(userStatus === "pending" ? "statusError" : null); if (!investigationId || !user) return null; @@ -48,6 +55,8 @@ export default function SaveForm({ ); if (result === "refreshError") { setStatus("refreshError"); + } else if (result === "statusError") { + setStatus("statusError"); } else { setStatus("success"); } @@ -57,7 +66,10 @@ export default function SaveForm({ }} aria-label={t("answers.save_form.label") ?? undefined} > - + {(pending) => t( pending @@ -79,6 +91,9 @@ export default function SaveForm({ {status === "mutationError" && (

{t("answers.save_form.mutation_error_message")}

)} + {status === "statusError" && ( +

{t("answers.save_form.status_error_message")}

+ )} ); diff --git a/components/educator-schema/saveAnswersAction.ts b/components/educator-schema/saveAnswersAction.ts index 5c3fdbeb..b8cf4d1f 100644 --- a/components/educator-schema/saveAnswersAction.ts +++ b/components/educator-schema/saveAnswersAction.ts @@ -25,12 +25,16 @@ export default async function saveAnswers( investigationId: NonNullable, answers: Answers ) { - const { craftUserId, craftToken } = await getAuthCookies(); + const { craftUserId, craftToken, craftUserStatus } = await getAuthCookies(); if (!craftUserId || !craftToken) { return "refreshError"; } + if (craftUserStatus === "pending") { + return "statusError"; + } + const answerSet = Object.values(answers); const { data, error } = await mutateAPI({ diff --git a/components/student-schema/saveAnswersAction.ts b/components/student-schema/saveAnswersAction.ts index 5c3fdbeb..b8cf4d1f 100644 --- a/components/student-schema/saveAnswersAction.ts +++ b/components/student-schema/saveAnswersAction.ts @@ -25,12 +25,16 @@ export default async function saveAnswers( investigationId: NonNullable, answers: Answers ) { - const { craftUserId, craftToken } = await getAuthCookies(); + const { craftUserId, craftToken, craftUserStatus } = await getAuthCookies(); if (!craftUserId || !craftToken) { return "refreshError"; } + if (craftUserStatus === "pending") { + return "statusError"; + } + const answerSet = Object.values(answers); const { data, error } = await mutateAPI({ diff --git a/components/templates/InvestigationChildPage/index.tsx b/components/templates/InvestigationChildPage/index.tsx index a005c04d..aa71d7cc 100644 --- a/components/templates/InvestigationChildPage/index.tsx +++ b/components/templates/InvestigationChildPage/index.tsx @@ -125,6 +125,7 @@ const InvestigationChildPage: FunctionComponent<{ data: FragmentType; site: string; user?: ReturnType; + userStatus?: string; children?: React.ReactNode; }> = (props) => { // const { t } = useTranslation(); @@ -150,7 +151,11 @@ const InvestigationChildPage: FunctionComponent<{ ) )} {data.hasSavePoint && props.user && ( - + )} diff --git a/public/localeStrings/en/translation.json b/public/localeStrings/en/translation.json index 628a3f40..f014860f 100644 --- a/public/localeStrings/en/translation.json +++ b/public/localeStrings/en/translation.json @@ -244,7 +244,8 @@ "success_message": "Answers saved!", "empty_error_message": "No new answers to save.", "refresh_error_message": "Your session has expired. Please log back in and try again.", - "mutation_error_message": "There was an error saving your answers to your account." + "mutation_error_message": "There was an error saving your answers to your account.", + "status_error_message": "Activate your account to begin saving. Check your inbox for an activation email." } }, "review": {