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

Feat/delphi 46 group chat #989

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
bfb897f
Merge pull request #120 from virtualidentityag/feat/overwrite-t-sys
Soarecos Nov 29, 2022
3ca42a8
Merge pull request #121 from Onlineberatung/develop
CarlosSoares Dec 8, 2022
c3f85c2
Merge pull request #122 from Onlineberatung/develop
CarlosSoares Dec 8, 2022
3c3318e
Merge pull request #123 from Onlineberatung/develop
adnanalicic Dec 9, 2022
2fd461b
Merge pull request #124 from Onlineberatung/develop
CarlosSoares Dec 9, 2022
a7d75bc
Merge pull request #125 from Onlineberatung/develop
CarlosSoares Dec 9, 2022
d2e98f5
Merge pull request #126 from Onlineberatung/develop
CarlosSoares Dec 12, 2022
fc9bc6e
Merge pull request #127 from Onlineberatung/develop
CarlosSoares Dec 13, 2022
1a44270
Merge pull request #128 from Onlineberatung/develop
Soarecos Dec 14, 2022
0a48322
feat: adding the package lock
CarlosSoares Dec 15, 2022
59daddf
fix: some prettier issues
CarlosSoares Dec 15, 2022
fa5be16
Merge pull request #129 from virtualidentityag/fix/missing-package
CarlosSoares Dec 15, 2022
ad23f45
Merge pull request #132 from Onlineberatung/develop
CarlosSoares Dec 19, 2022
da288d8
Merge pull request #133 from Onlineberatung/develop
Soarecos Dec 19, 2022
8b2d59c
Merge pull request #134 from Onlineberatung/develop
Soarecos Dec 19, 2022
25b7775
style: delete message label
Soarecos Dec 20, 2022
950471b
Merge pull request #135 from virtualidentityag/fix/styling-delete-mes…
Soarecos Dec 20, 2022
d6d57c2
fix: terms and conditions
Soarecos Dec 20, 2022
68cbaa2
Merge pull request #136 from virtualidentityag/fix/TC
adnanalicic Dec 20, 2022
12f8679
Merge pull request #137 from Onlineberatung/develop
Soarecos Dec 20, 2022
c265d97
feat: sync
Soarecos Dec 20, 2022
b5c3b56
Merge pull request #138 from virtualidentityag/fix/sync
Soarecos Dec 20, 2022
80fcb19
feat: hide terms and conditions for consultants
CarlosSoares Dec 21, 2022
b554d48
Merge pull request #139 from virtualidentityag/hide-terms-and-consult…
CarlosSoares Dec 21, 2022
77455d7
Merge pull request #140 from Onlineberatung/develop
CarlosSoares Dec 21, 2022
f9096cf
fix: issue when changing the translation
CarlosSoares Dec 22, 2022
c47efb6
Merge pull request #142 from virtualidentityag/fix/locale-issues
CarlosSoares Dec 22, 2022
1c657d5
fix: enabled t&c for consultant
adnanalicic Dec 29, 2022
b13d472
Merge pull request #143 from virtualidentityag/terms_and_conditions_c…
adnanalicic Dec 29, 2022
5579457
Merge pull request #141 from Onlineberatung/develop
CarlosSoares Jan 6, 2023
abfcec7
Merge pull request #146 from Onlineberatung/develop
CarlosSoares Jan 20, 2023
5017917
Merge pull request #148 from Onlineberatung/develop
CarlosSoares Feb 2, 2023
961f6c3
Merge pull request #149 from Onlineberatung/develop
adnanalicic Feb 2, 2023
752990f
Merge pull request #150 from Onlineberatung/develop
CarlosSoares Feb 7, 2023
9181c61
Merge pull request #151 from Onlineberatung/develop
adnanalicic Feb 7, 2023
5a9cc76
Merge pull request #153 from Onlineberatung/develop
CarlosSoares Feb 17, 2023
95ed800
Merge pull request #154 from Onlineberatung/develop
CarlosSoares Feb 20, 2023
c3fe895
Merge pull request #155 from Onlineberatung/develop
CarlosSoares Feb 27, 2023
ed1dc4a
Merge pull request #156 from Onlineberatung/develop
CarlosSoares Mar 1, 2023
e96f005
Merge pull request #157 from Onlineberatung/develop
CarlosSoares Mar 15, 2023
1b7b7ca
Merge pull request #159 from Onlineberatung/develop
CarlosSoares Mar 17, 2023
9997d94
Merge pull request #160 from Onlineberatung/develop
CarlosSoares Mar 17, 2023
2b0899f
Merge pull request #161 from Onlineberatung/develop
CarlosSoares Mar 21, 2023
06b2a35
Merge pull request #162 from Onlineberatung/develop
CarlosSoares Mar 22, 2023
502773a
Merge pull request #163 from Onlineberatung/develop
CarlosSoares Mar 23, 2023
76e5cc8
Merge pull request #164 from Onlineberatung/develop
CarlosSoares Mar 29, 2023
a1ff792
Merge pull request #165 from Onlineberatung/develop
CarlosSoares Mar 30, 2023
1cf1f37
Merge pull request #166 from Onlineberatung/develop
CarlosSoares Apr 3, 2023
719d40b
Merge pull request #167 from Onlineberatung/develop
CarlosSoares Apr 4, 2023
19eb4cb
Merge pull request #168 from Onlineberatung/develop
CarlosSoares Apr 11, 2023
b8e3215
Merge pull request #169 from Onlineberatung/develop
CarlosSoares May 30, 2023
0b9d61e
Merge pull request #170 from Onlineberatung/develop
CarlosSoares Jun 2, 2023
3645a8d
Merge pull request #171 from Onlineberatung/develop
RunzelRosinchen Jul 19, 2023
72906ec
Merge branch 'Onlineberatung:develop' into develop
web-mi Aug 11, 2023
91811c6
Merge branch 'Onlineberatung:develop' into develop
web-mi Aug 23, 2023
4134b45
fix: parse colors when they not set
web-mi Aug 23, 2023
71dc33a
Merge pull request #179 from virtualidentityag/OB-5707
web-mi Aug 23, 2023
3d540a0
fix: parse colors when they not set
web-mi Aug 23, 2023
a8df575
Merge pull request #181 from virtualidentityag/OB-5707
web-mi Aug 23, 2023
6808cdb
Merge pull request #183 from Onlineberatung/develop
web-mi Aug 28, 2023
05e5580
Merge pull request #186 from Onlineberatung/develop
web-mi Jan 12, 2024
7b556f2
feat: update i18n
janrembold Jan 15, 2024
349bd69
feat: update textarea max letters position
janrembold Jan 15, 2024
674f680
fix: add missing user roles field
janrembold Jan 15, 2024
9ea53fd
fix: add new fields assigned agencies and hint message
janrembold Jan 15, 2024
1b26d9d
feat: update group chat info
janrembold Jan 15, 2024
b8ba0e3
fix: add new group chat fields
janrembold Jan 15, 2024
0e2bfb4
feat: add new form fields
janrembold Jan 15, 2024
038505c
fix: hide agency select in update form
janrembold Jan 16, 2024
4449f1e
fix: remove unused interface
janrembold Jan 16, 2024
e899ed4
fix: error when assigend agencies is not set
janrembold Jan 17, 2024
3a1d410
Merge branch 'develop' into feat/delphi-46-group-chat
janrembold Jan 17, 2024
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
2 changes: 2 additions & 0 deletions src/api/apiGroupChatSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ export interface groupChatSettings {
startDate: string;
startTime: string;
duration: number;
agencyId: number;
hintMessage: string;
repetitive: boolean;
featureGroupChatV2Enabled?: boolean;
}
Expand Down
7 changes: 6 additions & 1 deletion src/components/form/textarea.styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@
}

