mirror of
https://github.com/sakaljurgis/best-choice.git
synced 2026-07-08 21:47:40 +00:00
progress
This commit is contained in:
@@ -88,6 +88,7 @@ export interface ImportedItemData {
|
||||
model: string | null;
|
||||
note: string | null;
|
||||
attributes: Record<string, unknown>;
|
||||
sourceUrl?: string | null;
|
||||
}
|
||||
|
||||
export const createItem = async (
|
||||
@@ -131,3 +132,55 @@ export const importItemFromUrl = async (
|
||||
|
||||
return response.data;
|
||||
};
|
||||
|
||||
export interface UpdateItemPayload {
|
||||
manufacturer?: string | null;
|
||||
model?: string;
|
||||
status?: ItemStatus;
|
||||
note?: string | null;
|
||||
attributes?: Record<string, unknown>;
|
||||
sourceUrl?: string | null;
|
||||
sourceUrlId?: string | null;
|
||||
}
|
||||
|
||||
export const updateItem = async (
|
||||
itemId: string,
|
||||
payload: UpdateItemPayload
|
||||
): Promise<Item> => {
|
||||
const body: Record<string, unknown> = {};
|
||||
|
||||
if ('manufacturer' in payload) {
|
||||
body.manufacturer = payload.manufacturer ?? null;
|
||||
}
|
||||
|
||||
if ('model' in payload) {
|
||||
body.model = payload.model;
|
||||
}
|
||||
|
||||
if ('status' in payload) {
|
||||
body.status = payload.status;
|
||||
}
|
||||
|
||||
if ('note' in payload) {
|
||||
body.note = payload.note ?? null;
|
||||
}
|
||||
|
||||
if ('attributes' in payload) {
|
||||
body.attributes = payload.attributes ?? {};
|
||||
}
|
||||
|
||||
if ('sourceUrl' in payload) {
|
||||
body.sourceUrl = payload.sourceUrl ?? null;
|
||||
}
|
||||
|
||||
if ('sourceUrlId' in payload) {
|
||||
body.sourceUrlId = payload.sourceUrlId ?? null;
|
||||
}
|
||||
|
||||
const response = await apiFetch<SingleItemResponse>(`/items/${itemId}`, {
|
||||
method: 'PATCH',
|
||||
body
|
||||
});
|
||||
|
||||
return response.data;
|
||||
};
|
||||
|
||||
@@ -111,9 +111,31 @@ export const updateProject = async (
|
||||
projectId: string,
|
||||
payload: UpdateProjectPayload
|
||||
): Promise<Project> => {
|
||||
const body: Record<string, unknown> = {};
|
||||
|
||||
if (payload.name !== undefined) {
|
||||
body.name = payload.name;
|
||||
}
|
||||
|
||||
if (payload.description !== undefined) {
|
||||
body.description = payload.description ?? null;
|
||||
}
|
||||
|
||||
if (payload.status !== undefined) {
|
||||
body.status = payload.status;
|
||||
}
|
||||
|
||||
if (payload.attributes !== undefined) {
|
||||
body.attributes = payload.attributes;
|
||||
}
|
||||
|
||||
if (payload.priorityRules !== undefined) {
|
||||
body.priorityRules = payload.priorityRules;
|
||||
}
|
||||
|
||||
const response = await apiFetch<SingleProjectResponse>(`/projects/${projectId}`, {
|
||||
method: 'PATCH',
|
||||
body: payload
|
||||
body
|
||||
});
|
||||
|
||||
return response.data;
|
||||
|
||||
Reference in New Issue
Block a user