Skip to content
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

creating api editMerchantProfile that change email, storeName, phone, and address #58

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/pages/app/history/details/[ticketId].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const TicketDetailsPage: AuthNextPage = () => {
<link rel="icon" href="/favicon.ico" />
</Head>
<AppLayout>
<div className="flex h-full w-full flex-col flex-col items-center justify-between bg-ultramarine p-16">
<div className="flex h-full w-full flex-col items-center justify-between bg-ultramarine p-16">
<div className="flex flex-col items-center p-5">
<img
className="h-8 w-auto rounded"
Expand Down
28 changes: 28 additions & 0 deletions src/server/api/routers/merchant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,32 @@ export const merchantRouter = createTRPCRouter({
}
return merchant;
}),
editMerchantProfile: protectedProcedure
.input(
z.object({
merchantId: z.string(),
email: z.string(),
storeName: z.string(),
phone: z.string(),
address: z.string(),
})
)
.mutation(async ({ input: { merchantId, email, storeName, phone, address }, ctx }) => {
const merchant = await ctx.prisma.merchant.findUnique({
where: {
id: merchantId,
},
});
await ctx.prisma.merchant.update({
where: {
id: merchantId,
},
data: {
email: email,
name: storeName,
phone: phone,
address: address,
},
});
}),
});
28 changes: 28 additions & 0 deletions src/server/api/routers/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,32 @@ export const userRouter = createTRPCRouter({
}
return user;
}),
editUserProfile: protectedProcedure
.input(
z.object({
userId: z.string(),
})
)
.mutation(async ({ input: { userId }, ctx }) => {
const user = await ctx.prisma.user.findUnique({
where: {
id: userId,
},
});
const email = user?.email;
const name = user?.name;
const phone = user?.phone;
const address = user?.address;
await ctx.prisma.user.update({
where: {
id: userId,
},
data: {
email: email,
name: name,
phone: phone,
address: address,
},
});
}),
Comment on lines +45 to +72
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
editUserProfile: protectedProcedure
.input(
z.object({
userId: z.string(),
})
)
.mutation(async ({ input: { userId }, ctx }) => {
const user = await ctx.prisma.user.findUnique({
where: {
id: userId,
},
});
const email = user?.email;
const name = user?.name;
const phone = user?.phone;
const address = user?.address;
await ctx.prisma.user.update({
where: {
id: userId,
},
data: {
email: email,
name: name,
phone: phone,
address: address,
},
});
}),

already PRed in other branch, don't push

});