diff --git a/app/components/assets/import-content.tsx b/app/components/assets/import-content.tsx index 4bb6964c9..9e61e10cd 100644 --- a/app/components/assets/import-content.tsx +++ b/app/components/assets/import-content.tsx @@ -141,16 +141,18 @@ export const ImportContent = () => ( free to get in touch with support and we can provide those for you. -

Extra considerations

- +
+

Extra considerations

+ +
); diff --git a/app/modules/asset/service.server.ts b/app/modules/asset/service.server.ts index b096f47d2..3195dc0fc 100644 --- a/app/modules/asset/service.server.ts +++ b/app/modules/asset/service.server.ts @@ -818,6 +818,7 @@ export async function createAsset({ customFieldsValues, organizationId, valuation, + availableToBook = true, }: Pick< Asset, "description" | "title" | "categoryId" | "userId" | "valuation" @@ -829,6 +830,7 @@ export async function createAsset({ custodian?: TeamMember["id"]; customFieldsValues?: ShelfAssetCustomFieldValueType[]; organizationId: Organization["id"]; + availableToBook?: Asset["availableToBook"]; }) { try { /** User connection data */ @@ -880,6 +882,7 @@ export async function createAsset({ qrCodes, valuation, organization, + availableToBook, }; /** If a categoryId is passed, link the category to the asset. */ @@ -1940,6 +1943,7 @@ export async function createAssetsFromContentImport({ : undefined, valuation: asset.valuation ? +asset.valuation : null, customFieldsValues, + availableToBook: asset?.bookable !== "no", }); } } catch (cause) { diff --git a/app/modules/asset/types.ts b/app/modules/asset/types.ts index 36c2dd286..68f4d93e1 100644 --- a/app/modules/asset/types.ts +++ b/app/modules/asset/types.ts @@ -53,6 +53,7 @@ export interface CreateAssetFromContentImportPayload tags: string[]; location?: string; custodian?: string; + bookable?: "yes" | "no"; } export interface CreateAssetFromBackupImportPayload extends Record { diff --git a/app/routes/_layout+/assets.import.tsx b/app/routes/_layout+/assets.import.tsx index f1b95c5f3..a280b1453 100644 --- a/app/routes/_layout+/assets.import.tsx +++ b/app/routes/_layout+/assets.import.tsx @@ -47,7 +47,7 @@ export const action = async ({ context, request }: ActionFunctionArgs) => { const { intent } = parseData( await request.clone().formData(), z.object({ - intent: z.enum(["backup", "content"]), + intent: z.enum(["content"]), }) ); @@ -59,27 +59,17 @@ export const action = async ({ context, request }: ActionFunctionArgs) => { message: "CSV file is empty", additionalData: { intent }, label: "Assets", + shouldBeCaptured: false, }); } - switch (intent) { - case "backup": { - throw new ShelfError({ - cause: null, - message: "This feature is not available for you", - label: "Assets", - }); - } - case "content": { - const contentData = extractCSVDataFromContentImport(csvData); - await createAssetsFromContentImport({ - data: contentData, - userId, - organizationId, - }); - return json(data(null)); - } - } + const contentData = extractCSVDataFromContentImport(csvData); + await createAssetsFromContentImport({ + data: contentData, + userId, + organizationId, + }); + return json(data(null)); } catch (cause) { const reason = makeShelfError(cause, { userId }); return json(error(reason), { status: reason.status }); diff --git a/public/static/shelf.nu-example-asset-import-from-content.csv b/public/static/shelf.nu-example-asset-import-from-content.csv index a12be8063..6743ef554 100644 --- a/public/static/shelf.nu-example-asset-import-from-content.csv +++ b/public/static/shelf.nu-example-asset-import-from-content.csv @@ -1,3 +1,3 @@ -qrId,title,description,kit,category,tags,location,valuation,custodian,"cf: Serial number,type:text","cf:brand, type:option","cf:purchase date, type:date" -abcde12345,AMD Ryzen,"CPU from my new home PC",Home PC,CPU,"High priority, small",Sofia office,100,John,WQE239123d,amd,02/22/2024 -12345abcde"Macbook Pro.","New laptop",Working gear,Laptop,"High priority, mid-size",Dutch office,2500,Thea,43543we23d,apple,03/12/2022 \ No newline at end of file +qrId,title,description,kit,category,tags,location,valuation,custodian,bookable,"cf: Serial number,type:text","cf:brand, type:option","cf:purchase date, type:date" +abcde12345,AMD Ryzen,"CPU from my new home PC",Home PC,CPU,"High priority, small",Sofia office,100,John,yes,WQE239123d,amd,02/22/2024 +12345abcde,"Macbook Pro.","New laptop",Working gear,Laptop,"High priority, mid-size",Dutch office,2500,Thea,no,43543we23d,apple,03/12/2022 \ No newline at end of file