MED-103: add booking functionality
This commit is contained in:
@@ -152,3 +152,29 @@ export async function getAnalysisOrdersAdmin({
|
||||
const orders = await query.order('created_at', { ascending: false }).throwOnError();
|
||||
return orders.data;
|
||||
}
|
||||
|
||||
export async function getTtoOrders({
|
||||
orderStatus,
|
||||
}: {
|
||||
orderStatus?: Tables<{ schema: 'medreport' }, 'connected_online_reservation'>['status'];
|
||||
} = {}) {
|
||||
const client = getSupabaseServerClient();
|
||||
|
||||
const {
|
||||
data: { user },
|
||||
} = await client.auth.getUser();
|
||||
if (!user) {
|
||||
throw new Error('Unauthorized');
|
||||
}
|
||||
|
||||
const query = client
|
||||
.schema('medreport')
|
||||
.from('connected_online_reservation')
|
||||
.select('*')
|
||||
.eq("user_id", user.id)
|
||||
if (orderStatus) {
|
||||
query.eq('status', orderStatus);
|
||||
}
|
||||
const orders = await query.order('created_at', { ascending: false }).throwOnError();
|
||||
return orders.data;
|
||||
}
|
||||
Reference in New Issue
Block a user