refactor(sync) : remove restrictedMode and add sync service + confirmation modal
This commit is contained in:
@@ -211,3 +211,45 @@ export function convertCategory(id: string, opts: { signal?: AbortSignal } = {})
|
||||
signal: opts.signal,
|
||||
}));
|
||||
}
|
||||
|
||||
export interface SyncPreviewResult {
|
||||
modelTypeId: string;
|
||||
category: string;
|
||||
itemCount: number;
|
||||
additions: Record<string, number>;
|
||||
deletions: Record<string, number>;
|
||||
modifications: Record<string, number>;
|
||||
}
|
||||
|
||||
export interface SyncExecuteResult {
|
||||
itemsUpdated: number;
|
||||
additions: Record<string, number>;
|
||||
deletions: Record<string, number>;
|
||||
modifications: Record<string, number>;
|
||||
}
|
||||
|
||||
export function syncPreview(id: string, structure: unknown, opts: { signal?: AbortSignal } = {}) {
|
||||
const requestFetch = useRequestFetch();
|
||||
return requestFetch<SyncPreviewResult>(`${ENDPOINT}/${id}/sync-preview`, createOptions({
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Accept': 'application/json',
|
||||
},
|
||||
body: { structure },
|
||||
signal: opts.signal,
|
||||
}));
|
||||
}
|
||||
|
||||
export function syncExecute(id: string, confirmation: { confirmDeletions: boolean; confirmTypeChanges: boolean }, opts: { signal?: AbortSignal } = {}) {
|
||||
const requestFetch = useRequestFetch();
|
||||
return requestFetch<SyncExecuteResult>(`${ENDPOINT}/${id}/sync`, createOptions({
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Accept': 'application/json',
|
||||
},
|
||||
body: confirmation,
|
||||
signal: opts.signal,
|
||||
}));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user