forked from obytes/react-native-template-obytes
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #114 from rootstrap/feat/sign-up-screen
feat(sign-up): add sign up screen & form
- Loading branch information
Showing
10 changed files
with
321 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { createMutation } from 'react-query-kit'; | ||
|
||
import { client } from '../common'; | ||
|
||
type Variables = { | ||
email: string; | ||
name: string; | ||
password: string; | ||
passwordConfirmation: string; | ||
}; | ||
|
||
type Response = { | ||
status: string; | ||
data: { | ||
id: string; | ||
email: string; | ||
name: string; | ||
provider: string; | ||
uid: string; | ||
allowPasswordChange: boolean; | ||
createdAt: string; | ||
updatedAt: string; | ||
nickname?: string; | ||
image?: string; | ||
birthday?: string; | ||
}; | ||
}; | ||
|
||
const signUp = async (variables: Variables) => { | ||
const { data } = await client({ | ||
url: '/v1/users', | ||
method: 'POST', | ||
data: { | ||
user: variables, | ||
}, | ||
}); | ||
|
||
return data; | ||
}; | ||
|
||
export const useSignUp = createMutation<Response, Variables>({ | ||
mutationFn: (variables) => signUp(variables), | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { useRouter } from 'expo-router'; | ||
import React from 'react'; | ||
import { showMessage } from 'react-native-flash-message'; | ||
|
||
import { useSignUp } from '@/api/auth/use-sign-up'; | ||
import type { SignUpFormProps } from '@/components/sign-up-form'; | ||
import { SignUpForm } from '@/components/sign-up-form'; | ||
import { FocusAwareStatusBar } from '@/ui'; | ||
|
||
export default function SignIn() { | ||
const router = useRouter(); | ||
|
||
const { mutate: signUp, isPending } = useSignUp({ | ||
onSuccess: () => { | ||
router.push('/'); | ||
}, | ||
onError: (error) => showMessage({ message: error.message, type: 'danger' }), | ||
}); | ||
|
||
const onSubmit: SignUpFormProps['onSubmit'] = (data) => { | ||
signUp(data); | ||
}; | ||
|
||
return ( | ||
<> | ||
<FocusAwareStatusBar /> | ||
<SignUpForm onSubmit={onSubmit} isPending={isPending} /> | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.