More work on timeblocks
All checks were successful
Build BAB Application Deployment Artifact / build (push) Successful in 2m0s

This commit is contained in:
2024-04-29 21:14:02 -04:00
parent 43e68c8ae7
commit c297f1f287
6 changed files with 153 additions and 179 deletions

View File

@@ -1,40 +1,66 @@
import { DateOptions, date } from 'quasar';
import { Boat, useBoatStore } from '../boat';
import type { StatusTypes, Timeblock, Reservation } from '../schedule.types';
import { ID } from 'src/boot/appwrite';
import {
parseTimestamp,
today,
Timestamp,
addToDate,
} from '@quasar/quasar-ui-qcalendar';
export const weekdayBlocks = [
{
start: { time: '08:00', hour: 8, minute: 0 },
end: { time: '12:00', hour: 12, minute: 0 },
},
{
start: { time: '12:00', hour: 12, minute: 0 },
end: { time: '16:00', hour: 16, minute: 0 },
},
{
start: { time: '17:00', hour: 17, minute: 0 },
end: { time: '21:00', hour: 21, minute: 0 },
},
] as Timeblock[];
import type {
StatusTypes,
Reservation,
TimeBlockTemplate,
Timeblock,
} from '../schedule.types';
export const weekendBlocks = [
{
start: { time: '07:00', hour: 7, minute: 0 },
end: { time: '10:00', hour: 10, minute: 0 },
},
{
start: { time: '10:00', hour: 10, minute: 0 },
end: { time: '13:00', hour: 13, minute: 0 },
},
{
start: { time: '13:00', hour: 13, minute: 0 },
end: { time: '16:00', hour: 16, minute: 0 },
},
{
start: { time: '16:00', hour: 16, minute: 0 },
end: { time: '19:00', hour: 19, minute: 0 },
},
];
export const templateA: TimeBlockTemplate = {
id: '1',
name: 'WeekdayBlocks',
blocks: [
['08:00', '12:00'],
['12:00', '16:00'],
['17:00', '21:00'],
],
};
export const templateB: TimeBlockTemplate = {
id: '2',
name: 'WeekendBlocks',
blocks: [
['07:00', '10:00'],
['10:00', '13:00'],
['13:00', '16:00'],
['16:00', '19:00'],
],
};
export function getSampleTimeBlocks(): Timeblock[] {
// Hard-code 30 days worth of blocks, for now. Make them random templates
const boats = useBoatStore().boats;
const result: Timeblock[] = [];
const tsToday: Timestamp = parseTimestamp(today()) as Timestamp;
for (let i = 0; i <= 30; i++) {
const template = Math.random() < 0.5 ? templateA : templateB;
result.push(
...boats
.map((b): Timeblock[] => {
return template.blocks.map((t): Timeblock => {
return {
id: 'id' + Math.random().toString(32).slice(2),
boatId: b.$id,
start: addToDate(tsToday, { day: i }).date + ' ' + t[0],
end: addToDate(tsToday, { day: i }).date + ' ' + t[1],
};
});
})
.flat(2)
);
}
return result;
}
export function getSampleReservations(): Reservation[] {
const sampleData = [