Skip to content

Commit

Permalink
web: Fix subscription creation
Browse files Browse the repository at this point in the history
  • Loading branch information
bperel committed Dec 31, 2024
1 parent f3c9eaf commit 77e7d92
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
16 changes: 9 additions & 7 deletions packages/api/routes/collection/subscriptions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,24 @@ export async function upsertSubscription(
) {
return null;
}

const dates = {
startDate: new Date(subscription.startDate),
endDate: new Date(subscription.endDate),
};

await prismaDm.subscription.upsert({
update: {
startDate: subscription.startDate!,
endDate: subscription.endDate!,
},
update: dates,
create: {
country: publicationCodeParts[0],
magazine: publicationCodeParts[1],
users: {
connect: { id: userId },
},
startDate: subscription.startDate!,
endDate: subscription.endDate!,
...dates
},
where: {
id,
id: id || 0,
},
});
}
Expand Down
6 changes: 3 additions & 3 deletions packages/types/EditSubscription.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export type EditSubscription = {
id: number | null;
publicationcode: string | null;
startDate: string | null;
endDate: string | null;
publicationcode: string;
startDate: string;
endDate: string;
};

0 comments on commit 77e7d92

Please sign in to comment.