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 55907a4 commit ebbc6d3
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
2 changes: 1 addition & 1 deletion apps/web/src/pages/collection/subscriptions.vue
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ alias: [/collection/abonnements]
</b-col>
</b-row>
<Subscription
v-if="currentSubscription && currentSubscription.id === null"
v-if="currentSubscription && !currentSubscription.id"
:subscription="currentSubscription"
is-edit
@start-edit="currentSubscription = newSubscription"
Expand Down
15 changes: 8 additions & 7 deletions packages/api/services/collection/subscriptions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,21 +66,22 @@ 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: {
publicationcode: subscription.publicationcode!,
users: {
connect: { id: userId },
},
startDate: subscription.startDate!,
endDate: subscription.endDate!,
...dates
},
where: {
id: id!,
id: id || 0,
},
});
}
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 ebbc6d3

Please sign in to comment.