Skip to content

Commit

Permalink
[NEW] Ability for RC server to check the business hour for a specific…
Browse files Browse the repository at this point in the history
… department
  • Loading branch information
murtaza98 committed May 9, 2022
1 parent 72100e8 commit a3d5c2f
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
8 changes: 6 additions & 2 deletions packages/livechat/src/lib/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,17 @@ const api = {
});
},

setDepartment(value) {
const { config: { departments = [] } } = store.state;
async setDepartment(value) {
const { config: { departments = [] }, department: existingDepartment } = store.state;

const dept = departments.find((dep) => dep._id === value || dep.name === value);
const department = (dept && dept._id) || '';

updateIframeGuestData({ department });

if (department !== existingDepartment) {
await loadConfig();
}
},

async setBusinessUnit(newBusinessUnit) {
Expand Down
2 changes: 2 additions & 0 deletions packages/livechat/src/lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export const loadConfig = async () => {
const {
token,
businessUnit = null,
guest: { department } = {},
} = store.state;

Livechat.credentials.token = token;
Expand All @@ -56,6 +57,7 @@ export const loadConfig = async () => {
} = await Livechat.config({
token,
...businessUnit && { businessUnit },
...department && { department },
});

await store.setState({
Expand Down
5 changes: 3 additions & 2 deletions packages/livechat/src/routes/SwitchDepartment/connector.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ const SwitchDepartmentConnector = ({ ref, ...props }) => (
fontColor: customFontColor,
iconColor: customIconColor,
} = {},
guest,
} = {},
room,
loading = false,
department,
dispatch,
alerts,
token,
Expand All @@ -33,7 +33,8 @@ const SwitchDepartmentConnector = ({ ref, ...props }) => (
iconColor: customIconColor,
}}
loading={loading}
departments={departments.filter((dept) => dept.showOnRegistration && dept._id !== department)}
guest={guest}
departments={departments.filter((dept) => dept.showOnRegistration && dept._id !== guest?.department)}
dispatch={dispatch}
room={room}
alerts={alerts}
Expand Down
4 changes: 2 additions & 2 deletions packages/livechat/src/routes/SwitchDepartment/container.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class SwitchDepartmentContainer extends Component {
}

handleSubmit = async (fields) => {
const { alerts, dispatch, room, token, t } = this.props;
const { alerts, dispatch, room, token, t, guest } = this.props;
const { department } = fields;

const confirm = await this.confirmChangeDepartment();
Expand All @@ -42,7 +42,7 @@ class SwitchDepartmentContainer extends Component {
throw t('no_available_agents_to_transfer');
}

await dispatch({ department, loading: false });
await dispatch({ guest: { ...guest, department }, loading: false });
await loadConfig();

await ModalManager.alert({
Expand Down

0 comments on commit a3d5c2f

Please sign in to comment.