Skip to content

Commit

Permalink
Update styling
Browse files Browse the repository at this point in the history
  • Loading branch information
ldvlgr committed Oct 17, 2023
1 parent 7c979ac commit b5e30a9
Show file tree
Hide file tree
Showing 11 changed files with 53 additions and 18 deletions.
1 change: 1 addition & 0 deletions flex-config/ui_attributes.common.json
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,7 @@
"edit_department": true,
"edit_location": true,
"edit_manager": false,
"edit_schedule": true,
"edit_unit_leader": true,
"edit_coach": true
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const {
edit_department = true,
edit_location = true,
edit_manager = false,
edit_schedule = true,
edit_unit_leader = true,
edit_coach = true,
} = (getFeatureFlags()?.features?.worker_details as WorkerDetailsConfig) || {};
Expand All @@ -28,6 +29,9 @@ export const editLocation = () => {
export const editManager = () => {
return edit_manager;
};
export const editSchedule = () => {
return edit_schedule;
};
export const editUnitLeader = () => {
return edit_unit_leader;
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,33 +1,29 @@
import { Template, templates } from '@twilio/flex-ui';
import { Label } from '@twilio-paste/core/label';
import { Tr, Td } from '@twilio-paste/core/table';
import { Switch } from '@twilio-paste/core/switch';

import { stringPrefix } from '../../flex-hooks/strings';

interface OwnProps {
id: string;
label: string;
description: string;
value: boolean;
enabled: boolean;
onChangeHandler: (value: boolean) => void;
}

const AttributeBoolean = (props: OwnProps) => {
const { id, label, value, enabled, onChangeHandler } = props;
const { id, label, description, value, enabled, onChangeHandler } = props;
const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
const value = e.target.checked;
onChangeHandler(value);
};

return (
<Tr key={id}>
<Td>
<Label htmlFor={id}>
<Template source={templates[`${stringPrefix}${label}`]} />
</Label>
<Td element="WORKER_DETAILS">
<Label htmlFor={id}>{description}</Label>
</Td>
<Td>
<Td element="WORKER_DETAILS">
<Switch checked={value} onChange={handleChange} disabled={!enabled} id={id} name={label}>
{label}
</Switch>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ interface OwnProps {
const AttributeDisplay = ({ id, label, value }: OwnProps) => {
return (
<Tr key={id}>
<Td>
<Td element="WORKER_DETAILS">
<Label htmlFor={id}>
<Template source={templates[`${stringPrefix}${label}`]} />
</Label>
</Td>
<Td>{value}</Td>
<Td element="WORKER_DETAILS">{value}</Td>
</Tr>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ const AttributeSelect = ({ id, label, value, options, onChangeHandler }: OwnProp

return (
<Tr key={id}>
<Th scope="row">
<Th scope="row" element="WORKER_DETAILS">
<Label htmlFor={id}>
<Template source={templates[`${stringPrefix}${label}`]} />
</Label>
</Th>
<Td>
<Td element="WORKER_DETAILS">
<Select value={value} onChange={handleChange} id={id}>
<Option key="none" value="none">
Select {label}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ const AttributeText = ({ id, label, value, onChangeHandler }: OwnProps) => {

return (
<Tr key={id}>
<Td>
<Td element="WORKER_DETAILS">
<Label htmlFor={id}>
<Template source={templates[`${stringPrefix}${label}`]} />
</Label>
</Td>
<Td>
<Td element="WORKER_DETAILS">
<Input type="text" id={id} value={value} onChange={handleChange} />
</Td>
</Tr>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,15 @@ import {
editManager,
editUnitLeader,
editCoach,
editSchedule,
} from '../../config';
import AttributeText from './AttributeText';
import AttributeSelect from './AttributeSelect';
import AttributeDisplay from './AttributeDisplay';
import AttributeBoolean from './AttributeBoolean';

const shiftOptions = ['Early', 'Regular', 'Late', 'Night'];

interface OwnProps {
worker: IWorker;
}
Expand All @@ -34,6 +37,7 @@ const WorkerDetailsContainer = ({ worker }: OwnProps) => {
const [manager, setManager] = useState('');
const [unitLeader, setUnitLeader] = useState(false);
const [coach, setCoach] = useState(false);
const [schedule, setSchedule] = useState('');

useEffect(() => {
if (worker) {
Expand All @@ -43,6 +47,7 @@ const WorkerDetailsContainer = ({ worker }: OwnProps) => {
setManager(worker.attributes.manager || '');
setUnitLeader(worker.attributes.unit_leader || false);
setCoach(worker.attributes.coach || false);
setSchedule(worker.attributes.schedule || '');
}
}, [worker]);

Expand All @@ -66,6 +71,11 @@ const WorkerDetailsContainer = ({ worker }: OwnProps) => {
setDepartmentName(dept);
};

const handleScheduleChange = (value: string) => {
setChanged(true);
setSchedule(value);
};

const handleUnitLeaderChange = (value: boolean) => {
setChanged(true);
setUnitLeader(value);
Expand Down Expand Up @@ -96,6 +106,7 @@ const WorkerDetailsContainer = ({ worker }: OwnProps) => {
manager,
unit_leader: unitLeader,
coach,
schedule,
};
await TaskRouterService.updateWorkerAttributes(workerSid, JSON.stringify(updatedAttr));
setChanged(false);
Expand All @@ -107,12 +118,12 @@ const WorkerDetailsContainer = ({ worker }: OwnProps) => {
<Table variant="borderless">
<TBody>
<Tr key="agent_name">
<Td>
<Td element="WORKER_DETAILS">
<Label htmlFor="name">
<Template source={templates.PSWorkerDetailsName} />
</Label>
</Td>
<Td>{worker?.fullName || 'Agent'}</Td>
<Td element="WORKER_DETAILS">{worker?.fullName || 'Agent'}</Td>
</Tr>
{editTeam() ? (
<AttributeSelect
Expand Down Expand Up @@ -146,16 +157,29 @@ const WorkerDetailsContainer = ({ worker }: OwnProps) => {
) : (
<AttributeDisplay id="manager" label="Manager" value={manager} />
)}
{editSchedule() ? (
<AttributeSelect
id="schedule"
label="Schedule"
value={schedule}
options={shiftOptions}
onChangeHandler={handleScheduleChange}
/>
) : (
<AttributeDisplay id="schedule" label="Schedule" value={schedule} />
)}
<AttributeBoolean
id="lead"
label="Unit Leader"
description=""
value={unitLeader}
onChangeHandler={handleUnitLeaderChange}
enabled={editUnitLeader()}
/>
<AttributeBoolean
id="coach"
label="Coach"
description=""
value={coach}
onChangeHandler={handleCoachChange}
enabled={editCoach()}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export const pasteElementHook = {
WORKER_DETAILS: {
padding: 'space30',
borderStyle: 'none',
},
} as { [key: string]: any };
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
"PSWorkerDetailsTeam": "Equipo",
"PSWorkerDetailsDepartment": "Departamento",
"PSWorkerDetailsLocation": "Lugar",
"PSWorkerDetailsManager": "Gerente"
"PSWorkerDetailsManager": "Gerente",
"PSWorkerDetailsSchedule": "Horario"
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export enum StringTemplates {
PSWorkerDetailsDepartment = 'PSWorkerDetailsDepartment',
PSWorkerDetailsLocation = 'PSWorkerDetailsLocation',
PSWorkerDetailsManager = 'PSWorkerDetailsManager',
PSWorkerDetailsSchedule = 'PSWorkerDetailsSchedule',
}

export const stringHook = () => ({
Expand All @@ -18,6 +19,7 @@ export const stringHook = () => ({
[StringTemplates.PSWorkerDetailsDepartment]: 'Department',
[StringTemplates.PSWorkerDetailsLocation]: 'Location',
[StringTemplates.PSWorkerDetailsManager]: 'Manager',
[StringTemplates.PSWorkerDetailsSchedule]: 'Schedule',
},
'es-MX': esMX,
});
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export default interface WorkerDetailsConfig {
edit_department: boolean;
edit_location: boolean;
edit_manager: boolean;
edit_schedule: boolean;
edit_unit_leader: boolean;
edit_coach: boolean;
}

0 comments on commit b5e30a9

Please sign in to comment.