MED-103: add booking functionality
This commit is contained in:
@@ -1,14 +1,14 @@
|
||||
'use server'
|
||||
|
||||
import { RequestStatus } from '@/lib/types/audit';
|
||||
'use server';
|
||||
|
||||
import { RequestStatus, SyncStatus } from '@/lib/types/audit';
|
||||
import { ConnectedOnlineMethodName } from '@/lib/types/connected-online';
|
||||
import { ExternalApi } from '@/lib/types/external';
|
||||
import { MedipostAction } from '@/lib/types/medipost';
|
||||
import { getSupabaseServerAdminClient } from '@/packages/supabase/src/clients/server-admin-client';
|
||||
import { getSupabaseServerClient } from '@/packages/supabase/src/clients/server-client';
|
||||
|
||||
|
||||
export default async function logRequestResult(
|
||||
/* personalCode: string, */ requestApi: keyof typeof ExternalApi,
|
||||
requestApi: keyof typeof ExternalApi,
|
||||
requestApiMethod: `${ConnectedOnlineMethodName}` | `${MedipostAction}`,
|
||||
status: RequestStatus,
|
||||
comment?: string,
|
||||
@@ -16,11 +16,10 @@ export default async function logRequestResult(
|
||||
serviceId?: number,
|
||||
serviceProviderId?: number,
|
||||
) {
|
||||
const { error } = await getSupabaseServerClient()
|
||||
const { error } = await getSupabaseServerAdminClient()
|
||||
.schema('audit')
|
||||
.from('request_entries')
|
||||
.insert({
|
||||
/* personal_code: personalCode, */
|
||||
request_api: requestApi,
|
||||
request_api_method: requestApiMethod,
|
||||
requested_start_date: startTime,
|
||||
@@ -69,3 +68,29 @@ export async function getMedipostDispatchTries(medusaOrderId: string) {
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
export async function logSyncResult({
|
||||
operation,
|
||||
comment,
|
||||
status,
|
||||
changed_by_role,
|
||||
}: {
|
||||
operation: string;
|
||||
comment?: string;
|
||||
status: SyncStatus;
|
||||
changed_by_role: string;
|
||||
}) {
|
||||
const { error } = await getSupabaseServerAdminClient()
|
||||
.schema('audit')
|
||||
.from('sync_entries')
|
||||
.insert({
|
||||
operation,
|
||||
comment,
|
||||
status,
|
||||
changed_by_role,
|
||||
});
|
||||
|
||||
if (error) {
|
||||
throw new Error('Failed to insert log entry, error: ' + error.message);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user