Skip to content

Commit

Permalink
chore: cleaned group chat rule logic
Browse files Browse the repository at this point in the history
  • Loading branch information
web-mi committed Jan 16, 2024
1 parent 4cea5c2 commit bed9b25
Showing 1 changed file with 9 additions and 26 deletions.
35 changes: 9 additions & 26 deletions src/components/groupChat/JoinGroupChatView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -313,32 +313,15 @@ export const JoinGroupChatView = ({
return <Redirect to={listPath + getSessionListTab()} />;
}

let groupChatRules: [string?] = [];
const hasGroupChatRulesTranslations = i18n.exists(
`consultingType.${consultingType?.id}.groupChatRules.0`,
{ ns: 'consultingTypes' }
);
const hasGroupChatRulesTranslationsRule = i18n.exists('groupChat.rules.0');
if (hasGroupChatRulesTranslations || hasGroupChatRulesTranslationsRule) {
for (let i = 0; i < 10; i++) {
if (
i18n.exists(
`consultingType.${consultingType?.id}.groupChatRules.${i}`,
{ ns: 'consultingTypes' }
)
) {
groupChatRules.push(
translate(
`consultingType.${consultingType?.id}.groupChatRules.${i}`,
{ ns: 'consultingTypes' }
)
);
} else if (i18n.exists(`groupChat.rules.${i}`)) {
groupChatRules.push(translate(`groupChat.rules.${i}`));
}
}
} else {
groupChatRules = consultingType?.groupChat?.groupChatRules ?? [];
let groupChatRules: string[] =
consultingType?.groupChat?.groupChatRules ?? [];
const transKey = `consultingType.${
consultingType?.id ?? 'noConsultingType'
}.groupChatRules`;
const translatedRules: { [key: string]: string } =
i18n.getResource(i18n.language, 'consultingTypes', transKey) || {};
if (Object.keys(translatedRules).length > 0) {
groupChatRules = Object.values(translatedRules);
}

return (
Expand Down

0 comments on commit bed9b25

Please sign in to comment.