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

Commit c57bf26

Browse files
'message' -> 'status' or 'error' in toast calls
1 parent 41f6875 commit c57bf26

File tree

1 file changed

+21
-8
lines changed

1 file changed

+21
-8
lines changed

app/account/page.tsx

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,11 @@ export default async function Account() {
5151
redirect(
5252
`/account?error=${encodeURI(
5353
'Hmm... Something went wrong.'
54-
)}&message=${encodeURI('Your name could not be updated.')}`
54+
)}&error_description=${encodeURI('Your name could not be updated.')}`
5555
);
5656
}
5757
redirect(
58-
`/account?status=${encodeURI('Success!')}&message=${encodeURI(
58+
`/account?status=${encodeURI('Success!')}&status_description=${encodeURI(
5959
'Your name has been updated.'
6060
)}`
6161
);
@@ -67,7 +67,18 @@ export default async function Account() {
6767
const newEmail = formData.get('email') as string;
6868
const cookieStore = cookies();
6969
const supabase = createClient(cookieStore);
70-
const { error } = await supabase.auth.updateUser({ email: newEmail });
70+
const { error } = await supabase.auth.updateUser(
71+
{ email: newEmail },
72+
{
73+
emailRedirectTo:
74+
process.env.NEXT_PUBLIC_SITE_URL +
75+
`/account?status=${encodeURI(
76+
'Success!'
77+
)}&status_description=${encodeURI(
78+
`Your email has been successfully updated to ${newEmail}`
79+
)}`
80+
}
81+
);
7182

7283
if (error) {
7384
console.log(error);
@@ -77,20 +88,22 @@ export default async function Account() {
7788
'A user with this email address has already been registered'
7889
) {
7990
return redirect(
80-
`/account?error=${encodeURI('Oops!')}&message=${encodeURI(
91+
`/account?error=${encodeURI('Oops!')}&error_description=${encodeURI(
8192
'It looks like that email is already in use. Please try another one.'
8293
)}`
8394
);
8495
}
8596
redirect(
8697
`/account?error=${encodeURI(
8798
'Hmm... Something went wrong.'
88-
)}&message=${encodeURI('Your email could not be updated.')}`
99+
)}&error_description=${encodeURI('Your email could not be updated.')}`
89100
);
90101
}
91102
redirect(
92-
`/account?status=${encodeURI('Email Sent')}&message=${encodeURI(
93-
'Check your email to confirm the update.'
103+
`/account?status=${encodeURI(
104+
'Confirmation Emails Sent'
105+
)}&status_description=${encodeURI(
106+
`You will need to confirm the update by clicking the link sent to both ${user?.email} and ${newEmail}.`
94107
)}`
95108
);
96109
};
@@ -189,7 +202,7 @@ interface Props {
189202
children: ReactNode;
190203
}
191204

192-
function Card({ title, description, footer, children }: Props) {
205+
export function Card({ title, description, footer, children }: Props) {
193206
return (
194207
<div className="w-full max-w-3xl m-auto my-8 border rounded-md p border-zinc-700">
195208
<div className="px-5 py-4">

0 commit comments

Comments
 (0)