From acc8f1fc8e97dfaaeb2b071123fa9d9ebe8e4951 Mon Sep 17 00:00:00 2001
From: 1AhmedYasser <26207361+1AhmedYasser@users.noreply.github.com>
Date: Thu, 31 Oct 2024 00:05:43 +0300
Subject: [PATCH 1/3] Added outside working hours configs
---
...eturn_organization_working_time.handlebars | 4 +-
...71002_add_outside_working_hours_config.xml | 17 ++++++
DSL/Resql/get-organization-base-config.sql | 58 ++++++------------
DSL/Resql/get-organization-working-time.sql | 4 +-
DSL/Resql/set-organization-working-time.sql | 8 ++-
.../configs/organization-working-time.yml | 10 +++
.../DSL/POST/internal/message-to-bot.yml | 14 ++---
GUI/src/constants/config.ts | 1 +
.../Settings/SettingsWorkingTime/data.tsx | 4 ++
.../Settings/SettingsWorkingTime/index.tsx | 61 ++++++++++++++++++-
GUI/src/types/organizationWorkingTime.ts | 2 +
GUI/translations/en/common.json | 19 +++---
GUI/translations/et/common.json | 11 +++-
13 files changed, 152 insertions(+), 61 deletions(-)
create mode 100644 DSL/Liquibase/changelog/20240621171002_add_outside_working_hours_config.xml
diff --git a/DSL/DMapper/hbs/return_organization_working_time.handlebars b/DSL/DMapper/hbs/return_organization_working_time.handlebars
index db5ab85e..06a66d8b 100644
--- a/DSL/DMapper/hbs/return_organization_working_time.handlebars
+++ b/DSL/DMapper/hbs/return_organization_working_time.handlebars
@@ -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' }}"
}
diff --git a/DSL/Liquibase/changelog/20240621171002_add_outside_working_hours_config.xml b/DSL/Liquibase/changelog/20240621171002_add_outside_working_hours_config.xml
new file mode 100644
index 00000000..94c227a9
--- /dev/null
+++ b/DSL/Liquibase/changelog/20240621171002_add_outside_working_hours_config.xml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/DSL/Resql/get-organization-base-config.sql b/DSL/Resql/get-organization-base-config.sql
index 470d0a8b..56bee152 100644
--- a/DSL/Resql/get-organization-base-config.sql
+++ b/DSL/Resql/get-organization-base-config.sql
@@ -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;
diff --git a/DSL/Resql/get-organization-working-time.sql b/DSL/Resql/get-organization-working-time.sql
index 5c3fd6b3..cf988ebf 100644
--- a/DSL/Resql/get-organization-working-time.sql
+++ b/DSL/Resql/get-organization-working-time.sql
@@ -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;
diff --git a/DSL/Resql/set-organization-working-time.sql b/DSL/Resql/set-organization-working-time.sql
index 751a6bb0..e72bb4c3 100644
--- a/DSL/Resql/set-organization-working-time.sql
+++ b/DSL/Resql/set-organization-working-time.sql
@@ -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 (
@@ -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)
diff --git a/DSL/Ruuter.private/DSL/POST/configs/organization-working-time.yml b/DSL/Ruuter.private/DSL/POST/configs/organization-working-time.yml
index aba4b988..05a7c366 100644
--- a/DSL/Ruuter.private/DSL/POST/configs/organization-working-time.yml
+++ b/DSL/Ruuter.private/DSL/POST/configs/organization-working-time.yml
@@ -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:
@@ -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
@@ -132,6 +140,8 @@ setOrganizationWorkingTime:
organizationWorkingAllTime: ${organizationWorkingAllTime}
organizationNoCsaAskForContacts: ${organizationNoCsaAskForContacts}
organizationNoCsaAvailableMessage: ${organizationNoCsaAvailableMessage}
+ organizationOutsideWorkingHoursAskForContacts: ${organizationOutsideWorkingHoursAskForContacts}
+ organizationOutsideWorkingHoursMessage: ${organizationOutsideWorkingHoursMessage}
created: ${new Date().toISOString()}
result: setOrganizationWorkingTimeResult
diff --git a/DSL/Ruuter.public/DSL/POST/internal/message-to-bot.yml b/DSL/Ruuter.public/DSL/POST/internal/message-to-bot.yml
index 28114a05..a5d50879 100644
--- a/DSL/Ruuter.public/DSL/POST/internal/message-to-bot.yml
+++ b/DSL/Ruuter.public/DSL/POST/internal/message-to-bot.yml
@@ -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
@@ -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
@@ -225,9 +225,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: ""
diff --git a/GUI/src/constants/config.ts b/GUI/src/constants/config.ts
index 09c0a65e..fb75bc73 100644
--- a/GUI/src/constants/config.ts
+++ b/GUI/src/constants/config.ts
@@ -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
diff --git a/GUI/src/pages/Settings/SettingsWorkingTime/data.tsx b/GUI/src/pages/Settings/SettingsWorkingTime/data.tsx
index c3987a25..aea67d2d 100644
--- a/GUI/src/pages/Settings/SettingsWorkingTime/data.tsx
+++ b/GUI/src/pages/Settings/SettingsWorkingTime/data.tsx
@@ -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,
+
};
}
@@ -77,6 +80,7 @@ export function setOrganizationTimeData(data: OrganizationWorkingTime) {
organizationWorkingAllTime: data.organizationWorkingAllTime.toString(),
organizationNoCsaAskForContacts:
data.organizationNoCsaAskForContacts.toString(),
+ organizationOutsideWorkingHoursAskForContacts: data.organizationOutsideWorkingHoursAskForContacts.toString(),
};
}
diff --git a/GUI/src/pages/Settings/SettingsWorkingTime/index.tsx b/GUI/src/pages/Settings/SettingsWorkingTime/index.tsx
index 27bb6dee..47211526 100644
--- a/GUI/src/pages/Settings/SettingsWorkingTime/index.tsx
+++ b/GUI/src/pages/Settings/SettingsWorkingTime/index.tsx
@@ -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;
@@ -411,6 +414,62 @@ const SettingsWorkingTime: FC = () => {
)}
))}
+ {!isOrganizationAvailableAllTime && (
+ (
+ field.onChange(!e)}
+ checked={!field.value}
+ {...field}
+ />
+ )}
+ />
+ )}
+ {!isOrganizationAvailableAllTime && (
+ (
+
+ )}
+ />
+ )}
+ {!isOrganizationAvailableAllTime && (
+
+ (
+
+ )}
+ />
+
+ )}
Date: Thu, 31 Oct 2024 00:16:04 +0300
Subject: [PATCH 2/3] Handled Holiday
---
DSL/Ruuter.public/DSL/POST/internal/message-to-bot.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/DSL/Ruuter.public/DSL/POST/internal/message-to-bot.yml b/DSL/Ruuter.public/DSL/POST/internal/message-to-bot.yml
index a5d50879..22578187 100644
--- a/DSL/Ruuter.public/DSL/POST/internal/message-to-bot.yml
+++ b/DSL/Ruuter.public/DSL/POST/internal/message-to-bot.yml
@@ -210,7 +210,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: ""
From 39174b621e62951b59df9a8475427697ee46bfd2 Mon Sep 17 00:00:00 2001
From: 1AhmedYasser <26207361+1AhmedYasser@users.noreply.github.com>
Date: Thu, 31 Oct 2024 00:22:32 +0300
Subject: [PATCH 3/3] Added Holiday translations
---
GUI/translations/en/common.json | 2 ++
GUI/translations/et/common.json | 2 ++
2 files changed, 4 insertions(+)
diff --git a/GUI/translations/en/common.json b/GUI/translations/en/common.json
index d2e12534..08a372ed 100644
--- a/GUI/translations/en/common.json
+++ b/GUI/translations/en/common.json
@@ -196,6 +196,7 @@
"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"
@@ -235,6 +236,7 @@
"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",
diff --git a/GUI/translations/et/common.json b/GUI/translations/et/common.json
index f169cade..9394194c 100644
--- a/GUI/translations/et/common.json
+++ b/GUI/translations/et/common.json
@@ -197,6 +197,7 @@
"unavailable_csas": "Nõustajad pole saadaval",
"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"
},
@@ -235,6 +236,7 @@
"unavailable_csas": "Nõustajad pole saadaval",
"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",