Skip to main content
Glama
deleonio
by deleonio
appointmentService.ts1.11 kB
import { Option } from '@public-ui/components'; const getRandomIntInclusive = (min: number, max: number) => { min = Math.ceil(min); max = Math.floor(max); return Math.floor(Math.random() * (max - min + 1) + min); }; const padHours = (hours: number): string => `${hours < 10 ? '0' : ''}${hours}`; const getRandomTimes = () => { const earliest = 8; const latest = 17; const amount = getRandomIntInclusive(2, 9); const times = new Set<number>(); while (times.size !== amount) { times.add(getRandomIntInclusive(earliest, latest)); } return [...times].sort((timeA, timeB) => timeA - timeB).flatMap((hours) => [`${padHours(hours)}:00`, `${padHours(hours)}:30`]); }; const sleep = (timeout: number) => { return new Promise((resolve) => setTimeout(resolve, timeout)); }; export const fetchAvailableTimes = async (): Promise<Option<string>[]> => { await sleep(1000); return getRandomTimes().map((time) => ({ label: time, value: time, })); }; export const checkAppointmentAvailability = async (time?: string): Promise<boolean> => { await sleep(500); return time?.endsWith(':30') ?? false; };

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/deleonio/public-ui-kolibri'

If you have feedback or need assistance with the MCP directory API, please join our Discord server