fix some bug and produce many problem to solve later
This commit is contained in:
@@ -10,37 +10,7 @@ import { PrismaService } from '../Prisma/prisma.service'
|
||||
import { ScheduleStatus } from '@prisma/client'
|
||||
import { ScheduleService } from './schedule.service'
|
||||
import { AppConfigService } from '../AppConfig/appconfig.service'
|
||||
import { forEach } from 'lodash'
|
||||
|
||||
export type ScheduleConfigType =
|
||||
| {
|
||||
midDayBreakTimeStart?: string | null | undefined
|
||||
midDayBreakTimeEnd?: string | null | undefined
|
||||
slotDuration?: string | null | undefined
|
||||
slotBreakDuration?: string | null | undefined
|
||||
slotEndTime?: string | null | undefined
|
||||
slotStartTime?: string | null | undefined
|
||||
}
|
||||
| null
|
||||
| undefined
|
||||
|
||||
export type ScheduleConfigTypeForCenter = {
|
||||
startDate: string
|
||||
endDate: string
|
||||
slots: number[]
|
||||
days: number[]
|
||||
}
|
||||
|
||||
export type ScheduleSlotType = {
|
||||
slot: string
|
||||
start: string
|
||||
end: string
|
||||
}
|
||||
|
||||
export type PreviewScheduleType = {
|
||||
totalSlots: number
|
||||
slots: ScheduleSlotType[]
|
||||
}
|
||||
import { ScheduleConfigType } from './schedule'
|
||||
|
||||
@Injectable()
|
||||
export class ScheduleSchema extends PothosSchema {
|
||||
@@ -109,6 +79,7 @@ export class ScheduleSchema extends PothosSchema {
|
||||
slot: t.string({}),
|
||||
start: t.string({}),
|
||||
end: t.string({}),
|
||||
dayOfWeek: t.int({}),
|
||||
}),
|
||||
})
|
||||
}
|
||||
@@ -168,12 +139,24 @@ export class ScheduleSchema extends PothosSchema {
|
||||
return this.builder.inputType('ScheduleConfigInput', {
|
||||
description: 'A schedule config in the system.',
|
||||
fields: (t) => ({
|
||||
midDayBreakTimeStart: t.string(),
|
||||
midDayBreakTimeEnd: t.string(),
|
||||
slotDuration: t.string(),
|
||||
slotBreakDuration: t.string(),
|
||||
slotEndTime: t.string(),
|
||||
slotStartTime: t.string(),
|
||||
midDayBreakTimeStart: t.string({
|
||||
required: true,
|
||||
}),
|
||||
midDayBreakTimeEnd: t.string({
|
||||
required: true,
|
||||
}),
|
||||
slotDuration: t.string({
|
||||
required: true,
|
||||
}),
|
||||
slotBreakDuration: t.string({
|
||||
required: true,
|
||||
}),
|
||||
dayStartTime: t.string({
|
||||
required: true,
|
||||
}),
|
||||
dayEndTime: t.string({
|
||||
required: true,
|
||||
}),
|
||||
}),
|
||||
})
|
||||
}
|
||||
@@ -254,7 +237,17 @@ export class ScheduleSchema extends PothosSchema {
|
||||
}),
|
||||
},
|
||||
resolve: async (_parent, args, _context, _info) => {
|
||||
return await this.scheduleService.createSchedulePreview(
|
||||
// if no scheduleConfig, use default config
|
||||
if (!args.scheduleConfig) {
|
||||
args.scheduleConfig = (
|
||||
await this.appConfigService.getVisibleConfigs()
|
||||
).reduce((acc, curr) => {
|
||||
// @ts-ignore
|
||||
acc[curr.key] = curr.value
|
||||
return acc
|
||||
}, {} as ScheduleConfigType)
|
||||
}
|
||||
return await this.scheduleService.createSchedulePreviewForSingleDay(
|
||||
args.scheduleConfig,
|
||||
)
|
||||
},
|
||||
@@ -278,6 +271,7 @@ d72a864e-2f41-45ab-9c9b-bf0512a31883,e9be51fd-2382-4e43-9988-74e76fde4b56,2024-1
|
||||
'status',
|
||||
'customerId',
|
||||
'orderId',
|
||||
'dates',
|
||||
]),
|
||||
required: true,
|
||||
}),
|
||||
|
||||
Reference in New Issue
Block a user