[portal][feat] allow changing email on settings page

pull/528/head
Yangshun Tay 2 years ago
parent 5b2f06fadc
commit c1d926c6fa

@ -34,6 +34,7 @@ function SettingsForm({
);
const [name, setName] = useState(session?.user?.name);
const [email, setEmail] = useState(session?.user?.email);
return (
<div className="lg:py-18 bg-white py-12">
@ -50,6 +51,7 @@ function SettingsForm({
onSubmit={(event) => {
event.preventDefault();
updateProfileMutation.mutate({
email: email ? email : undefined,
name: name ? name : undefined,
});
}}>
@ -58,10 +60,20 @@ function SettingsForm({
<TextInput
description="This name will be used across the entire platform"
label="Name"
placeholder="John Doe"
value={name ?? undefined}
onChange={(val) => setName(val)}
/>
</div>
<div className="sm:col-span-3">
<TextInput
label="Email"
placeholder="john.doe@example.com"
type="email"
value={email ?? undefined}
onChange={(val) => setEmail(val)}
/>
</div>
{/* <div className="sm:col-span-6">
<label
className="block text-sm font-medium text-gray-700"

@ -6,12 +6,14 @@ export const userRouter = createProtectedRouter().mutation(
'settings.profile.update',
{
input: z.object({
email: z.string().optional(),
name: z.string().optional(),
}),
async resolve({ ctx, input }) {
const userId = ctx.session?.user?.id;
return await ctx.prisma.user.update({
data: {
email: input.email,
name: input.name,
},
where: {

Loading…
Cancel
Save