All files / app/features/auth/signup CommunityGuidelinesForm.tsx

100% Statements 13/13
33.33% Branches 1/3
100% Functions 5/5
100% Lines 13/13

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 312x 2x 2x 2x   2x   9x 10x   10x   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 { 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);
      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)} />
    </>
  );
}