Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | 2x 2x 2x 2x 2x 2x 9x 10x 10x 2x 2x 2x 2x 2x 2x | import { useMutation } from "@tanstack/react-query";
import Alert from "components/Alert";
import { useAuthContext } from "features/auth/AuthProvider";
import CommunityGuidelines from "features/auth/CommunityGuidelines";
import { RpcError } from "grpc-web";
import TagManager from "react-gtm-module";
import { service } from "service";
export default function CommunityGuidelinesForm() {
const { authActions, authState } = useAuthContext();
const mutation = useMutation<void, RpcError, boolean>({
mutationFn: async (accept) => {
const state = await service.auth.signupFlowCommunityGuidelines(
authState.flowState!.flowToken,
accept,
);
TagManager.dataLayer({
dataLayer: {
event: "sign_up",
signupMethod: "email",
userId: state.authRes?.userId || -1,
"gtm.elementUrl": `${window.location.hostname}${window.location.pathname}`,
},
});
authActions.updateSignupState(state);
},
onMutate() {
authActions.clearError();
},
onSettled() {
window.scroll({ top: 0, behavior: "smooth" });
},
});
return (
<>
{mutation.error && (
<Alert severity="error">{mutation.error.message || ""}</Alert>
)}
<CommunityGuidelines
onSubmit={(accept) => mutation.mutateAsync(accept)}
/>
</>
);
}
|