Skip to content
This repository was archived by the owner on Jan 23, 2025. It is now read-only.

Commit 1b41ef8

Browse files
Removed ring focus from toasts container and
simplified some error message handling on the account page
1 parent c57bf26 commit 1b41ef8

File tree

5 files changed

+15
-23
lines changed

5 files changed

+15
-23
lines changed

app/account/page.tsx

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
getSubscription,
66
createClient
77
} from '@/utils/supabase/server';
8+
import { getURL } from '@/utils/helpers';
89
import Button from '@/components/ui/Button';
910
import { cookies } from 'next/headers';
1011
import Link from 'next/link';
@@ -54,7 +55,7 @@ export default async function Account() {
5455
)}&error_description=${encodeURI('Your name could not be updated.')}`
5556
);
5657
}
57-
redirect(
58+
redirect(
5859
`/account?status=${encodeURI('Success!')}&status_description=${encodeURI(
5960
'Your name has been updated.'
6061
)}`
@@ -71,7 +72,7 @@ export default async function Account() {
7172
{ email: newEmail },
7273
{
7374
emailRedirectTo:
74-
process.env.NEXT_PUBLIC_SITE_URL +
75+
getURL() +
7576
`/account?status=${encodeURI(
7677
'Success!'
7778
)}&status_description=${encodeURI(
@@ -82,21 +83,10 @@ export default async function Account() {
8283

8384
if (error) {
8485
console.log(error);
85-
console.log(error.message);
86-
if (
87-
error.message ===
88-
'A user with this email address has already been registered'
89-
) {
90-
return redirect(
91-
`/account?error=${encodeURI('Oops!')}&error_description=${encodeURI(
92-
'It looks like that email is already in use. Please try another one.'
93-
)}`
94-
);
95-
}
96-
redirect(
97-
`/account?error=${encodeURI(
98-
'Hmm... Something went wrong.'
99-
)}&error_description=${encodeURI('Your email could not be updated.')}`
86+
return redirect(
87+
`/account?error=${encodeURI('Oops!')}&error_description=${encodeURI(
88+
error.message
89+
)}`
10090
);
10191
}
10292
redirect(

app/layout.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import SupabaseProvider from './supabase-provider';
22
import Footer from '@/components/ui/Footer';
33
import Navbar from '@/components/ui/Navbar';
4-
import { Toaster } from '@/components/ui/toaster';
4+
import { Toaster } from '@/components/ui/Toasts/toaster';
55
import { PropsWithChildren } from 'react';
66
import 'styles/main.css';
77

components/ui/Toasts/toast.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ const Toast = React.forwardRef<
4343
React.ComponentPropsWithoutRef<typeof ToastPrimitives.Root> &
4444
VariantProps<typeof toastVariants>
4545
>(({ className, variant, ...props }, ref) => {
46+
4647
return (
4748
<ToastPrimitives.Root
4849
ref={ref}

components/ui/Toasts/toaster.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,19 @@ export function Toaster() {
2020

2121
useEffect(() => {
2222
const status = searchParams.get('status');
23+
const status_description = searchParams.get('status_description');
2324
const error = searchParams.get('error');
24-
const message = searchParams.get('message');
25+
const error_description = searchParams.get('error_description');
2526
if (error || status) {
2627
toast({
2728
title: error
2829
? error ?? 'Hmm... Something went wrong.'
2930
: status ?? 'Alright!',
30-
description: message,
31+
description: error ? error_description : status_description,
3132
variant: error ? 'destructive' : undefined
3233
});
3334
// Clear the search params so that the toast doesn't show up again on refresh
34-
router.replace(pathname, { replace: true, scroll: false });
35+
router.replace(pathname, { scroll: false });
3536
}
3637
}, [searchParams]);
3738

styles/main.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
box-sizing: inherit;
99
}
1010

11-
*:focus {
11+
*:focus:not(ol) {
1212
@apply outline-none ring-2 ring-pink-500 ring-opacity-50;
1313
}
1414

@@ -49,4 +49,4 @@ a {
4949

5050
.height-screen-helper {
5151
height: calc(100vh - 80px);
52-
}
52+
}

0 commit comments

Comments
 (0)