@vicacha-devs/medusa-plugin-b2b 0.0.0-stage → 0.1.0
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 +126 -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
|
@@ -0,0 +1,170 @@
|
|
|
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
|
+
AdminCreateEmployee,
|
|
13
|
+
AdminEmployeeResponse,
|
|
14
|
+
AdminEmployeesResponse,
|
|
15
|
+
AdminUpdateEmployee,
|
|
16
|
+
} from "../../../types"
|
|
17
|
+
|
|
18
|
+
export const employeeQueryKey = queryKeysFactory("employee")
|
|
19
|
+
|
|
20
|
+
export const useEmployees = (
|
|
21
|
+
companyId: string,
|
|
22
|
+
query?: Record<string, any>,
|
|
23
|
+
options?: UseQueryOptions<
|
|
24
|
+
AdminEmployeesResponse,
|
|
25
|
+
FetchError,
|
|
26
|
+
AdminEmployeesResponse,
|
|
27
|
+
QueryKey
|
|
28
|
+
>
|
|
29
|
+
) => {
|
|
30
|
+
const { fields: _fields, ...safeQuery } = (query ?? {}) as any
|
|
31
|
+
|
|
32
|
+
return useQuery({
|
|
33
|
+
queryKey: employeeQueryKey.list({ companyId, ...safeQuery }),
|
|
34
|
+
queryFn: () =>
|
|
35
|
+
sdk.client.fetch<AdminEmployeesResponse>(
|
|
36
|
+
`/admin/b2b/companies/${companyId}/employees`,
|
|
37
|
+
{ method: "GET", query: safeQuery }
|
|
38
|
+
),
|
|
39
|
+
...options,
|
|
40
|
+
})
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export const useEmployee = (
|
|
44
|
+
companyId: string,
|
|
45
|
+
employeeId: string,
|
|
46
|
+
options?: UseQueryOptions<
|
|
47
|
+
AdminEmployeeResponse,
|
|
48
|
+
FetchError,
|
|
49
|
+
AdminEmployeeResponse,
|
|
50
|
+
QueryKey
|
|
51
|
+
>
|
|
52
|
+
) => {
|
|
53
|
+
return useQuery({
|
|
54
|
+
queryKey: employeeQueryKey.detail(employeeId),
|
|
55
|
+
queryFn: () =>
|
|
56
|
+
sdk.client.fetch<AdminEmployeeResponse>(
|
|
57
|
+
`/admin/b2b/companies/${companyId}/employees/${employeeId}`,
|
|
58
|
+
{ method: "GET" }
|
|
59
|
+
),
|
|
60
|
+
enabled: !!companyId && !!employeeId,
|
|
61
|
+
...options,
|
|
62
|
+
})
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export const useCreateEmployee = (
|
|
66
|
+
companyId: string,
|
|
67
|
+
options?: UseMutationOptions<
|
|
68
|
+
AdminEmployeeResponse,
|
|
69
|
+
FetchError,
|
|
70
|
+
AdminCreateEmployee
|
|
71
|
+
>
|
|
72
|
+
) => {
|
|
73
|
+
const queryClient = useQueryClient()
|
|
74
|
+
|
|
75
|
+
return useMutation({
|
|
76
|
+
mutationFn: (employee: AdminCreateEmployee) =>
|
|
77
|
+
sdk.client.fetch<AdminEmployeeResponse>(
|
|
78
|
+
`/admin/b2b/companies/${companyId}/employees`,
|
|
79
|
+
{
|
|
80
|
+
method: "POST",
|
|
81
|
+
headers: {
|
|
82
|
+
"Content-Type": "application/json",
|
|
83
|
+
},
|
|
84
|
+
body: employee,
|
|
85
|
+
}
|
|
86
|
+
),
|
|
87
|
+
onSuccess: (
|
|
88
|
+
data: any,
|
|
89
|
+
variables: any,
|
|
90
|
+
onMutateResult: any,
|
|
91
|
+
context: any
|
|
92
|
+
) => {
|
|
93
|
+
queryClient.invalidateQueries({
|
|
94
|
+
queryKey: employeeQueryKey.lists(),
|
|
95
|
+
})
|
|
96
|
+
options?.onSuccess?.(data, variables, onMutateResult, context)
|
|
97
|
+
},
|
|
98
|
+
...options,
|
|
99
|
+
})
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export const useUpdateEmployee = (
|
|
103
|
+
companyId: string,
|
|
104
|
+
employeeId: string,
|
|
105
|
+
options?: UseMutationOptions<
|
|
106
|
+
AdminEmployeeResponse,
|
|
107
|
+
FetchError,
|
|
108
|
+
AdminUpdateEmployee
|
|
109
|
+
>
|
|
110
|
+
) => {
|
|
111
|
+
const queryClient = useQueryClient()
|
|
112
|
+
|
|
113
|
+
return useMutation({
|
|
114
|
+
mutationFn: (employee: AdminUpdateEmployee) =>
|
|
115
|
+
sdk.client.fetch<AdminEmployeeResponse>(
|
|
116
|
+
`/admin/b2b/companies/${companyId}/employees/${employeeId}`,
|
|
117
|
+
{
|
|
118
|
+
method: "POST",
|
|
119
|
+
headers: {
|
|
120
|
+
"Content-Type": "application/json",
|
|
121
|
+
},
|
|
122
|
+
body: employee,
|
|
123
|
+
}
|
|
124
|
+
),
|
|
125
|
+
onSuccess: (
|
|
126
|
+
data: any,
|
|
127
|
+
variables: any,
|
|
128
|
+
onMutateResult: any,
|
|
129
|
+
context: any
|
|
130
|
+
) => {
|
|
131
|
+
queryClient.invalidateQueries({
|
|
132
|
+
queryKey: employeeQueryKey.detail(employeeId),
|
|
133
|
+
})
|
|
134
|
+
queryClient.invalidateQueries({
|
|
135
|
+
queryKey: employeeQueryKey.lists(),
|
|
136
|
+
})
|
|
137
|
+
options?.onSuccess?.(data, variables, onMutateResult, context)
|
|
138
|
+
},
|
|
139
|
+
...options,
|
|
140
|
+
})
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export const useDeleteEmployee = (
|
|
144
|
+
companyId: string,
|
|
145
|
+
options?: UseMutationOptions<void, FetchError, string>
|
|
146
|
+
) => {
|
|
147
|
+
const queryClient = useQueryClient()
|
|
148
|
+
|
|
149
|
+
return useMutation({
|
|
150
|
+
mutationFn: (employeeId: string) =>
|
|
151
|
+
sdk.client.fetch<void>(
|
|
152
|
+
`/admin/b2b/companies/${companyId}/employees/${employeeId}`,
|
|
153
|
+
{
|
|
154
|
+
method: "DELETE",
|
|
155
|
+
}
|
|
156
|
+
),
|
|
157
|
+
onSuccess: (
|
|
158
|
+
data: any,
|
|
159
|
+
variables: any,
|
|
160
|
+
onMutateResult: any,
|
|
161
|
+
context: any
|
|
162
|
+
) => {
|
|
163
|
+
queryClient.invalidateQueries({
|
|
164
|
+
queryKey: employeeQueryKey.lists(),
|
|
165
|
+
})
|
|
166
|
+
options?.onSuccess?.(data, variables, onMutateResult, context)
|
|
167
|
+
},
|
|
168
|
+
...options,
|
|
169
|
+
})
|
|
170
|
+
}
|
|
@@ -0,0 +1,329 @@
|
|
|
1
|
+
import { HttpTypes } from "@medusajs/framework/types"
|
|
2
|
+
import { ClientHeaders, FetchError } from "@medusajs/js-sdk"
|
|
3
|
+
import {
|
|
4
|
+
QueryKey,
|
|
5
|
+
useMutation,
|
|
6
|
+
UseMutationOptions,
|
|
7
|
+
useQuery,
|
|
8
|
+
useQueryClient,
|
|
9
|
+
UseQueryOptions,
|
|
10
|
+
} from "@tanstack/react-query"
|
|
11
|
+
import { ordersQueryKeys } from "@medusajs/dashboard/hooks"
|
|
12
|
+
import { queryKeysFactory, sdk } from "@vicacha-devs/medusa-shared-admin/admin"
|
|
13
|
+
import {
|
|
14
|
+
AdminCreateQuoteMessage,
|
|
15
|
+
AdminQuoteResponse,
|
|
16
|
+
QuoteFilterParams,
|
|
17
|
+
StoreQuoteResponse,
|
|
18
|
+
StoreQuotesResponse,
|
|
19
|
+
} from "../../../types"
|
|
20
|
+
|
|
21
|
+
export const orderPreviewQueryKey = queryKeysFactory("custom_orders")
|
|
22
|
+
export const quoteQueryKey = queryKeysFactory("quote")
|
|
23
|
+
|
|
24
|
+
export const useQuotes = (
|
|
25
|
+
query: QuoteFilterParams,
|
|
26
|
+
options?: UseQueryOptions<
|
|
27
|
+
StoreQuotesResponse,
|
|
28
|
+
FetchError,
|
|
29
|
+
StoreQuotesResponse,
|
|
30
|
+
QueryKey
|
|
31
|
+
>
|
|
32
|
+
) => {
|
|
33
|
+
const fetchQuotes = (query: QuoteFilterParams, headers?: ClientHeaders) =>
|
|
34
|
+
sdk.client.fetch<StoreQuotesResponse>(`/admin/b2b/quotes`, {
|
|
35
|
+
query,
|
|
36
|
+
headers,
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
const { data, ...rest } = useQuery({
|
|
40
|
+
...options,
|
|
41
|
+
queryFn: () => fetchQuotes(query)!,
|
|
42
|
+
queryKey: quoteQueryKey.list(query),
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
return { ...data, ...rest }
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export const useQuote = (
|
|
49
|
+
id: string,
|
|
50
|
+
query?: QuoteFilterParams,
|
|
51
|
+
options?: UseQueryOptions<
|
|
52
|
+
StoreQuoteResponse,
|
|
53
|
+
FetchError,
|
|
54
|
+
StoreQuoteResponse,
|
|
55
|
+
QueryKey
|
|
56
|
+
>
|
|
57
|
+
) => {
|
|
58
|
+
const fetchQuote = (
|
|
59
|
+
id: string,
|
|
60
|
+
query?: QuoteFilterParams,
|
|
61
|
+
headers?: ClientHeaders
|
|
62
|
+
) =>
|
|
63
|
+
sdk.client.fetch<StoreQuoteResponse>(`/admin/b2b/quotes/${id}`, {
|
|
64
|
+
query,
|
|
65
|
+
headers,
|
|
66
|
+
})
|
|
67
|
+
|
|
68
|
+
const { data, ...rest } = useQuery({
|
|
69
|
+
queryFn: () => fetchQuote(id, query),
|
|
70
|
+
queryKey: quoteQueryKey.detail(id),
|
|
71
|
+
...options,
|
|
72
|
+
})
|
|
73
|
+
|
|
74
|
+
return { ...data, ...rest }
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export const useAddItemsToQuote = (
|
|
78
|
+
id: string,
|
|
79
|
+
options?: UseMutationOptions<
|
|
80
|
+
HttpTypes.AdminOrderEditPreviewResponse,
|
|
81
|
+
FetchError,
|
|
82
|
+
HttpTypes.AdminAddOrderEditItems
|
|
83
|
+
>
|
|
84
|
+
) => {
|
|
85
|
+
const queryClient = useQueryClient()
|
|
86
|
+
|
|
87
|
+
return useMutation({
|
|
88
|
+
...options,
|
|
89
|
+
mutationFn: (payload: HttpTypes.AdminAddOrderEditItems) =>
|
|
90
|
+
sdk.admin.orderEdit.addItems(id, payload),
|
|
91
|
+
onSuccess: (
|
|
92
|
+
data: any,
|
|
93
|
+
variables: any,
|
|
94
|
+
onMutateResult: any,
|
|
95
|
+
context: any
|
|
96
|
+
) => {
|
|
97
|
+
queryClient.invalidateQueries({
|
|
98
|
+
queryKey: orderPreviewQueryKey.detail(id),
|
|
99
|
+
})
|
|
100
|
+
queryClient.invalidateQueries({ queryKey: ordersQueryKeys.preview(id) })
|
|
101
|
+
options?.onSuccess?.(data, variables, onMutateResult, context)
|
|
102
|
+
},
|
|
103
|
+
})
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export const useUpdateQuoteItem = (
|
|
107
|
+
id: string,
|
|
108
|
+
options?: UseMutationOptions<
|
|
109
|
+
HttpTypes.AdminOrderEditPreviewResponse,
|
|
110
|
+
FetchError,
|
|
111
|
+
HttpTypes.AdminUpdateOrderEditItem & { itemId: string }
|
|
112
|
+
>
|
|
113
|
+
) => {
|
|
114
|
+
const queryClient = useQueryClient()
|
|
115
|
+
|
|
116
|
+
return useMutation({
|
|
117
|
+
...options,
|
|
118
|
+
mutationFn: ({
|
|
119
|
+
itemId,
|
|
120
|
+
...payload
|
|
121
|
+
}: HttpTypes.AdminUpdateOrderEditItem & { itemId: string }) => {
|
|
122
|
+
return sdk.admin.orderEdit.updateOriginalItem(id, itemId, payload)
|
|
123
|
+
},
|
|
124
|
+
onSuccess: (
|
|
125
|
+
data: any,
|
|
126
|
+
variables: any,
|
|
127
|
+
onMutateResult: any,
|
|
128
|
+
context: any
|
|
129
|
+
) => {
|
|
130
|
+
queryClient.invalidateQueries({
|
|
131
|
+
queryKey: orderPreviewQueryKey.detail(id),
|
|
132
|
+
})
|
|
133
|
+
queryClient.invalidateQueries({ queryKey: ordersQueryKeys.preview(id) })
|
|
134
|
+
options?.onSuccess?.(data, variables, onMutateResult, context)
|
|
135
|
+
},
|
|
136
|
+
})
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export const useRemoveQuoteItem = (
|
|
140
|
+
id: string,
|
|
141
|
+
options?: UseMutationOptions<
|
|
142
|
+
HttpTypes.AdminOrderEditPreviewResponse,
|
|
143
|
+
FetchError,
|
|
144
|
+
string
|
|
145
|
+
>
|
|
146
|
+
) => {
|
|
147
|
+
const queryClient = useQueryClient()
|
|
148
|
+
|
|
149
|
+
return useMutation({
|
|
150
|
+
...options,
|
|
151
|
+
mutationFn: (actionId: string) =>
|
|
152
|
+
sdk.admin.orderEdit.removeAddedItem(id, actionId),
|
|
153
|
+
onSuccess: (
|
|
154
|
+
data: any,
|
|
155
|
+
variables: any,
|
|
156
|
+
onMutateResult: any,
|
|
157
|
+
context: any
|
|
158
|
+
) => {
|
|
159
|
+
queryClient.invalidateQueries({
|
|
160
|
+
queryKey: orderPreviewQueryKey.detail(id),
|
|
161
|
+
})
|
|
162
|
+
queryClient.invalidateQueries({ queryKey: ordersQueryKeys.preview(id) })
|
|
163
|
+
options?.onSuccess?.(data, variables, onMutateResult, context)
|
|
164
|
+
},
|
|
165
|
+
})
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
export const useUpdateAddedQuoteItem = (
|
|
169
|
+
id: string,
|
|
170
|
+
options?: UseMutationOptions<
|
|
171
|
+
HttpTypes.AdminOrderEditPreviewResponse,
|
|
172
|
+
FetchError,
|
|
173
|
+
HttpTypes.AdminUpdateOrderEditItem & { actionId: string }
|
|
174
|
+
>
|
|
175
|
+
) => {
|
|
176
|
+
const queryClient = useQueryClient()
|
|
177
|
+
|
|
178
|
+
return useMutation({
|
|
179
|
+
...options,
|
|
180
|
+
mutationFn: ({
|
|
181
|
+
actionId,
|
|
182
|
+
...payload
|
|
183
|
+
}: HttpTypes.AdminUpdateOrderEditItem & { actionId: string }) => {
|
|
184
|
+
return sdk.admin.orderEdit.updateAddedItem(id, actionId, payload)
|
|
185
|
+
},
|
|
186
|
+
onSuccess: (
|
|
187
|
+
data: any,
|
|
188
|
+
variables: any,
|
|
189
|
+
onMutateResult: any,
|
|
190
|
+
context: any
|
|
191
|
+
) => {
|
|
192
|
+
queryClient.invalidateQueries({
|
|
193
|
+
queryKey: orderPreviewQueryKey.detail(id),
|
|
194
|
+
})
|
|
195
|
+
queryClient.invalidateQueries({ queryKey: ordersQueryKeys.preview(id) })
|
|
196
|
+
options?.onSuccess?.(data, variables, onMutateResult, context)
|
|
197
|
+
},
|
|
198
|
+
})
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
export const useConfirmQuote = (
|
|
202
|
+
id: string,
|
|
203
|
+
options?: UseMutationOptions<
|
|
204
|
+
HttpTypes.AdminOrderEditPreviewResponse,
|
|
205
|
+
FetchError,
|
|
206
|
+
void
|
|
207
|
+
>
|
|
208
|
+
) => {
|
|
209
|
+
const queryClient = useQueryClient()
|
|
210
|
+
|
|
211
|
+
return useMutation({
|
|
212
|
+
...options,
|
|
213
|
+
mutationFn: () => sdk.admin.orderEdit.request(id),
|
|
214
|
+
onSuccess: (
|
|
215
|
+
data: any,
|
|
216
|
+
variables: any,
|
|
217
|
+
onMutateResult: any,
|
|
218
|
+
context: any
|
|
219
|
+
) => {
|
|
220
|
+
queryClient.invalidateQueries({
|
|
221
|
+
queryKey: orderPreviewQueryKey.details(),
|
|
222
|
+
})
|
|
223
|
+
queryClient.invalidateQueries({ queryKey: ordersQueryKeys.details() })
|
|
224
|
+
queryClient.invalidateQueries({ queryKey: quoteQueryKey.details() })
|
|
225
|
+
queryClient.invalidateQueries({ queryKey: quoteQueryKey.lists() })
|
|
226
|
+
options?.onSuccess?.(data, variables, onMutateResult, context)
|
|
227
|
+
},
|
|
228
|
+
})
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
export const useSendQuote = (
|
|
232
|
+
id: string,
|
|
233
|
+
options?: UseMutationOptions<
|
|
234
|
+
AdminQuoteResponse,
|
|
235
|
+
FetchError,
|
|
236
|
+
{ expires_at?: string | null }
|
|
237
|
+
>
|
|
238
|
+
) => {
|
|
239
|
+
const queryClient = useQueryClient()
|
|
240
|
+
|
|
241
|
+
return useMutation({
|
|
242
|
+
...options,
|
|
243
|
+
mutationFn: (body: { expires_at?: string | null } = {}) =>
|
|
244
|
+
sdk.client.fetch<AdminQuoteResponse>(`/admin/b2b/quotes/${id}/send`, {
|
|
245
|
+
method: "POST",
|
|
246
|
+
body,
|
|
247
|
+
}),
|
|
248
|
+
onSuccess: (
|
|
249
|
+
data: any,
|
|
250
|
+
variables: any,
|
|
251
|
+
onMutateResult: any,
|
|
252
|
+
context: any
|
|
253
|
+
) => {
|
|
254
|
+
queryClient.invalidateQueries({
|
|
255
|
+
queryKey: orderPreviewQueryKey.details(),
|
|
256
|
+
})
|
|
257
|
+
queryClient.invalidateQueries({
|
|
258
|
+
queryKey: quoteQueryKey.detail(id),
|
|
259
|
+
})
|
|
260
|
+
queryClient.invalidateQueries({
|
|
261
|
+
queryKey: quoteQueryKey.lists(),
|
|
262
|
+
})
|
|
263
|
+
options?.onSuccess?.(data, variables, onMutateResult, context)
|
|
264
|
+
},
|
|
265
|
+
})
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
export const useRejectQuote = (
|
|
269
|
+
id: string,
|
|
270
|
+
options?: UseMutationOptions<AdminQuoteResponse, FetchError, void>
|
|
271
|
+
) => {
|
|
272
|
+
const queryClient = useQueryClient()
|
|
273
|
+
|
|
274
|
+
return useMutation({
|
|
275
|
+
...options,
|
|
276
|
+
mutationFn: () =>
|
|
277
|
+
sdk.client.fetch<AdminQuoteResponse>(`/admin/b2b/quotes/${id}/reject`, {
|
|
278
|
+
method: "POST",
|
|
279
|
+
}),
|
|
280
|
+
onSuccess: (
|
|
281
|
+
data: AdminQuoteResponse,
|
|
282
|
+
variables: any,
|
|
283
|
+
onMutateResult: any,
|
|
284
|
+
context: any
|
|
285
|
+
) => {
|
|
286
|
+
queryClient.invalidateQueries({
|
|
287
|
+
queryKey: orderPreviewQueryKey.details(),
|
|
288
|
+
})
|
|
289
|
+
queryClient.invalidateQueries({
|
|
290
|
+
queryKey: quoteQueryKey.detail(id),
|
|
291
|
+
})
|
|
292
|
+
queryClient.invalidateQueries({
|
|
293
|
+
queryKey: quoteQueryKey.lists(),
|
|
294
|
+
})
|
|
295
|
+
options?.onSuccess?.(data, variables, onMutateResult, context)
|
|
296
|
+
},
|
|
297
|
+
})
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
export const useCreateQuoteMessage = (
|
|
301
|
+
id: string,
|
|
302
|
+
options?: UseMutationOptions<
|
|
303
|
+
AdminQuoteResponse,
|
|
304
|
+
FetchError,
|
|
305
|
+
AdminCreateQuoteMessage
|
|
306
|
+
>
|
|
307
|
+
) => {
|
|
308
|
+
const queryClient = useQueryClient()
|
|
309
|
+
|
|
310
|
+
return useMutation({
|
|
311
|
+
...options,
|
|
312
|
+
mutationFn: (body: AdminCreateQuoteMessage) =>
|
|
313
|
+
sdk.client.fetch<AdminQuoteResponse>(`/admin/b2b/quotes/${id}/messages`, {
|
|
314
|
+
body,
|
|
315
|
+
method: "POST",
|
|
316
|
+
}),
|
|
317
|
+
onSuccess: (
|
|
318
|
+
data: AdminQuoteResponse,
|
|
319
|
+
variables: any,
|
|
320
|
+
onMutateResult: any,
|
|
321
|
+
context: any
|
|
322
|
+
) => {
|
|
323
|
+
queryClient.invalidateQueries({
|
|
324
|
+
queryKey: quoteQueryKey.details(),
|
|
325
|
+
})
|
|
326
|
+
options?.onSuccess?.(data, variables, onMutateResult, context)
|
|
327
|
+
},
|
|
328
|
+
})
|
|
329
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# i18n
|
|
2
|
+
|
|
3
|
+
Internationalisation setup for the B2B admin extension using [react-i18next](https://react.i18next.com/).
|
|
4
|
+
|
|
5
|
+
```
|
|
6
|
+
i18n/
|
|
7
|
+
├── index.ts initialises i18next and exports the translation map
|
|
8
|
+
└── json/ one JSON file per locale
|
|
9
|
+
└── en.json English (default)
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## Adding a translation key
|
|
15
|
+
|
|
16
|
+
1. Add the key to `json/en.json` (and to any other locale files that already exist).
|
|
17
|
+
2. Use it in any admin component via the `useTranslation` hook:
|
|
18
|
+
|
|
19
|
+
```tsx
|
|
20
|
+
import { useTranslation } from "react-i18next"
|
|
21
|
+
|
|
22
|
+
const MyComponent = () => {
|
|
23
|
+
const { t } = useTranslation()
|
|
24
|
+
return <span>{t("companies.title")}</span>
|
|
25
|
+
}
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Adding a new locale
|
|
29
|
+
|
|
30
|
+
1. Create `json/<locale>.json` with the same key structure as `en.json`.
|
|
31
|
+
2. Import it in `index.ts` and add it to the exported map:
|
|
32
|
+
|
|
33
|
+
```ts
|
|
34
|
+
import en from "./json/en.json" with { type: "json" }
|
|
35
|
+
import es from "./json/es.json" with { type: "json" }
|
|
36
|
+
|
|
37
|
+
export default {
|
|
38
|
+
en: { translation: en },
|
|
39
|
+
es: { translation: es },
|
|
40
|
+
}
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
3. Medusa's admin shell picks up the additional locale automatically — no further registration is required.
|
|
44
|
+
|
|
45
|
+
## Planned locales
|
|
46
|
+
|
|
47
|
+
The roadmap targets `en`, `es`, `tr`, and `ar`. Arabic (`ar`) requires RTL layout support — test layout direction when adding it.
|
|
48
|
+
|
|
49
|
+
## Key structure
|
|
50
|
+
|
|
51
|
+
Keys are organised by domain, not by component, so that related strings stay together regardless of where they are rendered:
|
|
52
|
+
|
|
53
|
+
```json
|
|
54
|
+
{
|
|
55
|
+
"companies": {
|
|
56
|
+
"title": "Companies",
|
|
57
|
+
"empty": "No companies yet",
|
|
58
|
+
"create": "Create company"
|
|
59
|
+
},
|
|
60
|
+
"employees": {
|
|
61
|
+
"title": "Employees",
|
|
62
|
+
"spending_limit": "Spending limit"
|
|
63
|
+
},
|
|
64
|
+
"quotes": {
|
|
65
|
+
"title": "Quotes",
|
|
66
|
+
"status": {
|
|
67
|
+
"pending_merchant": "Pending review",
|
|
68
|
+
"pending_customer": "Pending customer",
|
|
69
|
+
"accepted": "Accepted",
|
|
70
|
+
"customer_rejected": "Rejected by customer",
|
|
71
|
+
"merchant_rejected": "Rejected"
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
"approvals": {
|
|
75
|
+
"title": "Approvals"
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
```
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import ar from "./json/ar.json"
|
|
2
|
+
import de from "./json/de.json"
|
|
3
|
+
import en from "./json/en.json"
|
|
4
|
+
import es from "./json/es.json"
|
|
5
|
+
import fr from "./json/fr.json"
|
|
6
|
+
import it from "./json/it.json"
|
|
7
|
+
import nl from "./json/nl.json"
|
|
8
|
+
import pl from "./json/pl.json"
|
|
9
|
+
import pt from "./json/pt.json"
|
|
10
|
+
import tr from "./json/tr.json"
|
|
11
|
+
|
|
12
|
+
export default {
|
|
13
|
+
ar: { translation: ar },
|
|
14
|
+
de: { translation: de },
|
|
15
|
+
en: { translation: en },
|
|
16
|
+
es: { translation: es },
|
|
17
|
+
fr: { translation: fr },
|
|
18
|
+
it: { translation: it },
|
|
19
|
+
nl: { translation: nl },
|
|
20
|
+
pl: { translation: pl },
|
|
21
|
+
pt: { translation: pt },
|
|
22
|
+
tr: { translation: tr },
|
|
23
|
+
}
|