diff --git a/src/app/questions-list/page.tsx b/src/app/questions-list/page.tsx
index c714ede..0bddedc 100644
--- a/src/app/questions-list/page.tsx
+++ b/src/app/questions-list/page.tsx
@@ -283,6 +283,7 @@ export default function QuestionsListPage() {
const result = await updateMarriageSectionData(pendingSections[0].slug, {
current_step: pendingSections[0].storedValue.current_step,
fields: pendingSections.flatMap((section) => section.fields),
+ version: overview.version,
});
applyProfilePatchResultToCache(queryClient, locale, result);
const cleared = new Set(result.cleared_answer_ids ?? []);
@@ -451,6 +452,11 @@ export default function QuestionsListPage() {
} catch (err) {
console.error("Failed to sync pending sections:", err);
setIsSyncError(true);
+ setToastMessage(
+ t[
+ "Sending the match request failed. Please check your connection and try again."
+ ] ?? "Sending the match request failed. Please check your connection and try again."
+ );
} finally {
setIsSyncing(false);
}
diff --git a/src/components/Componentes/button.tsx b/src/components/Componentes/button.tsx
index 0c9008c..5c013dc 100644
--- a/src/components/Componentes/button.tsx
+++ b/src/components/Componentes/button.tsx
@@ -153,7 +153,47 @@ export function Button({
);
};
- const button = (
+ const content = isLoading ? (
+
+ ) : (
+
+ {renderArrow("left")}
+
+
+ {children}
+
+ {description && !isOutlined ? (
+
+ {description}
+
+ ) : null}
+
+ {countdownLocked ? (
+
+
+
+ ) : (
+ renderArrow("right")
+ )}
+
+ );
+
+ if (href) {
+ return (
+
+ {content}
+
+ );
+ }
+
+ return (
);
-
- return href ? (
- {button}
- ) : (
- button
- );
}
type CountdownProgressProps = {
diff --git a/src/components/Componentes/question-answer-storage.tsx b/src/components/Componentes/question-answer-storage.tsx
index 83d63de..9e4e578 100644
--- a/src/components/Componentes/question-answer-storage.tsx
+++ b/src/components/Componentes/question-answer-storage.tsx
@@ -317,6 +317,7 @@ export function QuestionAnswersProvider({
const storageKeyRef = useRef(storageKey);
const slugRef = useRef(slug);
const backendFieldsRef = useRef([]);
+ const versionRef = useRef(undefined);
const dirtyKeysRef = useRef(new Set());
const { data: profile } = useMarriageProfileQuery();
@@ -331,12 +332,14 @@ export function QuestionAnswersProvider({
slugRef.current = slug;
questionsRef.current = questions;
backendFieldsRef.current = serverSectionData?.data || [];
+ versionRef.current = serverSectionData?.version;
}, [
answers,
hasPendingSync,
slug,
questions,
serverSectionData?.data,
+ serverSectionData?.version,
]);
useEffect(() => {
@@ -491,6 +494,7 @@ export function QuestionAnswersProvider({
fields: nextDirtyKey
? fullPayload.fields.filter((field) => field.key === nextDirtyKey)
: [],
+ version: versionRef.current,
};
const revision = answersRevisionRef.current;
@@ -591,7 +595,7 @@ export function QuestionAnswersProvider({
const pendingFields = fullPayload.fields.filter((field) =>
dirtyKeysRef.current.has(field.key),
);
- const payload = { ...fullPayload, fields: pendingFields };
+ const payload = { ...fullPayload, fields: pendingFields, version: versionRef.current };
const revision = answersRevisionRef.current;
if (payload.fields.length === 0) {
@@ -616,6 +620,7 @@ export function QuestionAnswersProvider({
fetch(getKeepalivePatchUrl(slugRef.current), {
body: JSON.stringify({
answers: answersPayload,
+ version: payload.version,
}),
credentials: "include",
headers,
diff --git a/src/hooks/marriage/types.ts b/src/hooks/marriage/types.ts
index 20d8fe9..77d7e6f 100644
--- a/src/hooks/marriage/types.ts
+++ b/src/hooks/marriage/types.ts
@@ -148,12 +148,14 @@ export type MarriageSectionData = {
total_steps: number;
completion_percent: number;
updated_at: string | null;
+ version?: number;
};
export type UpdateMarriageSectionDataPayload = {
current_step: number;
total_steps?: number;
fields: MarriageField[];
+ version?: number;
};
export type MarriageQuestionState = {
diff --git a/src/hooks/marriage/use-form-schema.ts b/src/hooks/marriage/use-form-schema.ts
index 0d2c644..e6b2630 100644
--- a/src/hooks/marriage/use-form-schema.ts
+++ b/src/hooks/marriage/use-form-schema.ts
@@ -77,12 +77,14 @@ export interface FormOverviewSection extends Omit {
export interface FormOverviewResponse {
form_id: string;
+ version: number;
sections: FormOverviewSection[];
progress: FormSchemaResponse["progress"];
}
export interface FormSectionResponse {
form_id: string;
+ version: number;
section: FormSection;
answers: FormSchemaResponse["answers"];
progress: FormSchemaResponse["progress"];
diff --git a/src/hooks/marriage/use-section-data.ts b/src/hooks/marriage/use-section-data.ts
index 84ce21d..e0d9671 100644
--- a/src/hooks/marriage/use-section-data.ts
+++ b/src/hooks/marriage/use-section-data.ts
@@ -25,10 +25,11 @@ type AnswersPayloadItem = {
async function patchAnswers(
answersPayload: AnswersPayloadItem[],
+ version?: number,
): Promise {
const response = await http.patch(
ANSWERS_ENDPOINT,
- { answers: answersPayload },
+ { answers: answersPayload, version },
);
return response.data;
}
@@ -43,7 +44,7 @@ export async function updateMarriageSectionData(
option_id: f.option_id || undefined,
}));
- const data = await patchAnswers(answersPayload);
+ const data = await patchAnswers(answersPayload, payload.version);
const prog = data.affected_sections[slug] ||
data.progress.sections_progress[slug] || {
@@ -204,6 +205,7 @@ export function useMarriageSectionDataQuery(
data: fields,
...progress,
updated_at: null,
+ version: query.data.version,
};
})()
: undefined,