Skip to content

Commit

Permalink
fix(admin): make shipping methods input optional to avoid error (#220)
Browse files Browse the repository at this point in the history
  • Loading branch information
EdieLemoine authored Oct 16, 2024
1 parent ef94d82 commit 2f72250
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ exports[`exports > exports from index.ts 1`] = `
"modalSubmitFormAction",
"openOrPrintPdf",
"optionalAdminActionContainerComponentNames",
"optionalAdminComponentNames",
"optionalAdminPlainWrapperComponentNames",
"orderExportAction",
"orderExportToShipmentsAction",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ exports[`exports > exports from index.ts 1`] = `
"modalSubmitFormAction",
"openOrPrintPdf",
"optionalAdminActionContainerComponentNames",
"optionalAdminComponentNames",
"optionalAdminPlainWrapperComponentNames",
"orderExportAction",
"orderExportToShipmentsAction",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ exports[`exports > exports from index.ts 1`] = `
"modalSubmitFormAction",
"openOrPrintPdf",
"optionalAdminActionContainerComponentNames",
"optionalAdminComponentNames",
"optionalAdminPlainWrapperComponentNames",
"orderExportAction",
"orderExportToShipmentsAction",
Expand Down
4 changes: 3 additions & 1 deletion apps/admin/src/data/components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ export const requiredAdminComponentNames = [
AdminComponent.RadioInput,
AdminComponent.Row,
AdminComponent.SelectInput,
AdminComponent.ShippingMethodsInput,
AdminComponent.TabNavButton,
AdminComponent.Table,
AdminComponent.TextArea,
Expand All @@ -76,6 +75,8 @@ export const requiredAdminComponentNames = [
AdminComponent.TriStateInput,
] as const;

export const optionalAdminComponentNames = [AdminComponent.ShippingMethodsInput] as const;

export const optionalAdminPlainWrapperComponentNames = [
AdminComponent.Badge,
AdminComponent.ButtonGroup,
Expand All @@ -94,6 +95,7 @@ export const optionalAdminActionContainerComponentNames = [

export const allAdminComponentNames = [
...requiredAdminComponentNames,
...optionalAdminComponentNames,
...optionalAdminPlainWrapperComponentNames,
...optionalAdminActionContainerComponentNames,
] as const;
3 changes: 1 addition & 2 deletions apps/admin/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,8 @@ export {
NotificationCategory,
allAdminComponentNames,
optionalAdminActionContainerComponentNames,
optionalAdminComponentNames,
optionalAdminPlainWrapperComponentNames,

/** @deprecated use TriState */
requiredAdminComponentNames,
} from './data';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {type AdminComponentMap, type PrefixedAdminComponent} from '../../../type
import {
AdminComponent,
optionalAdminActionContainerComponentNames,
optionalAdminComponentNames,
optionalAdminPlainWrapperComponentNames,
requiredAdminComponentNames,
} from '../../../data';
Expand All @@ -27,6 +28,7 @@ const getOptionalComponents = (app: App): Record<string, Component | AdminCompon
};

return {
...createComponentMap(optionalAdminComponentNames, PlainElement),
...createComponentMap(optionalAdminPlainWrapperComponentNames, PlainElement),
...createComponentMap(optionalAdminActionContainerComponentNames, AdminComponent.Box),
};
Expand All @@ -47,13 +49,7 @@ export const createRegisterComponentsPlugin: PdkAppPlugin = ({config, logger}) =
);

const requiredComponents = {
...requiredAdminComponentNames.reduce(
(acc, name) => ({
...acc,
[name]: null,
}),
{},
),
...requiredAdminComponentNames.reduce((acc, name) => ({...acc, [name]: null}), {}),
...componentsFromConfig,
};

Expand Down
2 changes: 2 additions & 0 deletions apps/admin/src/types/admin.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
type AdminComponent,
type AdminView,
type optionalAdminActionContainerComponentNames,
type optionalAdminComponentNames,
type optionalAdminPlainWrapperComponentNames,
type requiredAdminComponentNames,
} from '../data';
Expand All @@ -14,6 +15,7 @@ import {type AdminConfiguration} from './configuration.types';
export type RequiredAdminComponentName = (typeof requiredAdminComponentNames)[number];

export type OptionalAdminComponentName =
| (typeof optionalAdminComponentNames)[number]
| (typeof optionalAdminPlainWrapperComponentNames)[number]
| (typeof optionalAdminActionContainerComponentNames)[number];

Expand Down

0 comments on commit 2f72250

Please sign in to comment.