feat: must not delete if status is not CREATED
This commit is contained in:
parent
c3f8673ac8
commit
23f05503c5
1 changed files with 13 additions and 1 deletions
|
|
@ -371,6 +371,17 @@ export class CustomerController extends Controller {
|
|||
},
|
||||
});
|
||||
|
||||
if (
|
||||
customerBranch &&
|
||||
relation.find((a) => !customerBranch.find((b) => a.id === b.id) && a.status !== "CREATED")
|
||||
) {
|
||||
throw new HttpError(
|
||||
HttpStatus.BAD_REQUEST,
|
||||
"One or more branch cannot be delete and is missing.",
|
||||
"missing_or_invalid_parameter",
|
||||
);
|
||||
}
|
||||
|
||||
const record = await prisma.customer
|
||||
.update({
|
||||
include: {
|
||||
|
|
@ -391,6 +402,7 @@ export class CustomerController extends Controller {
|
|||
id: {
|
||||
notIn: customerBranch.map((v) => v.id).filter((v): v is string => !!v) || [],
|
||||
},
|
||||
status: Status.CREATED,
|
||||
},
|
||||
upsert: customerBranch.map((v, i) => ({
|
||||
where: { id: v.id || "" },
|
||||
|
|
@ -415,7 +427,7 @@ export class CustomerController extends Controller {
|
|||
.then((v) => {
|
||||
if (customerBranch) {
|
||||
relation
|
||||
.filter((a) => !customerBranch?.find((b) => b.id === a.id))
|
||||
.filter((a) => !customerBranch.find((b) => b.id === a.id))
|
||||
.forEach((deleted) => {
|
||||
new Promise<string[]>((resolve, reject) => {
|
||||
const item: string[] = [];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue