Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Additions To Working Hours #955

Open
wants to merge 5 commits into
base: v2.0.2
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion DSL/DMapper/hbs/return_organization_working_time.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,7 @@
"organizationWorkingTimeNationalHolidays": "{{lookupConfigs configurationArray 'organizationWorkingTimeNationalHolidays' }}",
"organizationWorkingAllTime": "{{lookupConfigs configurationArray 'organizationWorkingAllTime' }}",
"organizationNoCsaAskForContacts": "{{lookupConfigs configurationArray 'organizationNoCsaAskForContacts' }}",
"organizationNoCsaAvailableMessage": "{{lookupConfigs configurationArray 'organizationNoCsaAvailableMessage' }}"
"organizationNoCsaAvailableMessage": "{{lookupConfigs configurationArray 'organizationNoCsaAvailableMessage' }}",
"organizationOutsideWorkingHoursAskForContacts": "{{lookupConfigs configurationArray 'organizationOutsideWorkingHoursAskForContacts' }}",
"organizationOutsideWorkingHoursMessage": "{{lookupConfigs configurationArray 'organizationOutsideWorkingHoursMessage' }}"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.1.xsd">

<changeSet id="20240621171002" author="ahmedyasser">
<insert tableName="configuration">
<column name="key" value="organizationOutsideWorkingHoursAskForContacts"/>
<column name="value" value="true"/>
</insert>
<insert tableName="configuration">
<column name="key" value="organizationOutsideWorkingHoursMessage"/>
<column name="value" value="Hetkel ei ole ettevõtte tööaeg, palun täitke kontaktivorm ja võtame Teiega ühendust!"/>
</insert>
</changeSet>
</databaseChangeLog>
4 changes: 2 additions & 2 deletions DSL/Resql/get-all-available-customer-support-agents.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
SELECT id_code, active, status
FROM customer_support_agent_activity
WHERE (status = 'online' OR status = 'idle')
AND id IN (SELECT MAX(id) FROM customer_support_agent_activity GROUP BY id_code);
WHERE (status = 'online')
AND id IN (SELECT MAX(id) FROM customer_support_agent_activity GROUP BY id_code);
58 changes: 19 additions & 39 deletions DSL/Resql/get-organization-base-config.sql
Original file line number Diff line number Diff line change
@@ -1,40 +1,20 @@
WITH all_time_availability_config AS
(SELECT id,
KEY,
value
FROM configuration
WHERE KEY IN ('organizationWorkingAllTime')
AND id IN
(SELECT max(id)
FROM configuration
GROUP BY KEY)
AND NOT deleted),
ask_for_contacts_config AS
(SELECT id,
KEY,
value
FROM configuration
WHERE KEY IN ('organizationNoCsaAskForContacts')
AND id IN
(SELECT max(id)
FROM configuration
GROUP BY KEY)
AND NOT deleted),
csa_no_available_message_config AS
(SELECT id,
KEY,
value
FROM configuration
WHERE KEY IN ('organizationNoCsaAvailableMessage')
AND id IN
(SELECT max(id)
FROM configuration
GROUP BY KEY)
AND NOT deleted)
WITH configuration_values AS (
SELECT id,
KEY,
value
FROM configuration
WHERE KEY IN ('organizationWorkingAllTime',
'organizationNoCsaAskForContacts',
'organizationNoCsaAvailableMessage',
'organizationOutsideWorkingHoursAskForContacts',
'organizationOutsideWorkingHoursMessage')
AND id IN (SELECT max(id) FROM configuration GROUP BY KEY)
AND NOT deleted
)
SELECT
(SELECT value AS is_available_all_time
FROM all_time_availability_config),
(SELECT value AS ask_for_contacts
FROM ask_for_contacts_config),
(SELECT value AS no_csa_message
FROM csa_no_available_message_config);
MAX(CASE WHEN KEY = 'organizationWorkingAllTime' THEN value END) AS is_available_all_time,
MAX(CASE WHEN KEY = 'organizationNoCsaAskForContacts' THEN value END) AS ask_for_contacts,
MAX(CASE WHEN KEY = 'organizationNoCsaAvailableMessage' THEN value END) AS no_csa_message,
MAX(CASE WHEN KEY = 'organizationOutsideWorkingHoursAskForContacts' THEN value END) AS outside_working_hours_ask_for_contacts,
MAX(CASE WHEN KEY = 'organizationOutsideWorkingHoursMessage' THEN value END) AS outside_working_hours_message
FROM configuration_values;
4 changes: 3 additions & 1 deletion DSL/Resql/get-organization-working-time.sql
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ WHERE key IN (
'organizationWorkingTimeNationalHolidays',
'organizationWorkingAllTime',
'organizationNoCsaAskForContacts',
'organizationNoCsaAvailableMessage')
'organizationNoCsaAvailableMessage',
'organizationOutsideWorkingHoursAskForContacts',
'organizationOutsideWorkingHoursMessage')
AND id IN (SELECT max(id) from configuration GROUP BY key)
AND NOT deleted;
8 changes: 6 additions & 2 deletions DSL/Resql/set-organization-working-time.sql
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ WITH last_configuration AS (
'organizationWorkingTimeNationalHolidays',
'organizationWorkingAllTime',
'organizationNoCsaAskForContacts',
'organizationNoCsaAvailableMessage')
'organizationNoCsaAvailableMessage',
'organizationOutsideWorkingHoursAskForContacts',
'organizationOutsideWorkingHoursMessage')
AND id IN (SELECT max(id) from configuration GROUP BY key)
AND deleted = FALSE
), new_configuration as (
Expand Down Expand Up @@ -53,7 +55,9 @@ WITH last_configuration AS (
('organizationWorkingTimeNationalHolidays', :organizationWorkingTimeNationalHolidays),
('organizationWorkingAllTime', :organizationWorkingAllTime),
('organizationNoCsaAskForContacts', :organizationNoCsaAskForContacts),
('organizationNoCsaAvailableMessage', :organizationNoCsaAvailableMessage)
('organizationNoCsaAvailableMessage', :organizationNoCsaAvailableMessage),
('organizationOutsideWorkingHoursAskForContacts', :organizationOutsideWorkingHoursAskForContacts),
('organizationOutsideWorkingHoursMessage', :organizationOutsideWorkingHoursMessage)
) as new_values (key, value)
)
INSERT INTO configuration (key, value, created)
Expand Down
10 changes: 10 additions & 0 deletions DSL/Ruuter.private/DSL/POST/configs/organization-working-time.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,12 @@ declaration:
- field: organizationNoCsaAvailableMessage
type: string
description: "Body field 'organizationNoCsaAvailableMessage'"
- field: organizationOutsideWorkingHoursAskForContacts
type: string
description: "Body field 'organizationOutsideWorkingHoursAskForContacts'"
- field: organizationOutsideWorkingHoursMessage
type: string
description: "Body field 'organizationOutsideWorkingHoursMessage'"

