Skip to content

Commit b117ae9

Browse files
committed
feat: UI - add assign and unassign operations
1 parent 15a4f1f commit b117ae9

File tree

4 files changed

+31
-3
lines changed

4 files changed

+31
-3
lines changed

plugin-hrm-form/src/components/teamsView/SkillsColumn.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import React from 'react';
1818
import { createPortal } from 'react-dom';
1919
import { useDispatch, useSelector } from 'react-redux';
2020
import { WorkersDataTable, ColumnDefinition, Template, styled } from '@twilio/flex-ui';
21-
import { Tooltip } from '@material-ui/core';
21+
import { Divider, Tooltip } from '@material-ui/core';
2222
import { ArrowDropDown, ArrowDropUp, KeyboardArrowRight } from '@material-ui/icons';
2323

2424
import { Flex, Column, OpaqueText, Row, Box } from '../../styles';
@@ -197,6 +197,15 @@ const DropdownPortal: React.FC<{
197197
<Template code="Disable Skills" />
198198
<KeyboardArrowRight style={{ marginLeft: '20px' }} />
199199
</DropDownButton>
200+
<Divider variant="middle" />
201+
<DropDownButton onClick={onClickAction('assign')}>
202+
<Template code="Assign Skills" />
203+
<KeyboardArrowRight style={{ marginLeft: '20px' }} />
204+
</DropDownButton>
205+
<DropDownButton onClick={onClickAction('unassign')}>
206+
<Template code="Unassign Skills" />
207+
<KeyboardArrowRight style={{ marginLeft: '20px' }} />
208+
</DropDownButton>
200209
</Column>
201210
</div>,
202211
document.body,

plugin-hrm-form/src/components/teamsView/UpdateWorkersSkillsModal.tsx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,24 @@ const ConfirmUpdatesModal: React.FC<Props> = () => {
192192
.length;
193193
}
194194

195+
if (operation === 'assign') {
196+
return selectedWorkersFlexState.filter(
197+
w =>
198+
!(
199+
w.worker.attributes.routing?.skills?.includes(skill) ||
200+
w.worker.attributes.disabled_skills?.skills?.includes(skill)
201+
),
202+
).length;
203+
}
204+
205+
if (operation === 'unassign') {
206+
return selectedWorkersFlexState.filter(
207+
w =>
208+
w.worker.attributes.routing?.skills?.includes(skill) ||
209+
w.worker.attributes.disabled_skills?.skills?.includes(skill),
210+
).length;
211+
}
212+
195213
return 0;
196214
};
197215

plugin-hrm-form/src/services/twilioWorkerService.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import { getHrmConfig } from '../hrmConfig';
1818
import fetchProtectedApi from './fetchProtectedApi';
1919
import { TaskSID } from '../types/twilio';
2020
import { ApiError } from './fetchApi';
21+
import { TeamsViewState } from '../states/teamsView';
2122

2223
type PopulateCounselorsReturn = { sid: string; fullName: string }[];
2324

@@ -74,5 +75,5 @@ export const getWorkerAttributes = async (workerSid: string) => {
7475
export const updateWorkersSkills = async (payload: {
7576
workers: Array<string>;
7677
skills: Array<string>;
77-
operation: 'enable' | 'disable';
78+
operation: Required<TeamsViewState['operation']>;
7879
}) => fetchProtectedApi('/updateWorkersSkills', payload, { useTwilioLambda: true, useJsonEncode: true });

plugin-hrm-form/src/states/teamsView/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import { updateWorkersSkills } from '../../services/twilioWorkerService';
2121
export type TeamsViewState = {
2222
selectedWorkers: Set<string>;
2323
selectedSkills: Set<string>;
24-
operation?: 'enable' | 'disable';
24+
operation?: 'enable' | 'disable' | 'assign' | 'unassign';
2525
status: {
2626
loading: boolean;
2727
error: any;

0 commit comments

Comments
 (0)