refactor utils

This commit is contained in:
2024-05-13 12:31:27 -04:00
parent 78211a33ae
commit b0921ccf32
4 changed files with 15 additions and 17 deletions

View File

@@ -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,