Skip to content

Commit ed91186

Browse files
feat: new SignIn UI (#592)
## What does this PR do? This PR has the same changes from #589, that PRs history is not same with the history of our main branch. Upon trying to rebase this PR, I was getting 54 conflicts due to the folder rename. The old PR is based on main branch, so I cant force push either, thus this PR > From Old PR <img width="425" alt="Screenshot 2024-07-22 at 17 56 40" src="https://github.com/user-attachments/assets/31d9e67f-d74e-42ed-90a9-f30dbdeee984"> <img width="558" alt="Screenshot 2024-07-22 at 17 57 29" src="https://github.com/user-attachments/assets/4c90f884-3bba-46ab-98e4-d9ab5674d58d"> ## Type of change <!-- Please mark the relevant points by using [x] --> - [ ] Bug fix (non-breaking change which fixes an issue) - [ ] Chore (refactoring code, technical debt, workflow improvements) - [ ] Enhancement (small improvements) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] This change requires a documentation update ## Checklist <!-- We're starting to get more and more contributions. Please help us making this efficient for all of us and go through this checklist. Please tick off what you did --> ### Required - [ ] Read [Contributing Guide](https://github.com/un/inbox/blob/main/CONTRIBUTING.md) - [ ] Self-reviewed my own code - [ ] Tested my code in a local environment - [ ] Commented on my code in hard-to-understand areas - [ ] Checked for warnings, there are none - [ ] Removed all `console.logs` - [ ] Merged the latest changes from main onto my branch with `git pull origin main` - [ ] My changes don't cause any responsiveness issues ### Appreciated - [ ] If a UI change was made: Added a screen recording or screenshots to this PR - [ ] Updated the UnInbox Docs if changes were necessary
1 parent 1873252 commit ed91186

File tree

5 files changed

+240
-241
lines changed

5 files changed

+240
-241
lines changed
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
import { Button } from '@/src/components/shadcn-ui/button';
2+
import {
3+
InputOTP,
4+
InputOTPGroup,
5+
InputOTPSlot
6+
} from '@/src/components/shadcn-ui/input-otp';
7+
import {
8+
AlertDialog,
9+
AlertDialogContent,
10+
AlertDialogTitle,
11+
AlertDialogDescription
12+
} from '@/src/components/shadcn-ui/alert-dialog';
13+
import { useRouter } from 'next/navigation';
14+
import { useState } from 'react';
15+
import { platform } from '@/src/lib/trpc';
16+
17+
export function TwoFactorDialog({ open }: { open: boolean }) {
18+
const [code, setCode] = useState('');
19+
const router = useRouter();
20+
const { isSuccess, error, mutateAsync, isPending } =
21+
platform.auth.twoFactorAuthentication.verifyTwoFactorChallenge.useMutation();
22+
23+
return (
24+
<AlertDialog open={open}>
25+
<AlertDialogContent className="w-min p-8">
26+
<AlertDialogTitle>Two Factor Authentication</AlertDialogTitle>
27+
<AlertDialogDescription>
28+
Please enter the 6-digit code from your authenticator app
29+
</AlertDialogDescription>
30+
<div className="mx-auto w-fit">
31+
<InputOTP
32+
maxLength={6}
33+
value={code}
34+
onChange={(e) => setCode(e)}>
35+
<InputOTPGroup>
36+
<InputOTPSlot index={0} />
37+
<InputOTPSlot index={1} />
38+
<InputOTPSlot index={2} />
39+
<InputOTPSlot index={3} />
40+
<InputOTPSlot index={4} />
41+
<InputOTPSlot index={5} />
42+
</InputOTPGroup>
43+
</InputOTP>
44+
</div>
45+
{error && (
46+
<div className="text-destructive text-center text-sm">
47+
{error.message}
48+
</div>
49+
)}
50+
<Button
51+
className="mx-auto w-full"
52+
variant="secondary"
53+
disabled={code.length !== 6 || isPending || isSuccess}
54+
loading={isPending || isSuccess}
55+
onClick={async () => {
56+
try {
57+
const { defaultOrgSlug } = await mutateAsync({
58+
twoFactorCode: code
59+
});
60+
if (!defaultOrgSlug) {
61+
router.push('/join/org');
62+
} else {
63+
router.push(`/${defaultOrgSlug}`);
64+
}
65+
} catch {
66+
/* do nothing */
67+
}
68+
}}>
69+
{isSuccess ? 'Redirecting...' : isPending ? 'Verifying...' : 'Verify'}
70+
</Button>
71+
</AlertDialogContent>
72+
</AlertDialog>
73+
);
74+
}

apps/web/src/app/(login)/login/page.tsx

Lines changed: 0 additions & 212 deletions
This file was deleted.

0 commit comments

Comments
 (0)