extractRequestData:
assign:
Expand All @@ -103,6 +109,8 @@ extractRequestData:
organizationWorkingAllTime: ${incoming.body.organizationWorkingAllTime}
organizationNoCsaAskForContacts: ${incoming.body.organizationNoCsaAskForContacts}
organizationNoCsaAvailableMessage: ${incoming.body.organizationNoCsaAvailableMessage}
organizationOutsideWorkingHoursAskForContacts: ${incoming.body.organizationOutsideWorkingHoursAskForContacts}
organizationOutsideWorkingHoursMessage: ${incoming.body.organizationOutsideWorkingHoursMessage}

setOrganizationWorkingTime:
call: http.post
Expand Down Expand Up @@ -132,6 +140,8 @@ setOrganizationWorkingTime:
organizationWorkingAllTime: ${organizationWorkingAllTime}
organizationNoCsaAskForContacts: ${organizationNoCsaAskForContacts}
organizationNoCsaAvailableMessage: ${organizationNoCsaAvailableMessage}
organizationOutsideWorkingHoursAskForContacts: ${organizationOutsideWorkingHoursAskForContacts}
organizationOutsideWorkingHoursMessage: ${organizationOutsideWorkingHoursMessage}
created: ${new Date().toISOString()}
result: setOrganizationWorkingTimeResult