&__letters {
text-align: right;
position: absolute;
top: 4px;
right: 20px;
font-size: 12px;
color: $tertiary;
}

textarea {
Expand All @@ -23,6 +27,7 @@
border-radius: $input-field-border-radius;
outline: 0;
box-shadow: $input-field-box-shadow;
vertical-align: top;

&:hover {
border: 1px solid $form-active;
Expand Down
12 changes: 6 additions & 6 deletions src/components/form/textarea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ export const Textarea = ({
{placeholder}
</label>
)}
{attrs.maxLength && (
<div className="textarea__letters">
{(attrs?.value?.toString() ?? '').length} /{' '}
{attrs.maxLength}
</div>
)}
</div>
{attrs.maxLength && (
<div className="textarea__letters">
{(attrs?.value?.toString() ?? '').length} /{' '}
{attrs.maxLength}
</div>
)}
</div>
);
};
155 changes: 129 additions & 26 deletions src/components/groupChat/CreateChatView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import {
getExtendedSession,
UPDATE_SESSIONS,
SessionTypeContext,
useTenant
useTenant,
UserDataContext
} from '../../globalState';
import { InputField, InputFieldItem } from '../inputField/InputField';
import { Checkbox, CheckboxItem } from '../checkbox/Checkbox';
Expand Down Expand Up @@ -45,20 +46,26 @@ import { useResponsive } from '../../hooks/useResponsive';
import { apiGetSessionRoomsByGroupIds } from '../../api/apiGetSessionRooms';
import { useSearchParam } from '../../hooks/useSearchParams';
import { useTranslation } from 'react-i18next';
import { Textarea } from '../form/textarea';

