Skip to content

Commit 3f787a5

Browse files
committed
feat(shelter-supply): set quantity to null if priority is UnderControl
1 parent b2550ee commit 3f787a5

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/shelter-supply/shelter-supply.service.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { Injectable } from '@nestjs/common';
33

44
import { PrismaService } from '../prisma/prisma.service';
55
import { CreateShelterSupplySchema, UpdateShelterSupplySchema } from './types';
6+
import { SupplyPriority } from '../supply/types';
67

78
@Injectable()
89
export class ShelterSupplyService {
@@ -35,15 +36,15 @@ export class ShelterSupplyService {
3536
shelterId,
3637
priority,
3738
supplyId,
38-
quantity,
39+
quantity: priority !== SupplyPriority.UnderControl ? quantity : null,
3940
createdAt: new Date().toISOString(),
4041
},
4142
});
4243
}
4344

4445
async update(body: z.infer<typeof UpdateShelterSupplySchema>) {
4546
const { data, where } = UpdateShelterSupplySchema.parse(body);
46-
const { priority } = data;
47+
const { priority, quantity } = data;
4748
if (priority !== null && priority !== undefined) {
4849
const shelterSupply = await this.prismaService.shelterSupply.findFirst({
4950
where: {
@@ -68,6 +69,7 @@ export class ShelterSupplyService {
6869
},
6970
data: {
7071
...data,
72+
quantity: priority !== SupplyPriority.UnderControl ? quantity : null,
7173
createdAt: new Date().toISOString(),
7274
},
7375
});

0 commit comments

Comments
 (0)