Enable Retailer Context Switcher functionality
Author:
Fluent Commerce
Changed on:
30 Oct 2023
Key Points
- Retailer context switcher allows you to switch the retailer without having to log off and back in with the specific credentials. This is feasible as long as the user permissions are configured accordingly.
- The context switcher requires a few manifest modifications, which are detailed in the article below.
Steps
Step-by-step guide
Step1
Extend the fc.mystique.manifest.oms manifest with the context section:
Initial Manifest | Result |
1{
2 "manifestVersion": "2.0",
3 "name": "Oms module",
4 "title": "Fluent Order Management",
5 "homePath": "orders",
6 "orchestrationAlias": "adminconsole",
7 "context": {
8 "level": "retailer",
9 "switcher": true
10 },
11 "plugins": [
12 {
13 "type": "url",
14 "src": "/_plugins/oms"
15 }
16 ]
17}
Language: json
Name: Code Example
Description:
[Warning: empty required content area]Step2
Update the
`fc.mystique.manifest.oms.fragment.dashboard`
2.1. Extend the query with the following variable type:
`$retailerId: [Int!]`
`orders`
`returnOrders`
`retailerId: $retailerId`
2.2. Extend the query
`variables`
`"retailerId": "{{activeRetailer.id}}"`
Initial Manifest | Result |
1{
2 "type": "page",
3 "path": "dashboard",
4 "component": "fc.page",
5 "data": {
6 "query": "query ($TodayStart: DateTime!, $YesterdayStart: DateTime!, $WorkWeekStart: DateTime!, $WeekStart: DateTime!, $MonthStart: DateTime!, $orders_first:Int, $retailerId: [Int!]) { ordersToday: orders(createdOn: {from: $TodayStart},first:$orders_first, retailerId: $retailerId) { edges { node { id } } } ordersYesterday: orders(createdOn: {from: $YesterdayStart, to: $TodayStart}, first:$orders_first, retailerId: $retailerId) { edges { node { id } } } ordersWeek: orders(createdOn: {from: $WorkWeekStart}, first: $orders_first, retailerId: $retailerId) { edges { node { id } } } ordersMonth: orders(createdOn: {from: $MonthStart}, first:$orders_first, retailerId: $retailerId) { edges { node { id } } } escalations: fulfilments(status: \"ESCALATED\", createdOn: {from: $MonthStart}, first:$orders_first) { edges { node { id } } } returns : returnOrders(createdOn: {from: $MonthStart}, first:$orders_first, retailerId: $retailerId) { edges { node { id } } } cancelled: orders(status: \"CANCELLED\", updatedOn: {from: $MonthStart}, first:$orders_first, retailerId: $retailerId) { edges { node { id } } } awaitingAction: orders(status: \"PICK_PACK\", updatedOn: {to: $WeekStart}, first:$orders_first, retailerId: $retailerId) { edges { node { id } } } }",
7 "variables": {
8 "TodayStart": "{{dateStringFormatter (dateAdd hours=-24) 'YYYY-MM-DD[T]HH:mm:ss.SSS' true}}",
9 "YesterdayStart": "{{dateStringFormatter (dateAdd hours=-48) 'YYYY-MM-DD[T]HH:mm:ss.SSS' true}}",
10 "WorkWeekStart": "{{dateStringFormatter (dateAdd day=-5) 'YYYY-MM-DD[T]HH:mm:ss.SSS' true}}",
11 "WeekStart": "{{dateStringFormatter (dateAdd day=-7) 'YYYY-MM-DD[T]HH:mm:ss.SSS' true}}",
12 "MonthStart": "{{dateStringFormatter (dateAdd day=-30) 'YYYY-MM-DD[T]HH:mm:ss.SSS' true}}",
13 "orders_first": 50,
14 "retailerId": "{{activeRetailer.id}}"
15 }
16 }
17}
Language: json
Name: Code Example
Description:
[Warning: empty required content area]Step3
Update
`fc.mystique.manifest.oms.fragment.ordermanagement`
`fc.mystique.manifest.oms.fragment.ordermanagement.mixedbasket`
3.1. Extend the Orders page query with the following variable type:
`$retailerId: [Int!]`
`orders`
`retailerId: $retailerId`
3.2. Extend the query
`variables`
`"retailerId": "{{activeRetailer.id}}"`
Initial Manifest | Result |
1{
2 "type": "page",
3 "path": "orders",
4 "component": "fc.page",
5 "data": {
6 "query": "query($orders_first: Int, $retailerId: [Int!]) { orders(first: $orders_first, retailerId: $retailerId) { edges{ node { id ref retailer{id tradingName} type status retailer{id} workflowRef workflowVersion totalPrice totalTaxPrice items { edges { node { currency }}} createdOn customer{id firstName lastName }} } } }",
7 "variables": {
8 "orders_first": 100,
9 "retailerId": "{{activeRetailer.id}}"
10 }
11 }
12}
Language: json
Name: Code Example
Description:
[Warning: empty required content area]3.3. Extend the Returns page query with the following variable type:
`$retailerId: [Int!]`
`retailerId: $retailerId`
3.4. Extend the query
`variables`
`"retailerId": "{{activeRetailer.id}}"`
Initial Manifest | Result |
1{
2 "type": "page",
3 "path": "returns",
4 "component": "fc.page",
5 "data": {
6 "query": "query($returnOrders_first: Int, $retailerId: [Int!]) { returnOrders(first: $returnOrders_first, retailerId: $retailerId) { edges{ node{ id retailer{id} ref order{ref} type status createdOn returnAuthorisationKey returnAuthorisationKeyExpiry workflowRef lodgedLocation{ref}destinationLocation{ref} } } } }",
7 "variables": {
8 "returnOrders_first": 100,
9 "retailerId": "{{activeRetailer.id}}"
10 }
11 }
12}
Language: json
Name: Code Example
Description:
[Warning: empty required content area]