@vicacha-devs/medusa-plugin-b2b 0.0.0-stage → 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.medusa/server/src/admin/index.cjs +8706 -0
- package/.medusa/server/src/admin/index.js +8683 -0
- package/.medusa/server/src/api/admin/b2b/approvals/[id]/route.js +24 -0
- package/.medusa/server/src/api/admin/b2b/approvals/middlewares.js +23 -0
- package/.medusa/server/src/api/admin/b2b/approvals/query-config.js +13 -0
- package/.medusa/server/src/api/admin/b2b/approvals/route.js +45 -0
- package/.medusa/server/src/api/admin/b2b/approvals/validators.js +15 -0
- package/.medusa/server/src/api/admin/b2b/companies/[id]/approval-settings/route.js +36 -0
- package/.medusa/server/src/api/admin/b2b/companies/[id]/customer-group/[customerGroupId]/route.js +10 -0
- package/.medusa/server/src/api/admin/b2b/companies/[id]/customer-group/route.js +35 -0
- package/.medusa/server/src/api/admin/b2b/companies/[id]/employees/[employeeId]/route.js +48 -0
- package/.medusa/server/src/api/admin/b2b/companies/[id]/employees/route.js +64 -0
- package/.medusa/server/src/api/admin/b2b/companies/[id]/route.js +48 -0
- package/.medusa/server/src/api/admin/b2b/companies/middlewares.js +77 -0
- package/.medusa/server/src/api/admin/b2b/companies/query-config.js +91 -0
- package/.medusa/server/src/api/admin/b2b/companies/route.js +68 -0
- package/.medusa/server/src/api/admin/b2b/companies/validators.js +113 -0
- package/.medusa/server/src/api/admin/b2b/customers/[id]/employee/route.js +20 -0
- package/.medusa/server/src/api/admin/b2b/quotes/[id]/messages/route.js +20 -0
- package/.medusa/server/src/api/admin/b2b/quotes/[id]/reject/route.js +19 -0
- package/.medusa/server/src/api/admin/b2b/quotes/[id]/route.js +30 -0
- package/.medusa/server/src/api/admin/b2b/quotes/[id]/send/route.js +19 -0
- package/.medusa/server/src/api/admin/b2b/quotes/middlewares.js +44 -0
- package/.medusa/server/src/api/admin/b2b/quotes/query-config.js +43 -0
- package/.medusa/server/src/api/admin/b2b/quotes/route.js +54 -0
- package/.medusa/server/src/api/admin/b2b/quotes/validators.js +37 -0
- package/.medusa/server/src/api/admin/companies/route.js +32 -0
- package/.medusa/server/src/api/admin/middlewares.js +9 -0
- package/.medusa/server/src/api/admin/validators.js +4 -0
- package/.medusa/server/src/api/admin/views/b2b-approvals/columns/route.js +119 -0
- package/.medusa/server/src/api/admin/views/b2b-companies/columns/route.js +144 -0
- package/.medusa/server/src/api/admin/views/b2b-company-employees/columns/route.js +73 -0
- package/.medusa/server/src/api/admin/views/b2b-quotes/columns/route.js +108 -0
- package/.medusa/server/src/api/middlewares/ensure-role.js +88 -0
- package/.medusa/server/src/api/middlewares.js +20 -0
- package/.medusa/server/src/api/store/b2b/approvals/[id]/route.js +24 -0
- package/.medusa/server/src/api/store/b2b/approvals/middlewares.js +71 -0
- package/.medusa/server/src/api/store/b2b/approvals/query-config.js +13 -0
- package/.medusa/server/src/api/store/b2b/approvals/route.js +76 -0
- package/.medusa/server/src/api/store/b2b/approvals/validators.js +22 -0
- package/.medusa/server/src/api/store/b2b/carts/[id]/approvals/route.js +24 -0
- package/.medusa/server/src/api/store/b2b/carts/[id]/line-items/bulk/route.js +26 -0
- package/.medusa/server/src/api/store/b2b/carts/middlewares.js +19 -0
- package/.medusa/server/src/api/store/b2b/carts/query-config.js +13 -0
- package/.medusa/server/src/api/store/b2b/carts/validators.js +12 -0
- package/.medusa/server/src/api/store/b2b/companies/[id]/approval-settings/route.js +21 -0
- package/.medusa/server/src/api/store/b2b/companies/[id]/employees/[employeeId]/route.js +53 -0
- package/.medusa/server/src/api/store/b2b/companies/[id]/employees/route.js +44 -0
- package/.medusa/server/src/api/store/b2b/companies/[id]/route.js +39 -0
- package/.medusa/server/src/api/store/b2b/companies/middlewares.js +94 -0
- package/.medusa/server/src/api/store/b2b/companies/query-config.js +62 -0
- package/.medusa/server/src/api/store/b2b/companies/route.js +18 -0
- package/.medusa/server/src/api/store/b2b/companies/validators.js +66 -0
- package/.medusa/server/src/api/store/b2b/free-shipping/middlewares.js +15 -0
- package/.medusa/server/src/api/store/b2b/free-shipping/prices/route.js +41 -0
- package/.medusa/server/src/api/store/b2b/free-shipping/utils.js +51 -0
- package/.medusa/server/src/api/store/b2b/free-shipping/validators.js +11 -0
- package/.medusa/server/src/api/store/b2b/quotes/[id]/accept/route.js +20 -0
- package/.medusa/server/src/api/store/b2b/quotes/[id]/messages/route.js +20 -0
- package/.medusa/server/src/api/store/b2b/quotes/[id]/preview/route.js +19 -0
- package/.medusa/server/src/api/store/b2b/quotes/[id]/reject/route.js +19 -0
- package/.medusa/server/src/api/store/b2b/quotes/[id]/route.js +15 -0
- package/.medusa/server/src/api/store/b2b/quotes/middlewares.js +64 -0
- package/.medusa/server/src/api/store/b2b/quotes/query-config.js +58 -0
- package/.medusa/server/src/api/store/b2b/quotes/route.js +39 -0
- package/.medusa/server/src/api/store/b2b/quotes/validators.js +35 -0
- package/.medusa/server/src/api/store/middlewares.js +13 -0
- package/.medusa/server/src/api/store/validators.js +6 -0
- package/.medusa/server/src/api/validators.js +3 -0
- package/.medusa/server/src/jobs/expire-quotes.js +22 -0
- package/.medusa/server/src/links/cart-approval-status.js +12 -0
- package/.medusa/server/src/links/cart-approvals.js +13 -0
- package/.medusa/server/src/links/company-approval-setting.js +5 -0
- package/.medusa/server/src/links/company-carts.js +12 -0
- package/.medusa/server/src/links/company-customer-group.js +11 -0
- package/.medusa/server/src/links/employee-customer.js +9 -0
- package/.medusa/server/src/links/order-company.js +9 -0
- package/.medusa/server/src/links/quote-links.js +77 -0
- package/.medusa/server/src/modules/approval/index.js +7 -0
- package/.medusa/server/src/modules/approval/migrations/Migration20260912010000.js +22 -0
- package/.medusa/server/src/modules/approval/models/approval-settings.js +21 -0
- package/.medusa/server/src/modules/approval/models/approval-status.js +21 -0
- package/.medusa/server/src/modules/approval/models/approval.js +36 -0
- package/.medusa/server/src/modules/approval/models/index.js +4 -0
- package/.medusa/server/src/modules/approval/service.js +18 -0
- package/.medusa/server/src/modules/company/index.js +7 -0
- package/.medusa/server/src/modules/company/migrations/Migration20260912010000.js +24 -0
- package/.medusa/server/src/modules/company/models/company.js +44 -0
- package/.medusa/server/src/modules/company/models/employee.js +30 -0
- package/.medusa/server/src/modules/company/models/index.js +3 -0
- package/.medusa/server/src/modules/company/service.js +9 -0
- package/.medusa/server/src/modules/company/types/common.js +2 -0
- package/.medusa/server/src/modules/company/types/mutations.js +2 -0
- package/.medusa/server/src/modules/quote/index.js +5 -0
- package/.medusa/server/src/modules/quote/migrations/Migration20260912010000.js +29 -0
- package/.medusa/server/src/modules/quote/models/index.js +3 -0
- package/.medusa/server/src/modules/quote/models/message.js +34 -0
- package/.medusa/server/src/modules/quote/models/quote.js +57 -0
- package/.medusa/server/src/modules/quote/service.js +6 -0
- package/.medusa/server/src/rbac.js +122 -0
- package/.medusa/server/src/scripts/seed-b2b-data.js +99 -0
- package/.medusa/server/src/scripts/seed-b2b-test-data.js +813 -0
- package/.medusa/server/src/types/approval/http.js +2 -0
- package/.medusa/server/src/types/approval/index.js +5 -0
- package/.medusa/server/src/types/approval/module.js +14 -0
- package/.medusa/server/src/types/approval/query.js +2 -0
- package/.medusa/server/src/types/approval/service.js +2 -0
- package/.medusa/server/src/types/company/http.js +2 -0
- package/.medusa/server/src/types/company/index.js +5 -0
- package/.medusa/server/src/types/company/module.js +3 -0
- package/.medusa/server/src/types/company/query.js +2 -0
- package/.medusa/server/src/types/company/service.js +2 -0
- package/.medusa/server/src/types/constants.js +16 -0
- package/.medusa/server/src/types/enums.js +18 -0
- package/.medusa/server/src/types/index.js +6 -0
- package/.medusa/server/src/types/quote/http.js +2 -0
- package/.medusa/server/src/types/quote/index.js +5 -0
- package/.medusa/server/src/types/quote/module.js +3 -0
- package/.medusa/server/src/types/quote/query.js +2 -0
- package/.medusa/server/src/types/quote/service.js +2 -0
- package/.medusa/server/src/types/shipping-options/http.js +2 -0
- package/.medusa/server/src/types/shipping-options/index.js +2 -0
- package/.medusa/server/src/types/types.js +2 -0
- package/.medusa/server/src/utils/check-spending-limit.js +51 -0
- package/.medusa/server/src/utils/get-cart-approval-status.js +22 -0
- package/.medusa/server/src/workflows/approval/steps/create-approval-settings.js +18 -0
- package/.medusa/server/src/workflows/approval/steps/create-approval-status.js +37 -0
- package/.medusa/server/src/workflows/approval/steps/create-approvals.js +55 -0
- package/.medusa/server/src/workflows/approval/steps/delete-approval-settings.js +23 -0
- package/.medusa/server/src/workflows/approval/steps/delete-approvals.js +11 -0
- package/.medusa/server/src/workflows/approval/steps/index.js +9 -0
- package/.medusa/server/src/workflows/approval/steps/update-approval-settings.js +12 -0
- package/.medusa/server/src/workflows/approval/steps/update-approval-statuses.js +49 -0
- package/.medusa/server/src/workflows/approval/steps/update-approval.js +60 -0
- package/.medusa/server/src/workflows/approval/workflows/create-approval-settings.js +20 -0
- package/.medusa/server/src/workflows/approval/workflows/create-approvals.js +43 -0
- package/.medusa/server/src/workflows/approval/workflows/index.js +5 -0
- package/.medusa/server/src/workflows/approval/workflows/update-approval-settings.js +6 -0
- package/.medusa/server/src/workflows/approval/workflows/update-approval.js +8 -0
- package/.medusa/server/src/workflows/company/steps/add-company-employees-to-customer-group.js +41 -0
- package/.medusa/server/src/workflows/company/steps/create-companies.js +14 -0
- package/.medusa/server/src/workflows/company/steps/delete-companies.js +11 -0
- package/.medusa/server/src/workflows/company/steps/dismiss-company-customer-group-link.js +40 -0
- package/.medusa/server/src/workflows/company/steps/index.js +7 -0
- package/.medusa/server/src/workflows/company/steps/remove-company-employees-from-customer-group.js +39 -0
- package/.medusa/server/src/workflows/company/steps/update-companies.js +14 -0
- package/.medusa/server/src/workflows/company/workflows/add-company-to-customer-group.js +25 -0
- package/.medusa/server/src/workflows/company/workflows/create-companies.js +21 -0
- package/.medusa/server/src/workflows/company/workflows/delete-companies.js +12 -0
- package/.medusa/server/src/workflows/company/workflows/index.js +6 -0
- package/.medusa/server/src/workflows/company/workflows/remove-company-from-customer-group.js +22 -0
- package/.medusa/server/src/workflows/company/workflows/update-companies.js +6 -0
- package/.medusa/server/src/workflows/employee/steps/add-employee-to-customer-group.js +41 -0
- package/.medusa/server/src/workflows/employee/steps/create-employees.js +20 -0
- package/.medusa/server/src/workflows/employee/steps/delete-employees.js +14 -0
- package/.medusa/server/src/workflows/employee/steps/index.js +8 -0
- package/.medusa/server/src/workflows/employee/steps/link-employee-to-customer.js +29 -0
- package/.medusa/server/src/workflows/employee/steps/remove-admin-role.js +37 -0
- package/.medusa/server/src/workflows/employee/steps/set-admin-role.js +56 -0
- package/.medusa/server/src/workflows/employee/steps/sync-customer-company-name.js +41 -0
- package/.medusa/server/src/workflows/employee/steps/update-employees.js +29 -0
- package/.medusa/server/src/workflows/employee/workflows/create-employees.js +34 -0
- package/.medusa/server/src/workflows/employee/workflows/delete-employees.js +15 -0
- package/.medusa/server/src/workflows/employee/workflows/index.js +4 -0
- package/.medusa/server/src/workflows/employee/workflows/update-employees.js +14 -0
- package/.medusa/server/src/workflows/hooks/cart-created.js +37 -0
- package/.medusa/server/src/workflows/hooks/order-created.js +30 -0
- package/.medusa/server/src/workflows/hooks/validate-add-to-cart.js +20 -0
- package/.medusa/server/src/workflows/hooks/validate-cart-completion.js +38 -0
- package/.medusa/server/src/workflows/hooks/validate-update-cart.js +20 -0
- package/.medusa/server/src/workflows/index.js +6 -0
- package/.medusa/server/src/workflows/order/steps/update-order.js +28 -0
- package/.medusa/server/src/workflows/order/workflows/update-order.js +21 -0
- package/.medusa/server/src/workflows/quote/steps/create-quote-message.js +18 -0
- package/.medusa/server/src/workflows/quote/steps/create-quotes.js +18 -0
- package/.medusa/server/src/workflows/quote/steps/update-quotes.js +28 -0
- package/.medusa/server/src/workflows/quote/steps/validate-quote-acceptance.js +11 -0
- package/.medusa/server/src/workflows/quote/steps/validate-quote-rejection.js +10 -0
- package/.medusa/server/src/workflows/quote/workflows/create-quote-message.js +11 -0
- package/.medusa/server/src/workflows/quote/workflows/create-quote.js +9 -0
- package/.medusa/server/src/workflows/quote/workflows/create-request-for-quote.js +84 -0
- package/.medusa/server/src/workflows/quote/workflows/customer-accept-quote.js +39 -0
- package/.medusa/server/src/workflows/quote/workflows/customer-reject-quote.js +27 -0
- package/.medusa/server/src/workflows/quote/workflows/index.js +9 -0
- package/.medusa/server/src/workflows/quote/workflows/merchant-reject-quote.js +28 -0
- package/.medusa/server/src/workflows/quote/workflows/merchant-send-quote.js +29 -0
- package/.medusa/server/src/workflows/quote/workflows/update-quote.js +9 -0
- package/LICENSE +21 -0
- package/README.md +587 -2
- package/package.json +121 -3
- package/src/__tests__/b2b-contract.spec.ts +41 -0
- package/src/admin/README.md +73 -0
- package/src/admin/constants.ts +1 -0
- package/src/admin/hooks/api/approvals.tsx +106 -0
- package/src/admin/hooks/api/companies.tsx +288 -0
- package/src/admin/hooks/api/customers.tsx +44 -0
- package/src/admin/hooks/api/employees.tsx +170 -0
- package/src/admin/hooks/api/index.ts +5 -0
- package/src/admin/hooks/api/quotes.tsx +329 -0
- package/src/admin/i18n/README.md +78 -0
- package/src/admin/i18n/index.ts +23 -0
- package/src/admin/i18n/json/ar.json +388 -0
- package/src/admin/i18n/json/de.json +388 -0
- package/src/admin/i18n/json/en.json +388 -0
- package/src/admin/i18n/json/es.json +388 -0
- package/src/admin/i18n/json/fr.json +388 -0
- package/src/admin/i18n/json/it.json +388 -0
- package/src/admin/i18n/json/nl.json +388 -0
- package/src/admin/i18n/json/pl.json +388 -0
- package/src/admin/i18n/json/pt.json +388 -0
- package/src/admin/i18n/json/tr.json +388 -0
- package/src/admin/routes/b2b/approvals/components/approval-actions.tsx +129 -0
- package/src/admin/routes/b2b/approvals/components/approval-status-badge.tsx +24 -0
- package/src/admin/routes/b2b/approvals/components/approvals-items-popover.tsx +69 -0
- package/src/admin/routes/b2b/approvals/components/approvals-table-adapter.tsx +45 -0
- package/src/admin/routes/b2b/approvals/components/approvals-table-renderers.tsx +74 -0
- package/src/admin/routes/b2b/approvals/components/approvals-table.tsx +66 -0
- package/src/admin/routes/b2b/approvals/components/table/columns.tsx +113 -0
- package/src/admin/routes/b2b/approvals/components/table/filters.tsx +30 -0
- package/src/admin/routes/b2b/approvals/components/table/query.tsx +25 -0
- package/src/admin/routes/b2b/approvals/page.tsx +66 -0
- package/src/admin/routes/b2b/companies/@create/page.tsx +70 -0
- package/src/admin/routes/b2b/companies/[id]/@approval-settings/page.tsx +106 -0
- package/src/admin/routes/b2b/companies/[id]/@customer-group/page.tsx +152 -0
- package/src/admin/routes/b2b/companies/[id]/@edit/page.tsx +93 -0
- package/src/admin/routes/b2b/companies/[id]/@employee/[employeeId]/page.tsx +82 -0
- package/src/admin/routes/b2b/companies/[id]/@employee/components/employees-actions-menu.tsx +61 -0
- package/src/admin/routes/b2b/companies/[id]/@employee/components/employees-create-form.tsx +190 -0
- package/src/admin/routes/b2b/companies/[id]/@employee/components/employees-update-form.tsx +160 -0
- package/src/admin/routes/b2b/companies/[id]/@employee/components/index.ts +3 -0
- package/src/admin/routes/b2b/companies/[id]/@employee/components/validators.ts +25 -0
- package/src/admin/routes/b2b/companies/[id]/@employee/create/page.tsx +91 -0
- package/src/admin/routes/b2b/companies/[id]/components/company-approval-settings-section.tsx +67 -0
- package/src/admin/routes/b2b/companies/[id]/components/company-customer-group-section.tsx +55 -0
- package/src/admin/routes/b2b/companies/[id]/components/company-employees-section.tsx +70 -0
- package/src/admin/routes/b2b/companies/[id]/components/company-employees-table-renderers.tsx +53 -0
- package/src/admin/routes/b2b/companies/[id]/components/company-general-section.tsx +59 -0
- package/src/admin/routes/b2b/companies/[id]/page.tsx +85 -0
- package/src/admin/routes/b2b/companies/components/companies-table-adapter.tsx +46 -0
- package/src/admin/routes/b2b/companies/components/companies-table-renderers.tsx +53 -0
- package/src/admin/routes/b2b/companies/components/companies-table.tsx +83 -0
- package/src/admin/routes/b2b/companies/components/company-actions-menu.tsx +46 -0
- package/src/admin/routes/b2b/companies/components/company-create-admin-tab.tsx +185 -0
- package/src/admin/routes/b2b/companies/components/company-create-details-tab.tsx +169 -0
- package/src/admin/routes/b2b/companies/components/company-create-form.tsx +201 -0
- package/src/admin/routes/b2b/companies/components/company-form-admin-tab.tsx +99 -0
- package/src/admin/routes/b2b/companies/components/company-form-details-tab.tsx +159 -0
- package/src/admin/routes/b2b/companies/components/company-form.tsx +159 -0
- package/src/admin/routes/b2b/companies/components/index.ts +9 -0
- package/src/admin/routes/b2b/companies/components/table/columns.tsx +81 -0
- package/src/admin/routes/b2b/companies/components/table/filters.tsx +23 -0
- package/src/admin/routes/b2b/companies/components/table/query.tsx +27 -0
- package/src/admin/routes/b2b/companies/components/use-delete-company-list-action.tsx +37 -0
- package/src/admin/routes/b2b/companies/components/validators.ts +49 -0
- package/src/admin/routes/b2b/companies/page.tsx +66 -0
- package/src/admin/routes/b2b/components/index.ts +6 -0
- package/src/admin/routes/b2b/components/navigation-card.tsx +51 -0
- package/src/admin/routes/b2b/components/stat-card.tsx +48 -0
- package/src/admin/routes/b2b/page.tsx +173 -0
- package/src/admin/routes/b2b/quotes/[id]/components/index.ts +8 -0
- package/src/admin/routes/b2b/quotes/[id]/components/quote-company-section.tsx +54 -0
- package/src/admin/routes/b2b/quotes/[id]/components/quote-customer-section.tsx +75 -0
- package/src/admin/routes/b2b/quotes/[id]/components/quote-detail-actions.tsx +57 -0
- package/src/admin/routes/b2b/quotes/[id]/components/quote-general-section.tsx +66 -0
- package/src/admin/routes/b2b/quotes/[id]/components/quote-message-bubble.tsx +132 -0
- package/src/admin/routes/b2b/quotes/[id]/components/quote-message-composer.tsx +135 -0
- package/src/admin/routes/b2b/quotes/[id]/components/quote-messages-section.tsx +100 -0
- package/src/admin/routes/b2b/quotes/[id]/components/quote-order-section.tsx +115 -0
- package/src/admin/routes/b2b/quotes/[id]/components/validators.ts +8 -0
- package/src/admin/routes/b2b/quotes/[id]/manage/components/index.ts +7 -0
- package/src/admin/routes/b2b/quotes/[id]/manage/components/manage-item-info.tsx +63 -0
- package/src/admin/routes/b2b/quotes/[id]/manage/components/manage-item-price-form.tsx +60 -0
- package/src/admin/routes/b2b/quotes/[id]/manage/components/manage-item.tsx +227 -0
- package/src/admin/routes/b2b/quotes/[id]/manage/components/manage-items-section.tsx +145 -0
- package/src/admin/routes/b2b/quotes/[id]/manage/components/manage-items-table.tsx +117 -0
- package/src/admin/routes/b2b/quotes/[id]/manage/components/manage-quote-form.tsx +187 -0
- package/src/admin/routes/b2b/quotes/[id]/manage/components/table/columns.tsx +29 -0
- package/src/admin/routes/b2b/quotes/[id]/manage/components/table/filters.tsx +8 -0
- package/src/admin/routes/b2b/quotes/[id]/manage/components/table/index.ts +3 -0
- package/src/admin/routes/b2b/quotes/[id]/manage/components/table/query.tsx +25 -0
- package/src/admin/routes/b2b/quotes/[id]/manage/components/validators.ts +5 -0
- package/src/admin/routes/b2b/quotes/[id]/manage/page.tsx +60 -0
- package/src/admin/routes/b2b/quotes/[id]/page.tsx +213 -0
- package/src/admin/routes/b2b/quotes/components/index.ts +4 -0
- package/src/admin/routes/b2b/quotes/components/quote-actions-menu.tsx +119 -0
- package/src/admin/routes/b2b/quotes/components/quote-status-badge.tsx +30 -0
- package/src/admin/routes/b2b/quotes/components/quotes-table-adapter.tsx +43 -0
- package/src/admin/routes/b2b/quotes/components/quotes-table-renderers.tsx +87 -0
- package/src/admin/routes/b2b/quotes/components/quotes-table.tsx +70 -0
- package/src/admin/routes/b2b/quotes/components/send-quote-drawer.tsx +69 -0
- package/src/admin/routes/b2b/quotes/components/table/columns.tsx +75 -0
- package/src/admin/routes/b2b/quotes/components/table/filters.tsx +44 -0
- package/src/admin/routes/b2b/quotes/components/table/query.tsx +27 -0
- package/src/admin/routes/b2b/quotes/page.tsx +65 -0
- package/src/admin/tsconfig.json +23 -0
- package/src/admin/validators.ts +4 -0
- package/src/admin/vite-env.d.ts +1 -0
- package/src/admin/widgets/customer-company-widget.tsx +63 -0
- package/src/admin/widgets/customer-employee-widget.tsx +48 -0
- package/src/admin/widgets/customer-group-companies-widget.tsx +68 -0
- package/src/api/README.md +64 -0
- package/src/api/admin/b2b/approvals/[id]/route.ts +34 -0
- package/src/api/admin/b2b/approvals/middlewares.ts +31 -0
- package/src/api/admin/b2b/approvals/query-config.ts +13 -0
- package/src/api/admin/b2b/approvals/route.ts +56 -0
- package/src/api/admin/b2b/approvals/validators.ts +23 -0
- package/src/api/admin/b2b/companies/[id]/approval-settings/route.ts +57 -0
- package/src/api/admin/b2b/companies/[id]/customer-group/[customerGroupId]/route.ts +17 -0
- package/src/api/admin/b2b/companies/[id]/customer-group/route.ts +56 -0
- package/src/api/admin/b2b/companies/[id]/employees/[employeeId]/route.ts +84 -0
- package/src/api/admin/b2b/companies/[id]/employees/route.ts +90 -0
- package/src/api/admin/b2b/companies/[id]/route.ts +88 -0
- package/src/api/admin/b2b/companies/middlewares.ts +123 -0
- package/src/api/admin/b2b/companies/query-config.ts +99 -0
- package/src/api/admin/b2b/companies/route.ts +101 -0
- package/src/api/admin/b2b/companies/validators.ts +165 -0
- package/src/api/admin/b2b/customers/[id]/employee/route.ts +31 -0
- package/src/api/admin/b2b/quotes/[id]/messages/route.ts +36 -0
- package/src/api/admin/b2b/quotes/[id]/reject/route.ts +35 -0
- package/src/api/admin/b2b/quotes/[id]/route.ts +48 -0
- package/src/api/admin/b2b/quotes/[id]/send/route.ts +35 -0
- package/src/api/admin/b2b/quotes/middlewares.ts +71 -0
- package/src/api/admin/b2b/quotes/query-config.ts +45 -0
- package/src/api/admin/b2b/quotes/route.ts +72 -0
- package/src/api/admin/b2b/quotes/validators.ts +49 -0
- package/src/api/admin/companies/route.ts +43 -0
- package/src/api/admin/middlewares.ts +10 -0
- package/src/api/admin/validators.ts +3 -0
- package/src/api/admin/views/b2b-approvals/columns/route.ts +121 -0
- package/src/api/admin/views/b2b-companies/columns/route.ts +146 -0
- package/src/api/admin/views/b2b-company-employees/columns/route.ts +74 -0
- package/src/api/admin/views/b2b-quotes/columns/route.ts +110 -0
- package/src/api/middlewares/ensure-role.ts +138 -0
- package/src/api/middlewares.ts +26 -0
- package/src/api/store/b2b/approvals/[id]/route.ts +34 -0
- package/src/api/store/b2b/approvals/middlewares.ts +103 -0
- package/src/api/store/b2b/approvals/query-config.ts +13 -0
- package/src/api/store/b2b/approvals/route.ts +105 -0
- package/src/api/store/b2b/approvals/validators.ts +30 -0
- package/src/api/store/b2b/carts/[id]/approvals/route.ts +33 -0
- package/src/api/store/b2b/carts/[id]/line-items/bulk/route.ts +46 -0
- package/src/api/store/b2b/carts/middlewares.ts +27 -0
- package/src/api/store/b2b/carts/query-config.ts +13 -0
- package/src/api/store/b2b/carts/validators.ts +19 -0
- package/src/api/store/b2b/companies/[id]/approval-settings/route.ts +33 -0
- package/src/api/store/b2b/companies/[id]/employees/[employeeId]/route.ts +86 -0
- package/src/api/store/b2b/companies/[id]/employees/route.ts +72 -0
- package/src/api/store/b2b/companies/[id]/route.ts +70 -0
- package/src/api/store/b2b/companies/middlewares.ts +137 -0
- package/src/api/store/b2b/companies/query-config.ts +76 -0
- package/src/api/store/b2b/companies/route.ts +34 -0
- package/src/api/store/b2b/companies/validators.ts +88 -0
- package/src/api/store/b2b/free-shipping/middlewares.ts +16 -0
- package/src/api/store/b2b/free-shipping/prices/route.ts +71 -0
- package/src/api/store/b2b/free-shipping/utils.ts +60 -0
- package/src/api/store/b2b/free-shipping/validators.ts +16 -0
- package/src/api/store/b2b/quotes/[id]/accept/route.ts +36 -0
- package/src/api/store/b2b/quotes/[id]/messages/route.ts +36 -0
- package/src/api/store/b2b/quotes/[id]/preview/route.ts +45 -0
- package/src/api/store/b2b/quotes/[id]/reject/route.ts +35 -0
- package/src/api/store/b2b/quotes/[id]/route.ts +30 -0
- package/src/api/store/b2b/quotes/middlewares.ts +96 -0
- package/src/api/store/b2b/quotes/query-config.ts +59 -0
- package/src/api/store/b2b/quotes/route.ts +65 -0
- package/src/api/store/b2b/quotes/validators.ts +51 -0
- package/src/api/store/middlewares.ts +14 -0
- package/src/api/store/validators.ts +5 -0
- package/src/api/validators.ts +2 -0
- package/src/jobs/expire-quotes.ts +31 -0
- package/src/links/README.md +62 -0
- package/src/links/cart-approval-status.ts +14 -0
- package/src/links/cart-approvals.ts +15 -0
- package/src/links/company-approval-setting.ts +8 -0
- package/src/links/company-carts.ts +14 -0
- package/src/links/company-customer-group.ts +16 -0
- package/src/links/employee-customer.ts +14 -0
- package/src/links/order-company.ts +14 -0
- package/src/links/quote-links.ts +77 -0
- package/src/modules/README.md +75 -0
- package/src/modules/approval/index.ts +8 -0
- package/src/modules/approval/migrations/Migration20260912010000.ts +47 -0
- package/src/modules/approval/models/approval-settings.ts +21 -0
- package/src/modules/approval/models/approval-status.ts +21 -0
- package/src/modules/approval/models/approval.ts +36 -0
- package/src/modules/approval/models/index.ts +3 -0
- package/src/modules/approval/service.ts +20 -0
- package/src/modules/company/index.ts +8 -0
- package/src/modules/company/migrations/Migration20260912010000.ts +50 -0
- package/src/modules/company/models/company.ts +44 -0
- package/src/modules/company/models/employee.ts +30 -0
- package/src/modules/company/models/index.ts +2 -0
- package/src/modules/company/service.ts +9 -0
- package/src/modules/company/types/common.ts +30 -0
- package/src/modules/company/types/mutations.ts +30 -0
- package/src/modules/quote/index.ts +6 -0
- package/src/modules/quote/migrations/Migration20260912010000.ts +65 -0
- package/src/modules/quote/models/index.ts +2 -0
- package/src/modules/quote/models/message.ts +35 -0
- package/src/modules/quote/models/quote.ts +58 -0
- package/src/modules/quote/service.ts +6 -0
- package/src/rbac.ts +136 -0
- package/src/scripts/README.md +40 -0
- package/src/scripts/seed-b2b-data.ts +177 -0
- package/src/scripts/seed-b2b-test-data.ts +986 -0
- package/src/types/README.md +52 -0
- package/src/types/approval/http.ts +56 -0
- package/src/types/approval/index.ts +4 -0
- package/src/types/approval/module.ts +77 -0
- package/src/types/approval/query.ts +11 -0
- package/src/types/approval/service.ts +126 -0
- package/src/types/company/http.ts +126 -0
- package/src/types/company/index.ts +4 -0
- package/src/types/company/module.ts +78 -0
- package/src/types/company/query.ts +15 -0
- package/src/types/company/service.ts +109 -0
- package/src/types/constants.ts +16 -0
- package/src/types/enums.ts +16 -0
- package/src/types/index.ts +5 -0
- package/src/types/quote/http.ts +50 -0
- package/src/types/quote/index.ts +4 -0
- package/src/types/quote/module.ts +45 -0
- package/src/types/quote/query.ts +22 -0
- package/src/types/quote/service.ts +65 -0
- package/src/types/shipping-options/http.ts +7 -0
- package/src/types/shipping-options/index.ts +1 -0
- package/src/types/types.ts +5 -0
- package/src/utils/README.md +37 -0
- package/src/utils/check-spending-limit.ts +81 -0
- package/src/utils/get-cart-approval-status.ts +35 -0
- package/src/workflows/README.md +85 -0
- package/src/workflows/approval/steps/create-approval-settings.ts +34 -0
- package/src/workflows/approval/steps/create-approval-status.ts +56 -0
- package/src/workflows/approval/steps/create-approvals.ts +114 -0
- package/src/workflows/approval/steps/delete-approval-settings.ts +52 -0
- package/src/workflows/approval/steps/delete-approvals.ts +21 -0
- package/src/workflows/approval/steps/index.ts +8 -0
- package/src/workflows/approval/steps/update-approval-settings.ts +27 -0
- package/src/workflows/approval/steps/update-approval-statuses.ts +77 -0
- package/src/workflows/approval/steps/update-approval.ts +87 -0
- package/src/workflows/approval/workflows/create-approval-settings.ts +32 -0
- package/src/workflows/approval/workflows/create-approvals.ts +60 -0
- package/src/workflows/approval/workflows/index.ts +4 -0
- package/src/workflows/approval/workflows/update-approval-settings.ts +13 -0
- package/src/workflows/approval/workflows/update-approval.ts +17 -0
- package/src/workflows/company/steps/add-company-employees-to-customer-group.ts +74 -0
- package/src/workflows/company/steps/create-companies.ts +28 -0
- package/src/workflows/company/steps/delete-companies.ts +21 -0
- package/src/workflows/company/steps/dismiss-company-customer-group-link.ts +53 -0
- package/src/workflows/company/steps/index.ts +6 -0
- package/src/workflows/company/steps/remove-company-employees-from-customer-group.ts +76 -0
- package/src/workflows/company/steps/update-companies.ts +25 -0
- package/src/workflows/company/workflows/add-company-to-customer-group.ts +34 -0
- package/src/workflows/company/workflows/create-companies.ts +35 -0
- package/src/workflows/company/workflows/delete-companies.ts +18 -0
- package/src/workflows/company/workflows/index.ts +5 -0
- package/src/workflows/company/workflows/remove-company-from-customer-group.ts +30 -0
- package/src/workflows/company/workflows/update-companies.ts +13 -0
- package/src/workflows/employee/steps/add-employee-to-customer-group.ts +81 -0
- package/src/workflows/employee/steps/create-employees.ts +46 -0
- package/src/workflows/employee/steps/delete-employees.ts +25 -0
- package/src/workflows/employee/steps/index.ts +7 -0
- package/src/workflows/employee/steps/link-employee-to-customer.ts +49 -0
- package/src/workflows/employee/steps/remove-admin-role.ts +59 -0
- package/src/workflows/employee/steps/set-admin-role.ts +89 -0
- package/src/workflows/employee/steps/sync-customer-company-name.ts +83 -0
- package/src/workflows/employee/steps/update-employees.ts +61 -0
- package/src/workflows/employee/workflows/create-employees.ts +61 -0
- package/src/workflows/employee/workflows/delete-employees.ts +26 -0
- package/src/workflows/employee/workflows/index.ts +3 -0
- package/src/workflows/employee/workflows/update-employees.ts +31 -0
- package/src/workflows/hooks/cart-created.ts +56 -0
- package/src/workflows/hooks/order-created.ts +38 -0
- package/src/workflows/hooks/validate-add-to-cart.ts +32 -0
- package/src/workflows/hooks/validate-cart-completion.ts +61 -0
- package/src/workflows/hooks/validate-update-cart.ts +32 -0
- package/src/workflows/index.ts +5 -0
- package/src/workflows/order/steps/update-order.ts +53 -0
- package/src/workflows/order/workflows/update-order.ts +28 -0
- package/src/workflows/quote/steps/create-quote-message.ts +33 -0
- package/src/workflows/quote/steps/create-quotes.ts +32 -0
- package/src/workflows/quote/steps/update-quotes.ts +48 -0
- package/src/workflows/quote/steps/validate-quote-acceptance.ts +22 -0
- package/src/workflows/quote/steps/validate-quote-rejection.ts +17 -0
- package/src/workflows/quote/workflows/create-quote-message.ts +20 -0
- package/src/workflows/quote/workflows/create-quote.ts +16 -0
- package/src/workflows/quote/workflows/create-request-for-quote.ts +102 -0
- package/src/workflows/quote/workflows/customer-accept-quote.ts +49 -0
- package/src/workflows/quote/workflows/customer-reject-quote.ts +31 -0
- package/src/workflows/quote/workflows/index.ts +8 -0
- package/src/workflows/quote/workflows/merchant-reject-quote.ts +34 -0
- package/src/workflows/quote/workflows/merchant-send-quote.ts +33 -0
- package/src/workflows/quote/workflows/update-quote.ts +16 -0
- package/tsconfig.json +40 -0
package/package.json
CHANGED
|
@@ -1,6 +1,124 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vicacha-devs/medusa-plugin-b2b",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "B2B commerce capabilities for Medusa v2: companies, employees, quotes, approvals, spending limits, and B2B cart workflows.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"b2b",
|
|
7
|
+
"medusa",
|
|
8
|
+
"medusa-plugin",
|
|
9
|
+
"medusa-plugin-b2b",
|
|
10
|
+
"medusa-plugin-integration",
|
|
11
|
+
"medusa-plugin-other",
|
|
12
|
+
"medusa-v2",
|
|
13
|
+
"plugin"
|
|
14
|
+
],
|
|
15
|
+
"license": "MIT",
|
|
16
|
+
"author": "Vicacha Devs",
|
|
17
|
+
"files": [
|
|
18
|
+
".medusa/server",
|
|
19
|
+
"src",
|
|
20
|
+
"README.md",
|
|
21
|
+
"LICENSE",
|
|
22
|
+
"tsconfig.json"
|
|
23
|
+
],
|
|
24
|
+
"type": "module",
|
|
25
|
+
"exports": {
|
|
26
|
+
"./package.json": "./package.json",
|
|
27
|
+
"./admin": {
|
|
28
|
+
"import": "./.medusa/server/src/admin/index.js",
|
|
29
|
+
"default": "./.medusa/server/src/admin/index.js"
|
|
30
|
+
},
|
|
31
|
+
"./types": {
|
|
32
|
+
"import": "./src/types/index.ts",
|
|
33
|
+
"default": "./.medusa/server/src/types/index.js"
|
|
34
|
+
},
|
|
35
|
+
"./workflows": "./.medusa/server/src/workflows/index.js",
|
|
36
|
+
"./.medusa/server/src/modules/*": "./.medusa/server/src/modules/*/index.js",
|
|
37
|
+
"./modules/*": "./.medusa/server/src/modules/*/index.js",
|
|
38
|
+
"./providers/*": "./.medusa/server/src/providers/*/index.js",
|
|
39
|
+
"./rbac": {
|
|
40
|
+
"import": "./src/rbac.ts",
|
|
41
|
+
"default": "./.medusa/server/src/rbac.js"
|
|
42
|
+
},
|
|
43
|
+
"./*": "./.medusa/server/src/*.js"
|
|
44
|
+
},
|
|
45
|
+
"devDependencies": {
|
|
46
|
+
"@hookform/resolvers": "5.7.1",
|
|
47
|
+
"@medusajs/admin-sdk": "2.23.0",
|
|
48
|
+
"@medusajs/admin-shared": "2.23.0",
|
|
49
|
+
"@medusajs/cli": "2.23.0",
|
|
50
|
+
"@medusajs/core-flows": "2.23.0",
|
|
51
|
+
"@medusajs/dashboard": "2.23.0",
|
|
52
|
+
"@medusajs/framework": "2.23.0",
|
|
53
|
+
"@medusajs/icons": "2.23.0",
|
|
54
|
+
"@medusajs/js-sdk": "2.23.0",
|
|
55
|
+
"@medusajs/medusa": "2.23.0",
|
|
56
|
+
"@medusajs/test-utils": "2.23.0",
|
|
57
|
+
"@medusajs/types": "2.23.0",
|
|
58
|
+
"@medusajs/ui": "4.3.0",
|
|
59
|
+
"@mikro-orm/migrations": "6.4.3",
|
|
60
|
+
"@radix-ui/react-popover": "1.1.23",
|
|
61
|
+
"@radix-ui/react-radio-group": "1.4.7",
|
|
62
|
+
"@radix-ui/react-slot": "1.3.3",
|
|
63
|
+
"@swc/core": "1.7.28",
|
|
64
|
+
"@tanstack/react-query": "5.107.1",
|
|
65
|
+
"@tanstack/react-table": "9.3.1",
|
|
66
|
+
"@types/lodash": "4.17.16",
|
|
67
|
+
"@types/node": "20.0.0",
|
|
68
|
+
"@types/react": "^19.3.0",
|
|
69
|
+
"@types/react-dom": "^19.3.0",
|
|
70
|
+
"cmdk": "1.1.1",
|
|
71
|
+
"date-fns": "4.4.0",
|
|
72
|
+
"jiti": "2.0.0",
|
|
73
|
+
"lodash": "4.18.1",
|
|
74
|
+
"prop-types": "15.8.1",
|
|
75
|
+
"react": "^19.3.1",
|
|
76
|
+
"react-dom": "^19.3.1",
|
|
77
|
+
"react-hook-form": "7.92.0",
|
|
78
|
+
"react-i18next": "18.0.1",
|
|
79
|
+
"react-router-dom": "7.18.5",
|
|
80
|
+
"ts-node": "10.9.2",
|
|
81
|
+
"tsc-alias": "^1.9.2",
|
|
82
|
+
"typescript": "5.6.2",
|
|
83
|
+
"vite": "^8.3.8",
|
|
84
|
+
"@vicacha-devs/medusa-shared-admin": "0.0.1"
|
|
85
|
+
},
|
|
86
|
+
"peerDependencies": {
|
|
87
|
+
"@hookform/resolvers": "5.7.1",
|
|
88
|
+
"@medusajs/admin-sdk": "2.23.0",
|
|
89
|
+
"@medusajs/admin-shared": "2.23.0",
|
|
90
|
+
"@medusajs/cli": "2.23.0",
|
|
91
|
+
"@medusajs/core-flows": "2.23.0",
|
|
92
|
+
"@medusajs/framework": "2.23.0",
|
|
93
|
+
"@medusajs/icons": "2.23.0",
|
|
94
|
+
"@medusajs/js-sdk": "2.23.0",
|
|
95
|
+
"@medusajs/medusa": "2.23.0",
|
|
96
|
+
"@medusajs/types": "2.23.0",
|
|
97
|
+
"@medusajs/ui": "4.3.0",
|
|
98
|
+
"@tanstack/react-query": "5.107.1",
|
|
99
|
+
"@tanstack/react-table": "9.3.1",
|
|
100
|
+
"@uiw/react-json-view": "2.0.0-alpha.43",
|
|
101
|
+
"lodash": "4.18.1",
|
|
102
|
+
"react": "^19.3.1",
|
|
103
|
+
"react-dom": "^19.3.1",
|
|
104
|
+
"react-hook-form": "7.92.0",
|
|
105
|
+
"react-i18next": "18.0.1",
|
|
106
|
+
"react-router-dom": "7.18.5",
|
|
107
|
+
"zod": "4.6.7"
|
|
108
|
+
},
|
|
109
|
+
"engines": {
|
|
110
|
+
"node": ">=22.22.0"
|
|
111
|
+
},
|
|
112
|
+
"scripts": {
|
|
113
|
+
"build": "medusa plugin:build && tsc-alias -p tsconfig.json --resolve-full-paths",
|
|
114
|
+
"publish:local": "medusa plugin:publish",
|
|
115
|
+
"dev": "medusa plugin:develop",
|
|
116
|
+
"lint": "medusa lint",
|
|
117
|
+
"typecheck": "tsc --noEmit",
|
|
118
|
+
"test": "node --import ../plugin-testing/register-ts-resolver.mjs --import ../plugin-testing/register-js-extension.mjs --test src/__tests__/*.spec.ts",
|
|
119
|
+
"test:integration:http": "TEST_TYPE=integration:http NODE_OPTIONS=--experimental-vm-modules jest --silent=false --runInBand --forceExit",
|
|
120
|
+
"test:integration:modules": "TEST_TYPE=integration:modules NODE_OPTIONS=--experimental-vm-modules jest --silent --runInBand --forceExit",
|
|
121
|
+
"test:unit": "TEST_TYPE=unit NODE_OPTIONS=--experimental-vm-modules jest --silent --runInBand --forceExit",
|
|
122
|
+
"clean": "rm -rf .medusa node_modules"
|
|
123
|
+
}
|
|
6
124
|
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import assert from "node:assert/strict"
|
|
2
|
+
import { existsSync, readFileSync } from "node:fs"
|
|
3
|
+
import { dirname, resolve } from "node:path"
|
|
4
|
+
import { describe, it } from "node:test"
|
|
5
|
+
import { fileURLToPath } from "node:url"
|
|
6
|
+
|
|
7
|
+
const pkgRoot = resolve(dirname(fileURLToPath(import.meta.url)), "../..")
|
|
8
|
+
|
|
9
|
+
describe("@vicacha-devs/medusa-plugin-b2b — Offline Contract Suite", () => {
|
|
10
|
+
it("declares valid Medusa v2 plugin manifest & exports", () => {
|
|
11
|
+
const pkg = JSON.parse(
|
|
12
|
+
readFileSync(resolve(pkgRoot, "package.json"), "utf8")
|
|
13
|
+
) as {
|
|
14
|
+
name: string
|
|
15
|
+
exports: Record<string, unknown>
|
|
16
|
+
files: string[]
|
|
17
|
+
scripts: Record<string, string>
|
|
18
|
+
}
|
|
19
|
+
assert.equal(pkg.name, "@vicacha-devs/medusa-plugin-b2b")
|
|
20
|
+
assert.ok(pkg.exports["./admin"], "exports ./admin entry")
|
|
21
|
+
assert.ok(pkg.exports["./workflows"], "exports ./workflows entry")
|
|
22
|
+
assert.ok(pkg.files.includes(".medusa/server"), "ships .medusa/server")
|
|
23
|
+
assert.ok(pkg.scripts.build, "has build script")
|
|
24
|
+
assert.ok(pkg.scripts.typecheck, "has typecheck script")
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
it("contains required B2B modules, workflows, links, and API routes", () => {
|
|
28
|
+
for (const rel of [
|
|
29
|
+
"src/modules",
|
|
30
|
+
"src/workflows",
|
|
31
|
+
"src/links",
|
|
32
|
+
"src/api",
|
|
33
|
+
"src/admin",
|
|
34
|
+
]) {
|
|
35
|
+
assert.ok(
|
|
36
|
+
existsSync(resolve(pkgRoot, rel)),
|
|
37
|
+
`Expected directory ${rel} to exist`
|
|
38
|
+
)
|
|
39
|
+
}
|
|
40
|
+
})
|
|
41
|
+
})
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# Admin (`src/admin`)
|
|
2
|
+
|
|
3
|
+
Medusa v2 Admin extension — multi-route pages built with `LayoutComposer`, decoupled single-responsibility section components (`< 170` lines per file), shared table/form primitives, and React Query hooks for `@vicacha-devs/medusa-plugin-b2b`.
|
|
4
|
+
|
|
5
|
+
```text
|
|
6
|
+
admin/
|
|
7
|
+
├── tsconfig.json
|
|
8
|
+
├── validators.ts # Barrel re-exporting all Admin UI form Zod schemas
|
|
9
|
+
├── i18n/ # react-i18next setup and locale JSON bundles
|
|
10
|
+
├── lib/
|
|
11
|
+
│ ├── client.ts # Medusa JS SDK client singleton
|
|
12
|
+
│ └── query-key-factory.ts # React Query key builder
|
|
13
|
+
├── hooks/
|
|
14
|
+
│ ├── api/ # React Query hooks (companies, employees, quotes, approvals, etc.)
|
|
15
|
+
│ └── table/ # Table filter, query, and column hooks
|
|
16
|
+
├── components/
|
|
17
|
+
│ └── common/ # Shared UI primitives (DataTable, Form, RouteFocusModal, ActionMenu, etc.)
|
|
18
|
+
├── routes/
|
|
19
|
+
│ └── b2b/
|
|
20
|
+
│ ├── page.tsx # /b2b — Overview dashboard (renders B2BOverviewSection)
|
|
21
|
+
│ ├── components/
|
|
22
|
+
│ │ └── b2b-overview-section.tsx # KPI stat cards & quick-navigation cards
|
|
23
|
+
│ ├── companies/
|
|
24
|
+
│ │ ├── page.tsx # /b2b/companies — Companies list & create drawer
|
|
25
|
+
│ │ ├── components/
|
|
26
|
+
│ │ │ ├── company-form.tsx
|
|
27
|
+
│ │ │ ├── company-actions-menu.tsx
|
|
28
|
+
│ │ │ └── employees/ # Employee table, create/edit drawers, and form fields
|
|
29
|
+
│ │ └── [companyId]/
|
|
30
|
+
│ │ ├── page.tsx # /b2b/companies/:companyId (TWO_COLUMN_SEVEN_FIVE layout)
|
|
31
|
+
│ │ └── components/
|
|
32
|
+
│ │ ├── company-details-Section.tsx
|
|
33
|
+
│ │ ├── company-edit-section.tsx
|
|
34
|
+
│ │ ├── company-employees-section.tsx
|
|
35
|
+
│ │ ├── company-customer-group-section.tsx
|
|
36
|
+
│ │ └── company-approval-settings-section.tsx
|
|
37
|
+
│ ├── quotes/
|
|
38
|
+
│ │ ├── page.tsx # /b2b/quotes — Quotes list (renders QuoteTableSection)
|
|
39
|
+
│ │ ├── components/
|
|
40
|
+
│ │ │ ├── quote-table-section.tsx
|
|
41
|
+
│ │ │ ├── quote-details/
|
|
42
|
+
│ │ │ │ ├── quote-details-main-section.tsx
|
|
43
|
+
│ │ │ │ ├── quote-details-sidebar-section.tsx
|
|
44
|
+
│ │ │ │ ├── quote-items.tsx
|
|
45
|
+
│ │ │ │ ├── quote-cost-breakdown.tsx
|
|
46
|
+
│ │ │ │ └── quote-messages.tsx
|
|
47
|
+
│ │ │ └── quote-manage/
|
|
48
|
+
│ │ │ ├── quote-manage-form-section.tsx
|
|
49
|
+
│ │ │ ├── manage-quote-form.tsx
|
|
50
|
+
│ │ │ ├── manage-item.tsx
|
|
51
|
+
│ │ │ └── manage-items-section.tsx
|
|
52
|
+
│ │ └── [quoteId]/
|
|
53
|
+
│ │ ├── page.tsx # /b2b/quotes/:quoteId (TWO_COLUMN_SEVEN_FIVE layout)
|
|
54
|
+
│ │ └── manage/
|
|
55
|
+
│ │ └── page.tsx # /b2b/quotes/:quoteId/manage
|
|
56
|
+
│ └── approvals/
|
|
57
|
+
│ ├── page.tsx # /b2b/approvals — Cart approval queue
|
|
58
|
+
│ └── components/
|
|
59
|
+
│ └── approval-actions.tsx
|
|
60
|
+
└── utils/ # Currency, date, and error formatting utilities
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
---
|
|
64
|
+
|
|
65
|
+
## Layout & Component Architecture
|
|
66
|
+
|
|
67
|
+
1. **`LayoutComposer` Integration**:
|
|
68
|
+
- Single-column list and overview pages (`/b2b`, `/b2b/companies`, `/b2b/quotes`, `/b2b/approvals`) use `CORE_LAYOUT_IDS.SINGLE_COLUMN`.
|
|
69
|
+
- Detail pages (`/b2b/companies/:companyId`, `/b2b/quotes/:quoteId`) use `CORE_LAYOUT_IDS.TWO_COLUMN_SEVEN_FIVE` (`main` + `sidebar` zones).
|
|
70
|
+
2. **Decoupled Single-Responsibility Sections**:
|
|
71
|
+
- Route `page.tsx` files act purely as layout orchestrators, delegating forms, tables, and drawers to dedicated section components under `components/` (`< 170` lines per file).
|
|
72
|
+
3. **Data Fetching (`hooks/api/`)**:
|
|
73
|
+
- All server communication uses React Query hooks (`useCompanies`, `useCompany`, `useEmployees`, `useQuotes`, `useQuote`, `useApprovals`, etc.) backed by the Medusa JS SDK (`lib/client.ts`).
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const PAGE_SIZE = 25
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { FetchError } from "@medusajs/js-sdk"
|
|
2
|
+
import { queryKeysFactory, sdk } from "@vicacha-devs/medusa-shared-admin/admin"
|
|
3
|
+
import {
|
|
4
|
+
useMutation,
|
|
5
|
+
UseMutationOptions,
|
|
6
|
+
useQuery,
|
|
7
|
+
useQueryClient,
|
|
8
|
+
UseQueryOptions,
|
|
9
|
+
} from "@tanstack/react-query"
|
|
10
|
+
|
|
11
|
+
import {
|
|
12
|
+
AdminApproval,
|
|
13
|
+
AdminApprovalSettings,
|
|
14
|
+
AdminApprovalsResponse,
|
|
15
|
+
AdminUpdateApproval,
|
|
16
|
+
AdminUpdateApprovalSettings,
|
|
17
|
+
} from "../../../types"
|
|
18
|
+
import { companyQueryKey } from "./companies"
|
|
19
|
+
|
|
20
|
+
export const approvalSettingsQueryKey = queryKeysFactory("approvalSettings")
|
|
21
|
+
|
|
22
|
+
export const useUpdateApprovalSettings = (
|
|
23
|
+
companyId: string,
|
|
24
|
+
options?: UseMutationOptions<
|
|
25
|
+
AdminApprovalSettings,
|
|
26
|
+
FetchError,
|
|
27
|
+
AdminUpdateApprovalSettings
|
|
28
|
+
>
|
|
29
|
+
) => {
|
|
30
|
+
const queryClient = useQueryClient()
|
|
31
|
+
|
|
32
|
+
return useMutation({
|
|
33
|
+
mutationFn: (payload: AdminUpdateApprovalSettings) =>
|
|
34
|
+
sdk.client.fetch<AdminUpdateApprovalSettings>(
|
|
35
|
+
`/admin/b2b/companies/${companyId}/approval-settings`,
|
|
36
|
+
{
|
|
37
|
+
body: payload,
|
|
38
|
+
method: "POST",
|
|
39
|
+
}
|
|
40
|
+
),
|
|
41
|
+
onSuccess: (
|
|
42
|
+
data: any,
|
|
43
|
+
variables: any,
|
|
44
|
+
onMutateResult: any,
|
|
45
|
+
context: any
|
|
46
|
+
) => {
|
|
47
|
+
queryClient.invalidateQueries({
|
|
48
|
+
queryKey: approvalSettingsQueryKey.detail(companyId),
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
queryClient.invalidateQueries({
|
|
52
|
+
queryKey: companyQueryKey.detail(companyId),
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
options?.onSuccess?.(data, variables, onMutateResult, context)
|
|
56
|
+
},
|
|
57
|
+
...options,
|
|
58
|
+
})
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const approvalQueryKey = queryKeysFactory("approval")
|
|
62
|
+
|
|
63
|
+
export const useApprovals = (
|
|
64
|
+
query?: Record<string, any>,
|
|
65
|
+
options?: UseQueryOptions<AdminApprovalsResponse, FetchError>
|
|
66
|
+
) => {
|
|
67
|
+
const fetchApprovals = async () =>
|
|
68
|
+
sdk.client.fetch<AdminApprovalsResponse>(`/admin/b2b/approvals`, {
|
|
69
|
+
method: "GET",
|
|
70
|
+
query,
|
|
71
|
+
})
|
|
72
|
+
|
|
73
|
+
return useQuery({
|
|
74
|
+
queryKey: approvalQueryKey.list(query),
|
|
75
|
+
queryFn: fetchApprovals,
|
|
76
|
+
...options,
|
|
77
|
+
})
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export const useUpdateApproval = (
|
|
81
|
+
approvalId: string,
|
|
82
|
+
options?: UseMutationOptions<AdminApproval, FetchError, AdminUpdateApproval>
|
|
83
|
+
) => {
|
|
84
|
+
const queryClient = useQueryClient()
|
|
85
|
+
|
|
86
|
+
return useMutation({
|
|
87
|
+
mutationFn: (payload: AdminUpdateApproval) =>
|
|
88
|
+
sdk.client.fetch<AdminApproval>(`/admin/b2b/approvals/${approvalId}`, {
|
|
89
|
+
body: payload,
|
|
90
|
+
method: "POST",
|
|
91
|
+
}),
|
|
92
|
+
onSuccess: (
|
|
93
|
+
data: any,
|
|
94
|
+
variables: any,
|
|
95
|
+
onMutateResult: any,
|
|
96
|
+
context: any
|
|
97
|
+
) => {
|
|
98
|
+
queryClient.invalidateQueries({
|
|
99
|
+
queryKey: approvalQueryKey.lists(),
|
|
100
|
+
})
|
|
101
|
+
|
|
102
|
+
options?.onSuccess?.(data, variables, onMutateResult, context)
|
|
103
|
+
},
|
|
104
|
+
...options,
|
|
105
|
+
})
|
|
106
|
+
}
|
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
import { FetchError } from "@medusajs/js-sdk"
|
|
2
|
+
import {
|
|
3
|
+
QueryKey,
|
|
4
|
+
useMutation,
|
|
5
|
+
UseMutationOptions,
|
|
6
|
+
useQuery,
|
|
7
|
+
useQueryClient,
|
|
8
|
+
UseQueryOptions,
|
|
9
|
+
} from "@tanstack/react-query"
|
|
10
|
+
import { queryKeysFactory, sdk } from "@vicacha-devs/medusa-shared-admin/admin"
|
|
11
|
+
import {
|
|
12
|
+
AdminCompaniesResponse,
|
|
13
|
+
AdminCompanyResponse,
|
|
14
|
+
AdminCreateCompany,
|
|
15
|
+
AdminUpdateCompany,
|
|
16
|
+
} from "../../../types"
|
|
17
|
+
|
|
18
|
+
export const companyQueryKey = queryKeysFactory("company")
|
|
19
|
+
|
|
20
|
+
export const useCompanies = (
|
|
21
|
+
query?: Record<string, any>,
|
|
22
|
+
options?: UseQueryOptions<
|
|
23
|
+
AdminCompaniesResponse,
|
|
24
|
+
FetchError,
|
|
25
|
+
AdminCompaniesResponse,
|
|
26
|
+
QueryKey
|
|
27
|
+
>
|
|
28
|
+
) => {
|
|
29
|
+
const fetchCompanies = async () =>
|
|
30
|
+
sdk.client.fetch<AdminCompaniesResponse>(`/admin/b2b/companies`, {
|
|
31
|
+
method: "GET",
|
|
32
|
+
query,
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
return useQuery({
|
|
36
|
+
queryKey: companyQueryKey.list(query),
|
|
37
|
+
queryFn: fetchCompanies,
|
|
38
|
+
...options,
|
|
39
|
+
})
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export const useCompany = (
|
|
43
|
+
companyId: string,
|
|
44
|
+
query?: Record<string, any>,
|
|
45
|
+
options?: UseQueryOptions<
|
|
46
|
+
AdminCompanyResponse,
|
|
47
|
+
FetchError,
|
|
48
|
+
AdminCompanyResponse,
|
|
49
|
+
QueryKey
|
|
50
|
+
>
|
|
51
|
+
) => {
|
|
52
|
+
const filterQuery = new URLSearchParams(query).toString()
|
|
53
|
+
|
|
54
|
+
const fetchCompany = async () =>
|
|
55
|
+
sdk.client.fetch<AdminCompanyResponse>(
|
|
56
|
+
`/admin/b2b/companies/${companyId}${filterQuery ? `?${filterQuery}` : ""}`,
|
|
57
|
+
{
|
|
58
|
+
method: "GET",
|
|
59
|
+
}
|
|
60
|
+
)
|
|
61
|
+
|
|
62
|
+
return useQuery({
|
|
63
|
+
queryKey: companyQueryKey.detail(companyId),
|
|
64
|
+
queryFn: fetchCompany,
|
|
65
|
+
...options,
|
|
66
|
+
})
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
type CreateCompanyInput = AdminCreateCompany & {
|
|
70
|
+
group_id?: string
|
|
71
|
+
requires_admin_approval?: boolean
|
|
72
|
+
requires_sales_manager_approval?: boolean
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export const useCreateCompany = (
|
|
76
|
+
options?: UseMutationOptions<
|
|
77
|
+
AdminCompanyResponse,
|
|
78
|
+
FetchError,
|
|
79
|
+
CreateCompanyInput
|
|
80
|
+
>
|
|
81
|
+
) => {
|
|
82
|
+
const queryClient = useQueryClient()
|
|
83
|
+
|
|
84
|
+
return useMutation({
|
|
85
|
+
mutationFn: async ({
|
|
86
|
+
group_id,
|
|
87
|
+
requires_admin_approval,
|
|
88
|
+
requires_sales_manager_approval,
|
|
89
|
+
...company
|
|
90
|
+
}: CreateCompanyInput) => {
|
|
91
|
+
const result = await sdk.client.fetch<AdminCompanyResponse>(
|
|
92
|
+
"/admin/b2b/companies",
|
|
93
|
+
{
|
|
94
|
+
method: "POST",
|
|
95
|
+
headers: { "Content-Type": "application/json" },
|
|
96
|
+
body: company,
|
|
97
|
+
}
|
|
98
|
+
)
|
|
99
|
+
|
|
100
|
+
const created = (result as any).companies?.[0] ?? (result as any).company
|
|
101
|
+
const companyId: string | undefined = created?.id
|
|
102
|
+
|
|
103
|
+
if (companyId) {
|
|
104
|
+
const postCreation: Promise<any>[] = []
|
|
105
|
+
|
|
106
|
+
if (group_id) {
|
|
107
|
+
postCreation.push(
|
|
108
|
+
sdk.client.fetch(
|
|
109
|
+
`/admin/b2b/companies/${companyId}/customer-group`,
|
|
110
|
+
{
|
|
111
|
+
method: "POST",
|
|
112
|
+
headers: { "Content-Type": "application/json" },
|
|
113
|
+
body: { group_id },
|
|
114
|
+
}
|
|
115
|
+
)
|
|
116
|
+
)
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
const approvalSettingsId: string | undefined =
|
|
120
|
+
created?.approval_settings?.id
|
|
121
|
+
if (
|
|
122
|
+
approvalSettingsId &&
|
|
123
|
+
(requires_admin_approval || requires_sales_manager_approval)
|
|
124
|
+
) {
|
|
125
|
+
postCreation.push(
|
|
126
|
+
sdk.client.fetch(
|
|
127
|
+
`/admin/b2b/companies/${companyId}/approval-settings`,
|
|
128
|
+
{
|
|
129
|
+
method: "POST",
|
|
130
|
+
headers: { "Content-Type": "application/json" },
|
|
131
|
+
body: {
|
|
132
|
+
id: approvalSettingsId,
|
|
133
|
+
requires_admin_approval,
|
|
134
|
+
requires_sales_manager_approval,
|
|
135
|
+
},
|
|
136
|
+
}
|
|
137
|
+
)
|
|
138
|
+
)
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
await Promise.all(postCreation)
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
return result
|
|
145
|
+
},
|
|
146
|
+
onSuccess: (
|
|
147
|
+
data: any,
|
|
148
|
+
variables: any,
|
|
149
|
+
onMutateResult: any,
|
|
150
|
+
context: any
|
|
151
|
+
) => {
|
|
152
|
+
queryClient.invalidateQueries({ queryKey: companyQueryKey.lists() })
|
|
153
|
+
queryClient.invalidateQueries({
|
|
154
|
+
queryKey: companyQueryKey.detail(data?.company?.id),
|
|
155
|
+
})
|
|
156
|
+
options?.onSuccess?.(data, variables, onMutateResult, context)
|
|
157
|
+
},
|
|
158
|
+
...options,
|
|
159
|
+
})
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
export const useUpdateCompany = (
|
|
163
|
+
companyId: string,
|
|
164
|
+
options?: UseMutationOptions<
|
|
165
|
+
AdminCompanyResponse,
|
|
166
|
+
FetchError,
|
|
167
|
+
AdminUpdateCompany
|
|
168
|
+
>
|
|
169
|
+
) => {
|
|
170
|
+
const queryClient = useQueryClient()
|
|
171
|
+
|
|
172
|
+
return useMutation({
|
|
173
|
+
mutationFn: (company: AdminUpdateCompany) =>
|
|
174
|
+
sdk.client.fetch<AdminCompanyResponse>(
|
|
175
|
+
`/admin/b2b/companies/${companyId}`,
|
|
176
|
+
{
|
|
177
|
+
method: "POST",
|
|
178
|
+
headers: {
|
|
179
|
+
"Content-Type": "application/json",
|
|
180
|
+
},
|
|
181
|
+
body: company,
|
|
182
|
+
}
|
|
183
|
+
),
|
|
184
|
+
onSuccess: (
|
|
185
|
+
data: any,
|
|
186
|
+
variables: any,
|
|
187
|
+
onMutateResult: any,
|
|
188
|
+
context: any
|
|
189
|
+
) => {
|
|
190
|
+
queryClient.invalidateQueries({
|
|
191
|
+
queryKey: companyQueryKey.lists(),
|
|
192
|
+
})
|
|
193
|
+
queryClient.invalidateQueries({
|
|
194
|
+
queryKey: companyQueryKey.detail(companyId),
|
|
195
|
+
})
|
|
196
|
+
options?.onSuccess?.(data, variables, onMutateResult, context)
|
|
197
|
+
},
|
|
198
|
+
...options,
|
|
199
|
+
})
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
export const useDeleteCompany = (
|
|
203
|
+
companyId: string,
|
|
204
|
+
options?: UseMutationOptions<void, FetchError>
|
|
205
|
+
) => {
|
|
206
|
+
const queryClient = useQueryClient()
|
|
207
|
+
return useMutation({
|
|
208
|
+
mutationFn: () =>
|
|
209
|
+
sdk.client.fetch<void>(`/admin/b2b/companies/${companyId}`, {
|
|
210
|
+
method: "DELETE",
|
|
211
|
+
}),
|
|
212
|
+
onSuccess: (
|
|
213
|
+
data: any,
|
|
214
|
+
variables: any,
|
|
215
|
+
onMutateResult: any,
|
|
216
|
+
context: any
|
|
217
|
+
) => {
|
|
218
|
+
queryClient.invalidateQueries({
|
|
219
|
+
queryKey: companyQueryKey.lists(),
|
|
220
|
+
})
|
|
221
|
+
options?.onSuccess?.(data, variables, onMutateResult, context)
|
|
222
|
+
},
|
|
223
|
+
...options,
|
|
224
|
+
})
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
export const useAddCompanyToCustomerGroup = (
|
|
228
|
+
companyId: string,
|
|
229
|
+
options?: UseMutationOptions<void, FetchError, string>
|
|
230
|
+
) => {
|
|
231
|
+
const queryClient = useQueryClient()
|
|
232
|
+
|
|
233
|
+
return useMutation({
|
|
234
|
+
mutationFn: (groupId: string) =>
|
|
235
|
+
sdk.client.fetch(`/admin/b2b/companies/${companyId}/customer-group`, {
|
|
236
|
+
method: "POST",
|
|
237
|
+
headers: {
|
|
238
|
+
"Content-Type": "application/json",
|
|
239
|
+
},
|
|
240
|
+
body: { group_id: groupId },
|
|
241
|
+
}),
|
|
242
|
+
onSuccess: (
|
|
243
|
+
data: any,
|
|
244
|
+
variables: any,
|
|
245
|
+
onMutateResult: any,
|
|
246
|
+
context: any
|
|
247
|
+
) => {
|
|
248
|
+
queryClient.invalidateQueries({
|
|
249
|
+
queryKey: companyQueryKey.lists(),
|
|
250
|
+
})
|
|
251
|
+
queryClient.invalidateQueries({
|
|
252
|
+
queryKey: companyQueryKey.detail(companyId),
|
|
253
|
+
})
|
|
254
|
+
options?.onSuccess?.(data, variables, onMutateResult, context)
|
|
255
|
+
},
|
|
256
|
+
...options,
|
|
257
|
+
})
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
export const useRemoveCompanyFromCustomerGroup = (
|
|
261
|
+
companyId: string,
|
|
262
|
+
options?: UseMutationOptions<void, FetchError, string>
|
|
263
|
+
) => {
|
|
264
|
+
const queryClient = useQueryClient()
|
|
265
|
+
|
|
266
|
+
return useMutation({
|
|
267
|
+
mutationFn: (groupId: string) =>
|
|
268
|
+
sdk.client.fetch(
|
|
269
|
+
`/admin/b2b/companies/${companyId}/customer-group/${groupId}`,
|
|
270
|
+
{
|
|
271
|
+
method: "DELETE",
|
|
272
|
+
headers: {
|
|
273
|
+
Accept: "text/plain",
|
|
274
|
+
},
|
|
275
|
+
}
|
|
276
|
+
),
|
|
277
|
+
onSuccess: (_, variables: any, onMutateResult: any, context: any) => {
|
|
278
|
+
queryClient.invalidateQueries({
|
|
279
|
+
queryKey: companyQueryKey.lists(),
|
|
280
|
+
})
|
|
281
|
+
queryClient.invalidateQueries({
|
|
282
|
+
queryKey: companyQueryKey.detail(companyId),
|
|
283
|
+
})
|
|
284
|
+
options?.onSuccess?.(undefined, variables, onMutateResult, context)
|
|
285
|
+
},
|
|
286
|
+
...options,
|
|
287
|
+
})
|
|
288
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { FetchError } from "@medusajs/js-sdk"
|
|
2
|
+
import { QueryKey, useQuery, UseQueryOptions } from "@tanstack/react-query"
|
|
3
|
+
import { sdk } from "@vicacha-devs/medusa-shared-admin/admin"
|
|
4
|
+
|
|
5
|
+
export type AdminCustomerEmployee = {
|
|
6
|
+
id: string
|
|
7
|
+
spending_limit: number | null
|
|
8
|
+
is_admin: boolean
|
|
9
|
+
is_active: boolean
|
|
10
|
+
customer_id: string
|
|
11
|
+
company_id: string
|
|
12
|
+
company: {
|
|
13
|
+
id: string
|
|
14
|
+
name: string
|
|
15
|
+
currency_code: string | null
|
|
16
|
+
logo_url?: string | null
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
type CustomerEmployeeResponse = {
|
|
21
|
+
employee: AdminCustomerEmployee | null
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export const useCustomerEmployee = (
|
|
25
|
+
customerId: string,
|
|
26
|
+
options?: UseQueryOptions<
|
|
27
|
+
CustomerEmployeeResponse,
|
|
28
|
+
FetchError,
|
|
29
|
+
CustomerEmployeeResponse,
|
|
30
|
+
QueryKey
|
|
31
|
+
>
|
|
32
|
+
) => {
|
|
33
|
+
const { data, ...rest } = useQuery({
|
|
34
|
+
queryFn: () =>
|
|
35
|
+
sdk.client.fetch<CustomerEmployeeResponse>(
|
|
36
|
+
`/admin/b2b/customers/${customerId}/employee`
|
|
37
|
+
),
|
|
38
|
+
queryKey: ["customer_employee", customerId],
|
|
39
|
+
enabled: !!customerId,
|
|
40
|
+
...options,
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
return { employee: data?.employee ?? null, ...rest }
|
|
44
|
+
}
|