diff --git a/bro.config.js b/bro.config.js index 14a0e64..63d44da 100644 --- a/bro.config.js +++ b/bro.config.js @@ -21,6 +21,7 @@ module.exports = { features: { 'dry-wash-pl': { // add your features here in the format [featureName]: { value: string } + 'order-view-status-polling': { value: '3000' } }, }, config: { diff --git a/src/__data__/features.ts b/src/__data__/features.ts new file mode 100644 index 0000000..124dba0 --- /dev/null +++ b/src/__data__/features.ts @@ -0,0 +1,15 @@ +import { getFeatures } from "@brojs/cli"; + +const features = getFeatures('dry-wash-pl'); + +export const FEATURE = { + orderViewStatusPolling: { + isOn: Boolean(features['order-view-status-polling']), + getValue: () => { + const interval = parseInt(features['order-view-status-polling'].value); + if (!Number.isNaN(interval)) { + return interval; + } + } + } +}; \ No newline at end of file diff --git a/src/pages/order-view/index.tsx b/src/pages/order-view/index.tsx index 1d43ab4..a500250 100644 --- a/src/pages/order-view/index.tsx +++ b/src/pages/order-view/index.tsx @@ -20,6 +20,7 @@ import { OrderDetails } from '../../components/order-view'; import { Order } from '../../models/landing'; import { landingApi } from '../../__data__/service/landing.api'; import { ErrorMessage } from '../../models/api'; +import { FEATURE } from '../../__data__/features'; const Page: FC = () => { const { t } = useTranslation('~', { @@ -37,6 +38,12 @@ const Page: FC = () => { { orderId, }, + FEATURE.orderViewStatusPolling.isOn + ? { + pollingInterval: FEATURE.orderViewStatusPolling.getValue(), + skipPollingIfUnfocused: true, + } + : undefined, ); const errorMessage = error as ErrorMessage;