2023-01-03 19:55:46 +00:00
|
|
|
// Copyright 2021 Signal Messenger, LLC
|
2021-03-11 21:29:31 +00:00
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2022-11-18 00:45:19 +00:00
|
|
|
import type { ReactNode } from 'react';
|
2021-10-26 19:15:33 +00:00
|
|
|
import React from 'react';
|
2021-03-11 21:29:31 +00:00
|
|
|
|
2021-10-26 19:15:33 +00:00
|
|
|
import type { LocalizerType } from '../types/Util';
|
2021-03-11 21:29:31 +00:00
|
|
|
import { Alert } from './Alert';
|
|
|
|
import { missingCaseError } from '../util/missingCaseError';
|
|
|
|
|
|
|
|
export enum AddGroupMemberErrorDialogMode {
|
|
|
|
MaximumGroupSize,
|
|
|
|
RecommendedMaximumGroupSize,
|
|
|
|
}
|
|
|
|
|
|
|
|
type PropsDataType =
|
|
|
|
| {
|
|
|
|
mode: AddGroupMemberErrorDialogMode.MaximumGroupSize;
|
|
|
|
maximumNumberOfContacts: number;
|
|
|
|
}
|
|
|
|
| {
|
|
|
|
mode: AddGroupMemberErrorDialogMode.RecommendedMaximumGroupSize;
|
|
|
|
recommendedMaximumNumberOfContacts: number;
|
|
|
|
};
|
|
|
|
|
|
|
|
type PropsType = {
|
|
|
|
i18n: LocalizerType;
|
|
|
|
onClose: () => void;
|
|
|
|
} & PropsDataType;
|
|
|
|
|
2022-11-18 00:45:19 +00:00
|
|
|
export function AddGroupMemberErrorDialog(props: PropsType): JSX.Element {
|
2022-03-22 20:45:34 +00:00
|
|
|
const { i18n, onClose } = props;
|
|
|
|
|
|
|
|
let title: string;
|
|
|
|
let body: ReactNode;
|
|
|
|
switch (props.mode) {
|
|
|
|
case AddGroupMemberErrorDialogMode.MaximumGroupSize: {
|
|
|
|
const { maximumNumberOfContacts } = props;
|
2023-03-30 00:03:25 +00:00
|
|
|
title = i18n('icu:chooseGroupMembers__maximum-group-size__title');
|
|
|
|
body = i18n('icu:chooseGroupMembers__maximum-group-size__body', {
|
2023-04-03 19:03:00 +00:00
|
|
|
max: maximumNumberOfContacts,
|
2023-03-27 23:37:39 +00:00
|
|
|
});
|
2022-03-22 20:45:34 +00:00
|
|
|
break;
|
2021-03-11 21:29:31 +00:00
|
|
|
}
|
2022-03-22 20:45:34 +00:00
|
|
|
case AddGroupMemberErrorDialogMode.RecommendedMaximumGroupSize: {
|
|
|
|
const { recommendedMaximumNumberOfContacts } = props;
|
2023-03-30 00:03:25 +00:00
|
|
|
title = i18n(
|
|
|
|
'icu:chooseGroupMembers__maximum-recommended-group-size__title'
|
|
|
|
);
|
|
|
|
body = i18n(
|
|
|
|
'icu:chooseGroupMembers__maximum-recommended-group-size__body',
|
|
|
|
{
|
2023-04-03 19:03:00 +00:00
|
|
|
max: recommendedMaximumNumberOfContacts,
|
2023-03-30 00:03:25 +00:00
|
|
|
}
|
|
|
|
);
|
2022-03-22 20:45:34 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
throw missingCaseError(props);
|
|
|
|
}
|
2021-03-11 21:29:31 +00:00
|
|
|
|
2022-03-22 20:45:34 +00:00
|
|
|
return <Alert body={body} i18n={i18n} onClose={onClose} title={title} />;
|
2022-11-18 00:45:19 +00:00
|
|
|
}
|