Expand Down
16 changes: 8 additions & 8 deletions DSL/Ruuter.public/DSL/POST/internal/message-to-bot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ check_for_service:

assign_service_content:
assign:
service_content: ${content}
next: trigger_service
service_content: ${content}
next: trigger_service

post_message_to_bot:
call: http.post
Expand All @@ -105,13 +105,13 @@ check_if_bot_is_unable_to_reply:
- condition: ${post_message_to_bot_result.response.body?.[0]?.text == 'Suunan teid klienditeenindajale. Varuge natukene kannatust.'}
next: get_organization_base_config
- condition: ${post_message_to_bot_result.response.body?.[0]?.text.startsWith("#common_service") || post_message_to_bot_result.response.body?.[0]?.text.startsWith("#service")}
next: assign_service_content_from_bot_response
next: assign_service_content_from_bot_response
next: extract_bot_responses

assign_service_content_from_bot_response:
assign:
service_content: ${post_message_to_bot_result.response.body?.[0]?.text}
next: trigger_service
service_content: ${post_message_to_bot_result.response.body?.[0]?.text}
next: trigger_service

trigger_service:
template: chats/trigger-service
Expand Down Expand Up @@ -211,7 +211,7 @@ return_is_a_holiday:
- chatId: ${chatId}
content: ${org_details.holidayMessage}
authorTimestamp: ${new Date().toISOString()}
event: "unavailable_holiday"
event: "${base_config.outsideWorkingHoursAskForContacts === 'true' ? 'unavailable_holiday_ask_contacts' : 'unavailable_holiday'}"
authorId: ${get_bot_name_result.response.body[0].value}
authorFirstName: ""
authorLastName: ""
Expand All @@ -226,9 +226,9 @@ return_organization_is_not_available:
body:
messages:
- chatId: ${chatId}
content: "Bürokratt on hetkel väljaspool tööaega, palun jäta oma kontaktandmed ja võtame Sinuga esimesel võimalusel ühendust"
content: ${base_config.outsideWorkingHoursMessage}
authorTimestamp: ${new Date().toISOString()}
event: "unavailable_organization"
event: "${base_config.outsideWorkingHoursAskForContacts === 'true' ? 'unavailable_organization_ask_contacts' : 'unavailable_organization'}"
authorId: ${get_bot_name_result.response.body[0].value}
authorFirstName: ""
authorLastName: ""
Expand Down
1 change: 1 addition & 0 deletions GUI/src/constants/config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export const EMERGENCY_NOTICE_LENGTH = 250;
export const WELCOME_MESSAGE_LENGTH = 250;
export const NO_CSA_MESSAGE_LENGTH = 250;
export const OUTSIDE_WORKING_HOURS_MESSAGE_LENGTH = 250;
export const USER_IDLE_STATUS_TIMEOUT = 300000; // milliseconds
export const CHAT_INPUT_LENGTH = 500;
export const POPUP_DURATION = 2; // seconds
Expand Down
4 changes: 4 additions & 0 deletions GUI/src/pages/Settings/SettingsWorkingTime/data.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ export function getOrganizationTimeData(data: OrganizationWorkingTime) {
organizationNoCsaAskForContacts:
data.organizationNoCsaAskForContacts.toString() === 'true',
organizationNoCsaAvailableMessage: data.organizationNoCsaAvailableMessage,
organizationOutsideWorkingHoursAskForContacts: data.organizationOutsideWorkingHoursAskForContacts.toString() === 'true',
organizationOutsideWorkingHoursMessage: data.organizationOutsideWorkingHoursMessage,

};
}

Expand All @@ -77,6 +80,7 @@ export function setOrganizationTimeData(data: OrganizationWorkingTime) {
organizationWorkingAllTime: data.organizationWorkingAllTime.toString(),
organizationNoCsaAskForContacts:
data.organizationNoCsaAskForContacts.toString(),
organizationOutsideWorkingHoursAskForContacts: data.organizationOutsideWorkingHoursAskForContacts.toString(),
};
}

