add item by url 1st step

This commit is contained in:
Jurgis Sakalauskas
2025-10-13 15:46:04 +03:00
parent afc3da3e65
commit ff18d0daeb
7 changed files with 448 additions and 105 deletions
+26
View File
@@ -83,6 +83,13 @@ interface SingleItemResponse {
data: Item;
}
export interface ImportedItemData {
manufacturer: string | null;
model: string | null;
note: string | null;
attributes: Record<string, unknown>;
}
export const createItem = async (
projectId: string,
payload: CreateItemPayload
@@ -105,3 +112,22 @@ export const createItem = async (
return response.data;
};
interface ImportItemResponse {
data: ImportedItemData;
}
export const importItemFromUrl = async (
projectId: string,
url: string
): Promise<ImportedItemData> => {
const response = await apiFetch<ImportItemResponse>(
`/projects/${projectId}/items/import`,
{
method: 'POST',
body: { url }
}
);
return response.data;
};