registerLocale('de', de);

export const CreateGroupChatView = (props) => {
const { t: translate } = useTranslation();
const { rcGroupId: groupIdFromParam } = useParams<{ rcGroupId: string }>();
const history = useHistory();
const {
userData: { agencies = [] }
} = useContext(UserDataContext);

const { sessions, ready, dispatch } = useContext(SessionsDataContext);
const { path: listPath } = useContext(SessionTypeContext);
const [selectedChatTopic, setSelectedChatTopic] = useState('');
const [selectedDate, setSelectedDate] = useState('');
const [selectedTime, setSelectedTime] = useState('');
const [selectedDuration, setSelectedDuration] = useState(null);
const [selectedAgency, setSelectedAgency] = useState<number | null>(null);
const [hintMessage, setHintMessage] = useState('');
const [selectedRepetitive, setSelectedRepetitive] = useState(false);
const [isCreateButtonDisabled, setIsCreateButtonDisabled] = useState(true);
const [isSaveButtonDisabled, setIsSaveButtonDisabled] = useState(true);
Expand Down Expand Up @@ -174,6 +181,12 @@ export const CreateGroupChatView = (props) => {
handleTimePicker(selectedTime);
setSelectedDuration(activeSession.item.duration);
setSelectedRepetitive(activeSession.item.repetitive);
setSelectedAgency(
activeSession.item.assignedAgencies?.length > 0
? activeSession.item.assignedAgencies[0].id
: null
);
setHintMessage(activeSession.item.hintMessage);
}
}, [groupIdFromParam, props.location.state, ready, sessions]);

Expand All @@ -192,21 +205,35 @@ export const CreateGroupChatView = (props) => {
prefillTime.toLocaleTimeString() !==
inputTime.toLocaleTimeString() ||
parseInt(selectedDuration) !== activeSession.item.duration ||
selectedRepetitive !== activeSession.item.repetitive
selectedRepetitive !== activeSession.item.repetitive ||
selectedAgency !== activeSession.item.assignedAgencies?.[0]?.id ||
hintMessage !== activeSession.item.hintMessage
);
}, [
activeSession?.item.duration,
activeSession?.item.repetitive,
activeSession?.item.startDate,
activeSession?.item.startTime,
activeSession?.item.topic,
activeSession?.item.assignedAgencies,
activeSession?.item.hintMessage,
hintMessage,
selectedAgency,
selectedChatTopic,
selectedDate,
selectedDuration,
selectedRepetitive,
selectedTime
]);

useEffect(() => {
const onlyOneAgencyAvailable = agencies?.length === 1;

if (onlyOneAgencyAvailable) {
setSelectedAgency(agencies[0].id);
}
}, [agencies]);

