Skip to content

Commit e3e543a

Browse files
committed
unbookServises
1 parent 8c76a30 commit e3e543a

File tree

6 files changed

+14
-8
lines changed

6 files changed

+14
-8
lines changed

packages/integrations/gei-bookings/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "gei-bookings",
3-
"version": "0.2.5",
3+
"version": "0.2.6",
44
"description": "Automatically generated by graphql-editor-cli",
55
"main": "lib/index.js",
66
"scripts": {

packages/integrations/gei-bookings/src/PublicQuery/listServices.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export const listServices = async (input: FieldResolveInput) =>
99
resolverFor('PublicQuery', 'listServices', async (args) =>
1010
errMiddleware(async () => {
1111
const po = preparePageOptions(args?.input?.page);
12-
const inputFilters = inputServiceFiltersSet(args.input?.filters)
12+
const inputFilters = inputServiceFiltersSet(args?.input?.filters)
1313
return {
1414
services: convertDateObjToStringForArray(await MongoOrb(ServicesCollection)
1515
.collection.find({

packages/integrations/gei-bookings/src/UserMutation/respondOnServiceRequest.ts

+9-3
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,29 @@ export const respondOnServiceRequest = async (input: FieldResolveInput) =>
77
resolverFor('UserMutation', 'respondOnServiceRequest', async (args, src) =>
88
errMiddleware(async () => {
99
sourceContainUserIdOrThrow(src);
10-
if (args.input?.answer === BookStatus.PENDING) {
10+
if (args?.input?.answer === BookStatus.PENDING) {
1111
throw new GlobalError('answer cannot be pending', import.meta.url);
1212
}
13-
MongoOrb('Bookings')
13+
await MongoOrb('Bookings')
1414
.collection.find({ _id: { $in: args.input.bookIds }, answeredAt: { $exists: false } }).toArray()
1515
.then(async (books) => {
1616
if (!books || books.length < 1) {
1717
throw new GlobalError(`cannot find anyone books for id: ${ args.input.bookIds }`, import.meta.url);
1818
}
19-
MongoOrb('Services')
19+
await MongoOrb('Services')
2020
.collection.find({ _id: { $in: books.map((b)=> b.services ).flatMap(innerArray => innerArray) }, ownerId: src.userId || src._id})
2121
.toArray().then((r) => {
2222
if (!r || r.length < 1) {
2323
throw new GlobalError('you can answer only on yours services', import.meta.url);
2424
}
2525
});
26+
if (args?.input?.answer === BookStatus.DECLINED) {
27+
MongoOrb('Services')
28+
.collection.updateMany({ _id: { $in: books.map((b)=> b.services ).flatMap(innerArray => innerArray) }, ownerId: src.userId || src._id}, {$set: { taken: false} })
29+
};
2630
});
31+
32+
2733
return MongoOrb('Bookings')
2834
.collection.updateMany(
2935
{ _id: { $in: args.input.bookIds} },

packages/integrations/gei-bookings/src/UserQuery/getBookingsForService.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export const getBookingsForService = async (input: FieldResolveInput) =>
99
errMiddleware(async () => {
1010
sourceContainUserIdOrThrow(src);
1111
const po = preparePageOptions(args?.input?.page);
12-
const inputFilters = inputBooksFiltersSet(args.input?.filters)
12+
const inputFilters = inputBooksFiltersSet(args?.input?.filters)
1313

1414

1515
const ownedServices = await MongoOrb('Services')

packages/integrations/gei-bookings/src/UserQuery/getSelfBooks.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export const getSelfBooks = async (input: FieldResolveInput) =>
88
errMiddleware(async () => {
99
sourceContainUserIdOrThrow(src);
1010
const po = preparePageOptions(args?.input?.page);
11-
const inputFilters = inputBooksFiltersSet(args.input?.filters)
11+
const inputFilters = inputBooksFiltersSet(args?.input?.filters)
1212

1313
return {
1414
books: convertDateObjToStringForArray(await MongoOrb('Bookings')

packages/integrations/gei-bookings/src/UserQuery/getSelfServices.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export const getSelfServices = async (input: FieldResolveInput) =>
1313
sourceContainUserIdOrThrow(src);
1414
const po = preparePageOptions(args?.input?.page);
1515

16-
const inputFilters = inputServiceFiltersSet(args.input?.filters)
16+
const inputFilters = inputServiceFiltersSet(args?.input?.filters)
1717

1818
const selfServices = await MongoOrb(ServicesCollection)
1919
.collection.find({

0 commit comments

Comments
 (0)