Skip to content

Commit

Permalink
Merge pull request #172 from UoaWDCC/GH133-edit-checker-page-endpoint
Browse files Browse the repository at this point in the history
Gh133 edit checker page endpoint
  • Loading branch information
alexwillmcleod authored Jan 12, 2024
2 parents da9f170 + 06b1834 commit 7b4b7f3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
2 changes: 1 addition & 1 deletion api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ app.use('/api/auth/google', authRoutes);
app.use('/api/sheet/columns', sheetroutes);
app.use('/api/club', organisationRoutes);
app.use('/api/pages', pagesRoutes);
app.use('api/verify', verifyRoutes);
app.use('/api/verify', verifyRoutes);
app.use('/api/dashboard', dashboardRoutes);
app.use('/api/user', userRoutes);

Expand Down
21 changes: 16 additions & 5 deletions api/routes/pages/pages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,13 +178,19 @@ router.post(
auth,
async (req: Request, res: Response) => {
try {
const customization: IPageCustomization & { webLink: string } = req.body;
const customization: IPageCustomization & {
webLink: string;
removeLogo: boolean;
removeBackground: boolean;
} = req.body;

const {
name,
sheetId,
sheetTabId,
identificationColumns,
removeBackground,
removeLogo,
fontFamily,
webLink,
...rest
Expand Down Expand Up @@ -279,8 +285,10 @@ router.post(
dropDownBackgroundColor:
rest.dropDownBackgroundColor ??
existingPage.dropDownBackgroundColor,
logoLink: logoUrl ?? existingPage.logoLink,
backgroundImageLink: backgroundUrl ?? existingPage.backgroundColor,
logoLink: removeLogo ? undefined : logoUrl ?? existingPage.logoLink,
backgroundImageLink: removeBackground
? undefined
: backgroundUrl ?? existingPage.backgroundColor,
fontFamily: fontFamily ?? existingPage.fontFamily ?? 'Montserrat',
},
});
Expand All @@ -290,9 +298,12 @@ router.post(
displayName?: string;
}[] = JSON.parse(identificationColumns || '[]');
parsedColumns!.forEach(async ({ originalName, displayName }) => {
await prisma.column.create({
data: {
await prisma.column.updateMany({
where: {
originalName,
pageId: page.id,
},
data: {
originalName: originalName,
displayName: displayName ?? originalName,
},
Expand Down

0 comments on commit 7b4b7f3

Please sign in to comment.