useEffect(() => {
const isChatTopicValid =
selectedChatTopic &&
Expand All @@ -216,7 +243,8 @@ export const CreateGroupChatView = (props) => {
isChatTopicValid &&
selectedDate &&
selectedTime &&
selectedDuration
selectedDuration &&
selectedAgency
) {
isEditGroupChatMode && arePrefilledValuesChanged()
? setIsSaveButtonDisabled(false)
Expand All @@ -231,11 +259,12 @@ export const CreateGroupChatView = (props) => {
selectedDate,
selectedTime,
selectedDuration,
selectedAgency,
isEditGroupChatMode,
arePrefilledValuesChanged
]);

const handleBackButton = () => {
const handleEditGroupChatBackButton = () => {
if (isEditGroupChatMode) {
const pathInfo =
(prevPathIsGroupChatInfo ? '/groupChatInfo' : '') +
Expand All @@ -246,9 +275,15 @@ export const CreateGroupChatView = (props) => {
}
};

const handleCreateGroupChatBackButton = () => {
if (!isEditGroupChatMode) {
history.push('/sessions/consultant/sessionView');
}
};

const chatTopicInputItem: InputFieldItem = {
name: 'chatTopic',
class: 'creatChat__name__input',
class: 'createChat__name__input',
id: 'chatTopic',
type: 'text',
label: translate(chatTopicLabel),
Expand Down Expand Up @@ -280,6 +315,10 @@ export const CreateGroupChatView = (props) => {
setSelectedDuration(selectedOption.value);
};

const handleAgencySelect = (selectedOption) => {
setSelectedAgency(parseInt(selectedOption.value));
};

const getOptionOfSelectedDuration = useCallback(() => {
return durationSelectOptionsSet
.map((option) => ({ ...option, label: translate(option.label) }))
Expand Down Expand Up @@ -311,6 +350,32 @@ export const CreateGroupChatView = (props) => {
[getOptionOfSelectedDuration, translate]
);

const getOptionOfSelectedAgency = useCallback(() => {
const agency = agencies.find((agency) => agency.id === selectedAgency);
return agency
? {
value: agency.id.toString(),
label: agency.name
}
: null;
}, [agencies, selectedAgency]);

const agencySelectDropdown = useMemo<SelectDropdownItem>(
() => ({
id: 'agency',
selectedOptions: agencies.map(({ id, name }) => ({
value: id.toString(),
label: name
})),
defaultValue: getOptionOfSelectedAgency(),
handleDropdownSelect: handleAgencySelect,
selectInputLabel: translate('groupChat.create.agencySelect.label'),
isSearchable: true,
menuPlacement: 'bottom'
}),
[agencies, getOptionOfSelectedAgency, translate]
);

const repetitiveCheckboxItem = useMemo<CheckboxItem>(
() => ({
inputId: 'isRepetitiveChat',
Expand Down Expand Up @@ -423,7 +488,9 @@ export const CreateGroupChatView = (props) => {
startDate: getValidDateFormatForSelectedDate(selectedDate),
startTime: getValidTimeFormatForSelectedTime(selectedTime),
duration: parseInt(selectedDuration),
agencyId: selectedAgency,
repetitive: selectedRepetitive,
hintMessage,
featureGroupChatV2Enabled
};

Expand All @@ -433,7 +500,9 @@ export const CreateGroupChatView = (props) => {
}, [
createGroupChat,
featureGroupChatV2Enabled,
hintMessage,
isEditGroupChatMode,
selectedAgency,
selectedChatTopic,
selectedDate,
selectedDuration,
Expand Down Expand Up @@ -483,7 +552,7 @@ export const CreateGroupChatView = (props) => {
<div className="createChat__header createChat__header--edit">
<div className="createChat__header__inner">
<span
onClick={handleBackButton}
onClick={handleEditGroupChatBackButton}
className="createChat__header__backButton"
>
<BackIcon />
Expand All @@ -500,7 +569,7 @@ export const CreateGroupChatView = (props) => {
<div className="createChat__header">
<div className="createChat__header__inner">
<span
onClick={handleBackButton}
onClick={handleEditGroupChatBackButton}
className="createChat__header__backButton"
>
<BackIcon />
Expand All @@ -514,6 +583,7 @@ export const CreateGroupChatView = (props) => {
</p>
</div>
)}

<form id="createChatForm" className="createChat__content">
<InputField
item={chatTopicInputItem}
Expand Down Expand Up @@ -541,6 +611,7 @@ export const CreateGroupChatView = (props) => {
{translate('groupChat.create.dateInput.label')}
</span>
</div>

<div className="formWrapper react-datepicker--time">
<DatePicker
selected={selectedTime}
Expand All @@ -565,32 +636,64 @@ export const CreateGroupChatView = (props) => {
{translate('groupChat.create.beginDateInput.label')}
</span>
</div>

<SelectDropdown {...durationSelectDropdown} />

{!isEditGroupChatMode && (
<SelectDropdown {...agencySelectDropdown} />
)}

<div className="createChat__textareaWrapper">
<Textarea
id="hintMessage"
value={hintMessage}
maxLength={300}
onChange={({ target: { value } }) =>
setHintMessage(value.slice(0, 300))
}
placeholder={translate(
'groupChat.create.hintMessage.label'
)}
/>
<p className="createChat__explanation">
{translate('groupChat.create.hintMessage.explanation')}
</p>
</div>

<Checkbox
item={repetitiveCheckboxItem}
checkboxHandle={() =>
setSelectedRepetitive(!selectedRepetitive)
}
/>
{isEditGroupChatMode ? (
<div className="createChat__buttonsWrapper">
<Button
item={buttonSetCancel}
buttonHandle={handleBackButton}
/>
<Button
item={buttonSetSave}
buttonHandle={handleCreateAndUpdateButton}
disabled={isSaveButtonDisabled}
/>
</div>
) : (
<Button
item={buttonSetCreate}
buttonHandle={handleCreateAndUpdateButton}
disabled={isCreateButtonDisabled}
/>
)}

<div className="createChat__buttonsWrapper">
{isEditGroupChatMode ? (
<>
<Button
item={buttonSetCancel}
buttonHandle={handleEditGroupChatBackButton}
/>
<Button
item={buttonSetSave}
buttonHandle={handleCreateAndUpdateButton}
disabled={isSaveButtonDisabled}
/>
</>
) : (
<>
<Button
item={buttonSetCancel}
buttonHandle={handleCreateGroupChatBackButton}
/>
<Button
item={buttonSetCreate}
buttonHandle={handleCreateAndUpdateButton}
disabled={isCreateButtonDisabled}
/>
</>
)}
</div>
</form>

{overlayActive && (
Expand Down
Loading
Loading