Merge branch 'develop' into MED-97
This commit is contained in:
@@ -4,7 +4,7 @@ import type { Tables } from '@kit/supabase/database';
|
||||
import { getSupabaseServerAdminClient } from '@kit/supabase/server-admin-client';
|
||||
import { getSupabaseServerClient } from '@kit/supabase/server-client';
|
||||
|
||||
import type { AnalysisOrder } from '../types/analysis-order';
|
||||
import type { AnalysisOrder, TTOOrder } from '../types/order';
|
||||
|
||||
export async function createAnalysisOrder({
|
||||
medusaOrder,
|
||||
@@ -129,3 +129,39 @@ export async function getAnalysisOrdersAdmin({
|
||||
.throwOnError();
|
||||
return orders.data;
|
||||
}
|
||||
|
||||
export async function getTtoOrders({
|
||||
orderStatus,
|
||||
lineItemIds,
|
||||
}: {
|
||||
orderStatus?: TTOOrder['status'];
|
||||
lineItemIds?: string[];
|
||||
} = {}) {
|
||||
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);
|
||||
}
|
||||
|
||||
if (lineItemIds?.length) {
|
||||
query.in('medusa_cart_line_item_id', lineItemIds);
|
||||
}
|
||||
|
||||
const orders = await query
|
||||
.order('created_at', { ascending: false })
|
||||
.throwOnError();
|
||||
return orders.data;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user