refactor: enhance user confirmation response with userId in userAccettaConferma
This commit is contained in:
parent
05998c6237
commit
5df7e8cef8
2 changed files with 9 additions and 3 deletions
|
|
@ -11,6 +11,7 @@ import { Button } from "~/components/ui/button";
|
|||
import { Checkbox } from "~/components/ui/checkbox";
|
||||
import type { NextPageWithLayout } from "~/pages/_app";
|
||||
import { useTranslation } from "~/providers/I18nProvider";
|
||||
import { useEnforcedSession } from "~/providers/SessionProvider";
|
||||
import type { AnnunciId } from "~/schemas/public/Annunci";
|
||||
import type { ServizioServizioId } from "~/schemas/public/Servizio";
|
||||
import { TrpcAuthedFetchingIstance } from "~/server/utils/ssgHelper";
|
||||
|
|
@ -82,6 +83,7 @@ const ConfirmSection = ({
|
|||
const router = useRouter();
|
||||
const [letto, setLetto] = useState(false);
|
||||
const [accettato, setAccettato] = useState(false);
|
||||
const { user } = useEnforcedSession();
|
||||
const utils = api.useUtils();
|
||||
const { mutate: conferma } =
|
||||
api.servizio.userAcceptConfermaImmobile.useMutation({
|
||||
|
|
@ -91,14 +93,18 @@ const ConfirmSection = ({
|
|||
});
|
||||
return { toastId };
|
||||
},
|
||||
onSuccess: async (_data, _variables, context) => {
|
||||
onSuccess: async (data, _variables, context) => {
|
||||
await utils.storage.retrieveUserFileData.invalidate();
|
||||
|
||||
toast.success("Confermato", {
|
||||
icon: "👍",
|
||||
id: context?.toastId,
|
||||
});
|
||||
|
||||
if (user.isAdmin) {
|
||||
await router.push(
|
||||
`/area-riservata/admin/user-view/ricerca/${data.userId}`,
|
||||
);
|
||||
}
|
||||
await router.push("/area-riservata/dashboard");
|
||||
},
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1403,7 +1403,7 @@ export const userAccettaConferma = async ({
|
|||
},
|
||||
});
|
||||
|
||||
return true;
|
||||
return { success: true, userId: utente.id };
|
||||
} catch (e) {
|
||||
throw new TRPCError({
|
||||
code: "INTERNAL_SERVER_ERROR",
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue