Skip to content

Commit

Permalink
final push
Browse files Browse the repository at this point in the history
  • Loading branch information
Hammad-Izhar committed Aug 4, 2023
1 parent e69971b commit 081ca15
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
6 changes: 2 additions & 4 deletions src/pages/pieces/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const Pieces: NextPage = () => {
setErrorSnackbarMessage(error.message);
setErrorMessage(error.message);
},
onSuccess(data) {
onSuccess() {
setOpenSuccessSnackbar(true);
setSuccessSnackbarMessage("Layout successfully saved!");
setIsEditing(false);
Expand Down Expand Up @@ -102,9 +102,7 @@ const Pieces: NextPage = () => {
if (errorLayout) {
return <p>Oh no... {errorLayout.message}</p>;
}
const piecesLayout = layout?.layout
? (layout.layout as unknown as Layouts)
: null;
const piecesLayout = layout?.layout as unknown as Layouts;
return (
<>
<TopNav />
Expand Down
20 changes: 17 additions & 3 deletions src/server/api/routers/layout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,29 @@ import {
} from "@CarteBlanche/server/api/trpc";
import { z } from "zod";

const breakpointLayoutSchema = z.array(
z.object({
w: z.number(),
h: z.number(),
x: z.number(),
y: z.number(),
i: z.string(),
moved: z.boolean(),
static: z.boolean(),
})
);

export const layoutRouter = createTRPCRouter({
/** UPSERT GRID LAYOUT */
upsertLayout: publicProcedure
.input(
z.object({
name: z.string(),
layout: z.any(),
layout: z.object({
lg: z.optional(breakpointLayoutSchema),
md: z.optional(breakpointLayoutSchema),
sm: z.optional(breakpointLayoutSchema),
}),
})
)
.mutation(({ input, ctx }) => {
Expand All @@ -19,12 +35,10 @@ export const layoutRouter = createTRPCRouter({
name: input.name,
},
update: {
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
layout: input.layout,
},
create: {
name: input.name,
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
layout: input.layout,
},
});
Expand Down

0 comments on commit 081ca15

Please sign in to comment.