Expand Down
61 changes: 60 additions & 1 deletion GUI/src/pages/Settings/SettingsWorkingTime/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ import './SettingsWorkingTime.scss';
import { getOrganizationTimeData, setOrganizationTimeData } from './data';
import withAuthorization from 'hoc/with-authorization';
import { ROLES } from 'utils/constants';
import { NO_CSA_MESSAGE_LENGTH } from 'constants/config';
import {
NO_CSA_MESSAGE_LENGTH,
OUTSIDE_WORKING_HOURS_MESSAGE_LENGTH,
} from 'constants/config';

type FieldDateNames = {
start: string;
Expand Down Expand Up @@ -411,6 +414,62 @@ const SettingsWorkingTime: FC = () => {
)}
</Track>
))}
{!isOrganizationAvailableAllTime && (
<Controller
name="organizationOutsideWorkingHoursAskForContacts"
control={control}
render={({ field }) => (
<Switch
label={t(
'settings.workingTime.showIfOrganizationIsOutsideWorkingHours'
)}
onLabel={t('global.yes').toString()}
offLabel={t('global.no').toString()}
onCheckedChange={(e) => field.onChange(!e)}
checked={!field.value}
{...field}
/>
)}
/>
)}
{!isOrganizationAvailableAllTime && (
<Controller
name="organizationOutsideWorkingHoursAskForContacts"
control={control}
render={({ field }) => (
<Switch
label={t(
'settings.workingTime.showIfOrganizationIsOutsideWorkingHoursWithContactsRequest'
)}
onLabel={t('global.yes').toString()}
offLabel={t('global.no').toString()}
onCheckedChange={field.onChange}
checked={field.value}
{...field}
/>
)}
/>
)}
{!isOrganizationAvailableAllTime && (
<div style={{ paddingRight: '20px' }}>
<Controller
name="organizationOutsideWorkingHoursMessage"
control={control}
render={({ field }) => (
<FormTextarea
label={t('settings.workingTime.outsideWorkingHoursMessage')}
minRows={4}
maxLength={OUTSIDE_WORKING_HOURS_MESSAGE_LENGTH}
showMaxLength
maxLengthBottom
onChange={field.onChange}
value={field.value}
name="label"
/>
)}
/>
</div>
)}
<Controller
name="organizationNoCsaAskForContacts"
control={control}
Expand Down
2 changes: 2 additions & 0 deletions GUI/src/types/organizationWorkingTime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,6 @@ export interface OrganizationWorkingTime {
organizationWorkingAllTime: boolean;
organizationNoCsaAskForContacts: boolean;
organizationNoCsaAvailableMessage: string;
organizationOutsideWorkingHoursAskForContacts: boolean;
organizationOutsideWorkingHoursMessage: string;
}
21 changes: 14 additions & 7 deletions GUI/translations/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -191,10 +191,12 @@
"inactive-chat-ended": "Ended cue to inactivity",
"contact-information-skipped": "Contact Information Skipped",
"unavailable-contact-information-fulfilled": "Contact information provided",
"unavailable_organization": "Organization Unavailable",
"unavailable_csas": "CSA's Unavailable",
"unavailable_csas_ask_contacts": "CSA's Unavailable and asked for contacts",
"unavailable_organization": "Organization is unavailable",
"unavailable_organization_ask_contacts": "Organization is unavailable and asked for contacts",
"unavailable_csas": "Advisors are not available",
"unavailable_csas_ask_contacts": "Advisors are not available and asked for contacts",
"unavailable_holiday": "Holiday",
"unavailable_holiday_ask_contacts": "Holiday and asked for contacts",
"message-read": "Read",
"user-reached": "User contacted",
"user-not-reached": "User could not be reached"
Expand Down Expand Up @@ -229,10 +231,12 @@
"message-read": "Read",
"contact-information-skipped": "Contact Information Skipped",
"unavailable-contact-information-fulfilled": "Contact information provided",
"unavailable_organization": "Organization Unavailable",
"unavailable_csas": "CSA's Unavailable",
"unavailable_csas_ask_contacts": "CSA's Unavailable and asked for contacts",
"unavailable_organization": "Organization is unavailable",
"unavailable_organization_ask_contacts": "Organization is unavailable and asked for contacts",
"unavailable_csas": "Advisors are not available",
"unavailable_csas_ask_contacts": "Advisors are not available and asked for contacts",
"unavailable_holiday": "Holiday",
"unavailable_holiday_ask_contacts": "Holiday and asked for contacts",
"pending-assigned": "{{name}} assigned to contact user",
"user-reached": "{{name}} contacted the user",
"user-not-reached": "{{name}} could not reach the user",
Expand Down Expand Up @@ -332,7 +336,10 @@
"availableAllTime": "Working hours are 24/7",
"showIfCSAIsNotAvailable": "Send a notification of absence to the client",
"showIfCSAIsNotAvailableWithContactsRequest": "Send a notification of absence to the client with a contact request",
"noCsaAvailableMessage": "No CSA available message"
"noCsaAvailableMessage": "Notification of the absence of a customer service representative",
"showIfOrganizationIsOutsideWorkingHours": "Send a notification to the client about the company's outside working hours",
"showIfOrganizationIsOutsideWorkingHoursWithContactsRequest": "Send a notification to the client about the company's outside working hours with a contact request",
"outsideWorkingHoursMessage": "Outside working hours message"
},
"userSession": {
"title": "User session",
Expand Down
13 changes: 10 additions & 3 deletions GUI/translations/et/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,11 @@
"contact-information-skipped": "Kontaktandmeid ei saadetud",
"unavailable-contact-information-fulfilled": "Kontaktandmed on antud",
"unavailable_organization": "Organisatsioon pole saadaval",
"unavailable_organization_ask_contacts": "Organisatsioon pole saadaval ja küsitakse kontakte",
"unavailable_csas": "Nõustajad pole saadaval",
"unavailable_csas_ask_contacts": "CSA pole saadaval ja küsis kontakte",
"unavailable_csas_ask_contacts": "Nõustajad ei ole kättesaadavad ja küsitakse kontakte",
"unavailable_holiday": "Puhkus",
"unavailable_holiday_ask_contacts": "Puhkus ja küsis kontakte",
"user-reached": "Kasutajaga võeti ühendust",
"user-not-reached": "Kasutajaga ei õnnestunud ühendust saada"
},
Expand Down Expand Up @@ -230,9 +232,11 @@
"contact-information-skipped": "Kontaktandmeid pole esitatud",
"unavailable-contact-information-fulfilled": "Kontaktandmed on antud",
"unavailable_organization": "Organisatsioon pole saadaval",
"unavailable_organization_ask_contacts": "Organisatsioon pole saadaval ja küsitakse kontakte",
"unavailable_csas": "Nõustajad pole saadaval",
"unavailable_csas_ask_contacts": "CSA pole saadaval ja küsis kontakte",
"unavailable_csas_ask_contacts": "Nõustajad ei ole kättesaadavad ja küsitakse kontakte",
"unavailable_holiday": "Puhkus",
"unavailable_holiday_ask_contacts": "Puhkus ja küsis kontakte",
"pending-assigned": "{{name}} määratud kontaktkasutajale",
"user-reached": "{{name}} võttis kasutajaga ühendust",
"user-not-reached": "{{name}} ei saanud kasutajaga ühendust",
Expand Down Expand Up @@ -332,7 +336,10 @@
"availableAllTime": "Asutuse tööaeg on 24/7",
"showIfCSAIsNotAvailable": "Saada kliendile teavitus eemalolekust",
"showIfCSAIsNotAvailableWithContactsRequest": "Saada kliendile teavitus eemalolekust koos kontakti päringuga",
"noCsaAvailableMessage": "CSA pole saadaval teade"
"noCsaAvailableMessage": "Klienditeenindaja eemaloleku teavitus",
"showIfOrganizationIsOutsideWorkingHours": "Saada kliendile teavitus ettevõtte välisest tööajast",
"showIfOrganizationIsOutsideWorkingHoursWithContactsRequest": "Saada kliendile teavitus töövälisest ajast koos kontakti päringuga",
"outsideWorkingHoursMessage": "Väljaspool tööaega teade"
},
"userSession": {
"title": "Kasutaja sessioon",
Expand Down