|
|
@ -1,7 +1,9 @@ |
|
|
"use client"; |
|
|
"use client"; |
|
|
|
|
|
|
|
|
import { useMutation, useQueryClient } from "@tanstack/react-query"; |
|
|
import { useMutation, useQueryClient } from "@tanstack/react-query"; |
|
|
|
|
|
import { setCachedMarriageEntryPath } from "@/lib/entry-route-cache"; |
|
|
import { http } from "@/lib/http"; |
|
|
import { http } from "@/lib/http"; |
|
|
|
|
|
import { saveScopedMarriageProfile } from "@/lib/user-scoped-storage"; |
|
|
import type { MutationOptions } from "./options"; |
|
|
import type { MutationOptions } from "./options"; |
|
|
import { pathParam } from "./path-param"; |
|
|
import { pathParam } from "./path-param"; |
|
|
import { marriageQueryKeys } from "./query-keys"; |
|
|
import { marriageQueryKeys } from "./query-keys"; |
|
|
@ -37,14 +39,17 @@ export function useRespondToMarriageCaseMutation( |
|
|
mutationFn: (payload) => respondToMarriageCase(caseId, payload), |
|
|
mutationFn: (payload) => respondToMarriageCase(caseId, payload), |
|
|
onSuccess: async (data, variables, onMutateResult, context) => { |
|
|
onSuccess: async (data, variables, onMutateResult, context) => { |
|
|
if (variables?.action === "reject") { |
|
|
if (variables?.action === "reject") { |
|
|
|
|
|
setCachedMarriageEntryPath("/finding-match"); |
|
|
queryClient.setQueryData(marriageQueryKeys.profile(), (old: any) => { |
|
|
queryClient.setQueryData(marriageQueryKeys.profile(), (old: any) => { |
|
|
if (!old) return old; |
|
|
if (!old) return old; |
|
|
return { |
|
|
|
|
|
|
|
|
const updated = { |
|
|
...old, |
|
|
...old, |
|
|
status: "waiting", |
|
|
status: "waiting", |
|
|
active_case: null, |
|
|
active_case: null, |
|
|
match_summary: null, |
|
|
match_summary: null, |
|
|
}; |
|
|
}; |
|
|
|
|
|
saveScopedMarriageProfile(updated); |
|
|
|
|
|
return updated; |
|
|
}); |
|
|
}); |
|
|
} else if (data?.case) { |
|
|
} else if (data?.case) { |
|
|
queryClient.setQueryData(marriageQueryKeys.profile(), (old: any) => { |
|
|
queryClient.setQueryData(marriageQueryKeys.profile(), (old: any) => { |
|
|
@ -66,10 +71,12 @@ export function useRespondToMarriageCaseMutation( |
|
|
: "completed" |
|
|
: "completed" |
|
|
: "waiting", |
|
|
: "waiting", |
|
|
}; |
|
|
}; |
|
|
return { |
|
|
|
|
|
|
|
|
const updated = { |
|
|
...old, |
|
|
...old, |
|
|
active_case: updatedActiveCase, |
|
|
active_case: updatedActiveCase, |
|
|
}; |
|
|
}; |
|
|
|
|
|
saveScopedMarriageProfile(updated); |
|
|
|
|
|
return updated; |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|