Compare commits
3 Commits
6d2a7818db
...
75620baeac
Author | SHA1 | Date | |
---|---|---|---|
75620baeac | |||
ca975e589d | |||
b3067b86dc |
@ -1,7 +1,8 @@
|
|||||||
export async function get_api_appointments({ fetch, clinics = [], date = 'T' } = {}) {
|
export async function get_api_appointments({ fetch, clinics = [], date = 'T' } = {}) {
|
||||||
if(clinics.constructor === Array) clinics = clinics.map(x => x.replace(/^\s+|\s+$/g, '').replace(/\s+/, ' ')).filter(x => x).join('^').replace(/\//g, '|');
|
if(clinics.constructor === Array) clinics = clinics.map(x => x.replace(/^\s+|\s+$/g, '').replace(/\s+/, ' ')).filter(x => x).join('^').replace(/\//g, '|');
|
||||||
else clinics = clinics.replace(/^\s+|\s+$/g, '').replace(/\s+/, ' ').replace(/\//g, '|');
|
else clinics = clinics.replace(/^\s+|\s+$/g, '').replace(/\s+/, ' ').replace(/\//g, '|');
|
||||||
return await (await (fetch || window.fetch)('/api/appointments/' + clinics + '/' + date)).json();
|
if(clinics) return await (await (fetch || window.fetch)('/api/appointments/' + clinics + '/' + date)).json();
|
||||||
|
else return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function get_api_lookup({ fetch, query, ordinal, force = false } = {}) {
|
export async function get_api_lookup({ fetch, query, ordinal, force = false } = {}) {
|
||||||
|
@ -2,7 +2,12 @@ import { get_api_appointments } from '$lib/backend.js';
|
|||||||
|
|
||||||
/** @type {import('./$types').PageLoad} */
|
/** @type {import('./$types').PageLoad} */
|
||||||
export async function load({ params, fetch }) {
|
export async function load({ params, fetch }) {
|
||||||
let clinics = await (await fetch('/api/config/user/clinics')).json();
|
let clinics = [];
|
||||||
|
try {
|
||||||
|
clinics = await (await fetch('/api/config/user/clinics')).json();
|
||||||
|
} catch(ex) {
|
||||||
|
console.error(ex, ex.stack);
|
||||||
|
}
|
||||||
let appointments = await get_api_appointments({ fetch, clinics, date: 'T' });
|
let appointments = await get_api_appointments({ fetch, clinics, date: 'T' });
|
||||||
appointments.sort((a, b) => a.time_scheduled < b.time_scheduled ? -1 : a.time_scheduled > b.time_scheduled ? 1 : 0);
|
appointments.sort((a, b) => a.time_scheduled < b.time_scheduled ? -1 : a.time_scheduled > b.time_scheduled ? 1 : 0);
|
||||||
return {
|
return {
|
||||||
|
Loading…
Reference in New Issue
Block a user