Skip to content

Commit 6074d92

Browse files
committed
fix: handle target field being empty and translate to null
1 parent 12f4e45 commit 6074d92

3 files changed

Lines changed: 8 additions & 6 deletions

File tree

src/app/dashboard/cash-flow/envelopes/config.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ export const envelopeColumns = [
114114
</div>
115115

116116
<Progress
117+
key={progressValue.toNumber()}
117118
value={progressValue.toNumber()}
118119
className={cn(
119120
"max-w-[300px]",

src/server/api/routers/envelope.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,7 @@ export const envelopeRouter = createTRPCRouter({
7070
.mutation(async ({ input, ctx }) => {
7171
const updated = await ctx.db.envelope.update({
7272
where: { id: input.id, createdById: ctx.session.user.id },
73-
data: {
74-
...(input.target ? { target: input.target } : {}),
75-
name: input.name,
76-
amount: input.amount,
77-
},
73+
data: input,
7874
});
7975

8076
return updated;

src/trpc/schemas/envelope.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@ import * as yup from "yup";
22

33
export const createEnvelopeSchema = yup.object({
44
name: yup.string().label("Name").required(),
5-
target: yup.number().label("Target").optional(),
5+
target: yup
6+
.number()
7+
.label("Target")
8+
.optional()
9+
.nullable()
10+
.transform((value) => (isNaN(value) ? null : value)),
611
amount: yup.number().label("Amount").required(),
712
priority: yup.number().label("Priority").required(),
813
});

0 commit comments

Comments
 (0)