Skip to content

Commit 10505ad

Browse files
committed
Default value for Sales Dashboard Context
1 parent 9302b8d commit 10505ad

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/Dashboard/Sales/SalesDashboard/salesDashboardContext.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,20 @@ export interface SalesDahsboardContext {
1111
setFilter?: any
1212
}
1313

14-
const salesDashboardContext = React.createContext<SalesDahsboardContext>({})
14+
// The default context, which is used when there is no provider
15+
// (might be used for components testing)
16+
export const salesDashboardContextDefault: SalesDahsboardContext = {
17+
filter: {
18+
dateFrom: moment()
19+
.subtract(14, 'day')
20+
.startOf('day'),
21+
dateTo: moment().startOf('day'),
22+
},
23+
}
24+
25+
export const salesDashboardContext = React.createContext<SalesDahsboardContext>(
26+
salesDashboardContextDefault,
27+
)
1528

1629
export const SalesDashboardProvider = salesDashboardContext.Provider
1730
export const SalesDashboardConsumer = salesDashboardContext.Consumer

0 commit comments

Comments
 (0)