refactor utils
This commit is contained in:
@@ -16,6 +16,7 @@ import {
|
||||
} from './schedule.types';
|
||||
import { AppwriteIds, databases } from 'src/boot/appwrite';
|
||||
import { ID, Models } from 'appwrite';
|
||||
import { buildISODate } from 'src/utils/misc';
|
||||
|
||||
export function arrayToTimeTuples(arr: string[]) {
|
||||
const timeTuples: TimeTuple[] = [];
|
||||
@@ -65,10 +66,6 @@ export function copyIntervalTemplate(
|
||||
};
|
||||
}
|
||||
|
||||
export function buildISODate(date: string, time: string | null): string {
|
||||
return new Date(date + 'T' + time || '00:00').toISOString();
|
||||
}
|
||||
|
||||
export function buildInterval(
|
||||
resource: Boat,
|
||||
time: TimeTuple,
|
||||
@@ -212,14 +209,6 @@ export const useScheduleStore = defineStore('schedule', () => {
|
||||
);
|
||||
};
|
||||
|
||||
const getNewId = (): string => {
|
||||
return [...Array(20)]
|
||||
.map(() => Math.floor(Math.random() * 16).toString(16))
|
||||
.join('');
|
||||
// Trivial placeholder
|
||||
//return Math.max(...reservations.value.map((item) => item.id)) + 1;
|
||||
};
|
||||
|
||||
const addOrCreateReservation = (reservation: Reservation) => {
|
||||
const index = reservations.value.findIndex(
|
||||
(res) => res.id == reservation.id
|
||||
@@ -339,7 +328,6 @@ export const useScheduleStore = defineStore('schedule', () => {
|
||||
getIntervals,
|
||||
fetchIntervals,
|
||||
fetchIntervalTemplates,
|
||||
getNewId,
|
||||
createInterval,
|
||||
updateInterval,
|
||||
deleteInterval,
|
||||
|
||||
Reference in New Issue
Block a user