-
Notifications
You must be signed in to change notification settings - Fork 0
fix: auth pages #245
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
fix: auth pages #245
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,21 @@ | ||
| name: Vercel Preview Deployment | ||
| env: | ||
| VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} | ||
| VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} | ||
| on: | ||
| push: | ||
| branches-ignore: | ||
| - main | ||
| jobs: | ||
| Deploy-Preview: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v2 | ||
| - name: Install Vercel CLI | ||
| run: npm install --global vercel@latest | ||
| - name: Pull Vercel Environment Information | ||
| run: vercel pull --yes --environment=preview --token=${{ secrets.VERCEL_TOKEN }} | ||
| - name: Build Project Artifacts | ||
| run: vercel build --token=${{ secrets.VERCEL_TOKEN }} | ||
| - name: Deploy Project Artifacts to Vercel | ||
| run: vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }} | ||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 was deleted.
Oops, something went wrong.
This file contains hidden or 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 |
|---|---|---|
| @@ -1,37 +1,35 @@ | ||
| // import components | ||
| "use client"; | ||
| import { PostForgetPasswordRequest } from "@repo/apis/core/forgot-password/post/post-forget-password.types"; | ||
| import { UsePostForgetPassword } from "@repo/apis/core/forgot-password/post/use-post-forget-password"; | ||
| import { Button } from "@repo/ui/components/button"; | ||
| import { | ||
| InputOTP, | ||
| InputOTPGroup, | ||
| InputOTPSlot, | ||
| } from "@repo/ui/components/input-otp"; | ||
| import { REGEXP_ONLY_DIGITS_AND_CHARS } from "input-otp"; | ||
| import { useRouter } from "next/navigation"; | ||
| import { useRouter, useSearchParams } from "next/navigation"; | ||
| import { useForm } from "react-hook-form"; | ||
| import { toast } from "sonner"; | ||
|
|
||
| // import icons | ||
| import { zodResolver } from "@hookform/resolvers/zod"; | ||
| import { postForgetPasswordSchema } from "@repo/apis/core/forgot-password/post/post-forget-password.schema"; | ||
| import { Input } from "@repo/ui/components/input"; | ||
| import { Suspense, useEffect } from "react"; | ||
| import AuthCard from "../_components/auth-card"; | ||
|
|
||
| import { postResetPasswordSchema } from "@repo/apis/core/accounts/users/reset-password/post/post-reset-password.schema"; | ||
| import { usePostResetPassword } from "@repo/apis/core/accounts/users/reset-password/post/use-post-reset-password"; | ||
| import type { PostResetPasswordRequest } from "@repo/apis/core/accounts/users/reset-password/post/post-reset-password.types"; | ||
|
|
||
| const Setpasswordpage = () => { | ||
| const router = useRouter(); | ||
| // TODO: Fix this | ||
| // const params = useSearchParams(); | ||
| // const username = params.get("username"); | ||
|
|
||
| const username = "[email protected]"; | ||
| const params = useSearchParams(); | ||
| const username = params.get("username"); | ||
|
|
||
| if (!username) router.replace("/auth/forget-password"); | ||
|
|
||
| const form = useForm<PostForgetPasswordRequest>({ | ||
| resolver: zodResolver(postForgetPasswordSchema.request), | ||
| const form = useForm<PostResetPasswordRequest>({ | ||
| resolver: zodResolver(postResetPasswordSchema.request), | ||
| }); | ||
|
|
||
| const { | ||
|
|
@@ -41,22 +39,23 @@ const Setpasswordpage = () => { | |
| formState: { errors }, | ||
| } = form; | ||
|
|
||
| // biome-ignore lint/correctness/useExhaustiveDependencies: <explanation> | ||
| useEffect(() => { | ||
| setValue("username", username as string); | ||
| }, []); | ||
| }, [username]); | ||
|
Comment on lines
+42
to
+45
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Add missing dependencies to useEffect. The useEffect(() => {
setValue("username", username as string);
- }, [username]);
+ }, [username, setValue]); |
||
|
|
||
| const mutation = UsePostForgetPassword({ | ||
| const mutation = usePostResetPassword({ | ||
| onSuccess: (res) => { | ||
| toast.info(res.data.message); | ||
| router.push(`/auth/login`); | ||
| router.push("/auth/login"); | ||
| }, | ||
|
|
||
| onError: (err) => { | ||
| toast.error(err.response?.data.message || "Something went wrong"); | ||
| toast.error(err.response?.data.message ?? "Something went wrong"); | ||
| }, | ||
| }); | ||
|
|
||
| const handleSubmitForm = (data: PostForgetPasswordRequest) => { | ||
| const handleSubmitForm = (data: PostResetPasswordRequest) => { | ||
| mutation.mutate(data); | ||
| }; | ||
|
|
||
|
|
@@ -70,16 +69,14 @@ const Setpasswordpage = () => { | |
| <p className="text-2xl font-bold">Set your Password</p> | ||
| <p className="text-center text-sm font-normal"> | ||
| We've sent the code to{" "} | ||
| <span className="underline text-sm font-normal"> | ||
| [email protected] | ||
| </span> | ||
| <span className="underline text-sm font-normal">{username}</span> | ||
| </p> | ||
| <p className="text-sm font-normal">check your email</p> | ||
| </div> | ||
| </div> | ||
| {/* otp input */} | ||
| <form | ||
| className="w-full flex flex-col items-center " | ||
| className="w-full flex flex-col items-center gap-4" | ||
| onSubmit={handleSubmit(handleSubmitForm)} | ||
| > | ||
| <div className="pb-4"> | ||
|
|
@@ -104,33 +101,31 @@ const Setpasswordpage = () => { | |
| </div> | ||
|
|
||
| {/* input */} | ||
| <div className="w-full flex flex-col gap-5"> | ||
| <Input | ||
| label="Password" | ||
| type="password" | ||
| className="font-normal text-xs text-gray-500" | ||
| placeholder="********" | ||
| {...register("newPassword")} | ||
| error={errors.newPassword?.message} | ||
| /> | ||
| <Input | ||
| label="Confirm Password" | ||
| type="password" | ||
| className="font-normal text-xs text-gray-500" | ||
| placeholder="********" | ||
| {...register("confirmPassword")} | ||
| error={errors.confirmPassword?.message} | ||
| /> | ||
| {/* button reset */} | ||
| <div className="pb-7 w-full"> | ||
| <Button | ||
| isLoading={mutation.isPending} | ||
| className="w-full text-sm font-bold bg-primary text-foreground" | ||
| variant="primary" | ||
| > | ||
| Reset | ||
| </Button> | ||
| </div> | ||
| <Input | ||
| label="Password" | ||
| type="password" | ||
| className="font-normal text-xs text-muted-foreground" | ||
| placeholder="********" | ||
| {...register("new_password")} | ||
| error={errors.new_password?.message} | ||
| /> | ||
| <Input | ||
| label="Confirm Password" | ||
| type="password" | ||
| className="font-normal text-xs text-muted-foreground" | ||
| placeholder="********" | ||
| {...register("confirm_password")} | ||
| error={errors.confirm_password?.message} | ||
| /> | ||
| {/* button reset */} | ||
| <div className="pb-7 w-full"> | ||
| <Button | ||
| isLoading={mutation.isPending} | ||
| className="w-full text-lg font-bold" | ||
| variant="primary" | ||
| > | ||
| Reset | ||
| </Button> | ||
| </div> | ||
| </form> | ||
| </AuthCard> | ||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update actions/checkout to latest version.
The current version (v2) is outdated. Update to the latest version for better compatibility and security.
📝 Committable suggestion
🧰 Tools
🪛 actionlint (1.7.4)
13-13: the runner of "actions/checkout@v2" action is too old to run on GitHub Actions. update the action's version to fix this issue
(action)