MCPcopy Create free account
hub / github.com/dailydotdev/apps / useRegistration

Function useRegistration

packages/shared/src/hooks/useRegistration.ts:50–250  ·  view source on GitHub ↗
({
  onRedirect,
  onInvalidRegistration,
  onInitializeVerification,
}: UseRegistrationProps)

Source from the content-addressed store, hash-verified

48 "We couldn't complete sign up. If you already have an account, try signing in instead.";
49
50const useRegistration = ({
51 onRedirect,
52 onInvalidRegistration,
53 onInitializeVerification,
54}: UseRegistrationProps): UseRegistration => {
55 const { logEvent } = useLogContext();
56 const { displayToast } = useToastNotification();
57 const { referral, referralOrigin, geo, refetchBoot } =
58 useContext(AuthContext);
59 const timezone = getUserDefaultTimezone();
60
61 const {
62 mutateAsync: betterAuthRegister,
63 status,
64 isPending: isBetterAuthMutationLoading,
65 } = useMutation({
66 mutationFn: async (params: {
67 name: string;
68 email: string;
69 password: string;
70 turnstileToken?: string;
71 username?: string;
72 experienceLevel?: string;
73 company?: string;
74 title?: string;
75 cloudProvider?: string;
76 referral?: string;
77 referralOrigin?: string;
78 timezone?: string;
79 region?: string;
80 acceptedMarketing?: boolean;
81 }) => {
82 logEvent({
83 event_name: 'click',
84 target_type: AuthEventNames.SignUpProvider,
85 target_id: 'email',
86 extra: JSON.stringify({ trigger: 'registration' }),
87 });
88 return betterAuthSignUp({
89 ...params,
90 });
91 },
92 onSuccess: async (res) => {
93 if (res.error) {
94 logEvent({
95 event_name: AuthEventNames.RegistrationError,
96 extra: JSON.stringify({
97 provider: 'password',
98 error: res.error,
99 origin: 'betterauth signup error',
100 }),
101 });
102 onInvalidRegistration?.({
103 [getBetterAuthSignUpErrorField(res)]: res.error,
104 });
105 return;
106 }
107

Callers 2

AuthOptionsInnerFunction · 0.85
InnerFunnelRegistrationFunction · 0.85

Calls 6

useLogContextFunction · 0.90
useToastNotificationFunction · 0.90
getUserDefaultTimezoneFunction · 0.90
betterAuthSignUpFunction · 0.90
logEventFunction · 0.85

Tested by

no test coverage detected