fix(interviews): retain answers and live errors after failed saves
This commit is contained in:
@@ -45,7 +45,7 @@ function Shell({ title, subtitle, loading, error, children, onRetry, keepContent
|
||||
export function ApplicationInterviewPrep({ jobId }: { jobId: number }) {
|
||||
const { t } = useI18n();
|
||||
const [board, setBoard] = useState<InterviewPrepBoard | null>(null);
|
||||
const [error, setError] = useState<string | { cause: unknown; fallback: "interviewPrepLoadFailed" | "interviewPrepUpdateFailed" } | null>(null);
|
||||
const [error, setError] = useState<{ cause: unknown; fallback: "interviewPrepLoadFailed" | "interviewPrepUpdateFailed" | "interviewPrepAnswerSaveFailed" } | null>(null);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [busy, setBusy] = useState(false);
|
||||
const [title, setTitle] = useState("");
|
||||
@@ -101,7 +101,8 @@ export function ApplicationInterviewPrep({ jobId }: { jobId: number }) {
|
||||
title={t("interviewPrepTitle")}
|
||||
subtitle={t("interviewPrepSubtitle")}
|
||||
loading={loading}
|
||||
error={typeof error === "string" ? error : error ? getApiErrorMessage(error.cause, t(error.fallback)) : null}
|
||||
error={error ? getApiErrorMessage(error.cause, t(error.fallback)) : null}
|
||||
keepContentOnError={error?.fallback === "interviewPrepAnswerSaveFailed"}
|
||||
>
|
||||
<Stack spacing={2}>
|
||||
{board && !board.isInterviewStage && (
|
||||
@@ -317,7 +318,7 @@ function PrepRow({ jobId, item, busy, onChanged, onError }: {
|
||||
item: InterviewPrepItem;
|
||||
busy: boolean;
|
||||
onChanged: () => void;
|
||||
onError: (message: string) => void;
|
||||
onError: (error: { cause: unknown; fallback: "interviewPrepAnswerSaveFailed" }) => void;
|
||||
}) {
|
||||
const { t } = useI18n();
|
||||
const { confirm } = useConfirm();
|
||||
@@ -333,7 +334,7 @@ function PrepRow({ jobId, item, busy, onChanged, onError }: {
|
||||
setDraft(null);
|
||||
onChanged();
|
||||
} catch (err) {
|
||||
onError(getApiErrorMessage(err, t("interviewPrepAnswerSaveFailed")));
|
||||
onError({ cause: err, fallback: "interviewPrepAnswerSaveFailed" });
|
||||
} finally {
|
||||
setSaving(false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user