mirror of
https://github.com/sakaljurgis/best-choice.git
synced 2026-07-08 21:47:40 +00:00
add item by url 1st step
This commit is contained in:
@@ -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;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user