2020-05-27 21:37:06 +00:00
|
|
|
import * as React from 'react';
|
2020-07-29 23:20:05 +00:00
|
|
|
import { ContactName, PropsType as ContactNameProps } from './ContactName';
|
2020-05-27 21:37:06 +00:00
|
|
|
import { ConfirmationModal } from '../ConfirmationModal';
|
|
|
|
import { Intl } from '../Intl';
|
|
|
|
import { LocalizerType } from '../../types/Util';
|
|
|
|
|
|
|
|
export enum MessageRequestState {
|
|
|
|
blocking,
|
|
|
|
deleting,
|
|
|
|
unblocking,
|
|
|
|
default,
|
|
|
|
}
|
|
|
|
|
|
|
|
export type Props = {
|
|
|
|
i18n: LocalizerType;
|
|
|
|
conversationType: 'group' | 'direct';
|
|
|
|
isBlocked?: boolean;
|
|
|
|
onBlock(): unknown;
|
|
|
|
onBlockAndDelete(): unknown;
|
|
|
|
onUnblock(): unknown;
|
|
|
|
onDelete(): unknown;
|
|
|
|
state: MessageRequestState;
|
|
|
|
onChangeState(state: MessageRequestState): unknown;
|
2020-07-24 01:35:32 +00:00
|
|
|
} & Omit<ContactNameProps, 'module' | 'i18n'>;
|
2020-05-27 21:37:06 +00:00
|
|
|
|
|
|
|
// tslint:disable-next-line: max-func-body-length
|
|
|
|
export const MessageRequestActionsConfirmation = ({
|
2020-07-29 23:20:05 +00:00
|
|
|
conversationType,
|
2020-05-27 21:37:06 +00:00
|
|
|
i18n,
|
|
|
|
name,
|
|
|
|
onBlock,
|
|
|
|
onBlockAndDelete,
|
2020-07-29 23:20:05 +00:00
|
|
|
onChangeState,
|
2020-05-27 21:37:06 +00:00
|
|
|
onDelete,
|
2020-07-29 23:20:05 +00:00
|
|
|
onUnblock,
|
|
|
|
phoneNumber,
|
|
|
|
profileName,
|
2020-05-27 21:37:06 +00:00
|
|
|
state,
|
2020-07-29 23:20:05 +00:00
|
|
|
title,
|
2020-05-27 21:37:06 +00:00
|
|
|
}: Props) => {
|
|
|
|
if (state === MessageRequestState.blocking) {
|
|
|
|
return (
|
|
|
|
// tslint:disable-next-line: use-simple-attributes
|
|
|
|
<ConfirmationModal
|
|
|
|
i18n={i18n}
|
|
|
|
onClose={() => {
|
|
|
|
onChangeState(MessageRequestState.default);
|
|
|
|
}}
|
|
|
|
title={
|
|
|
|
<Intl
|
|
|
|
i18n={i18n}
|
|
|
|
id={`MessageRequests--block-${conversationType}-confirm-title`}
|
|
|
|
components={[
|
|
|
|
<ContactName
|
|
|
|
key="name"
|
|
|
|
name={name}
|
|
|
|
profileName={profileName}
|
|
|
|
phoneNumber={phoneNumber}
|
2020-07-24 01:35:32 +00:00
|
|
|
title={title}
|
|
|
|
i18n={i18n}
|
2020-05-27 21:37:06 +00:00
|
|
|
/>,
|
|
|
|
]}
|
|
|
|
/>
|
|
|
|
}
|
|
|
|
actions={[
|
|
|
|
{
|
|
|
|
text: i18n('MessageRequests--block'),
|
|
|
|
action: onBlock,
|
|
|
|
style: 'negative',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text: i18n('MessageRequests--block-and-delete'),
|
|
|
|
action: onBlockAndDelete,
|
|
|
|
style: 'negative',
|
|
|
|
},
|
|
|
|
]}
|
|
|
|
>
|
|
|
|
{i18n(`MessageRequests--block-${conversationType}-confirm-body`)}
|
|
|
|
</ConfirmationModal>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (state === MessageRequestState.unblocking) {
|
|
|
|
return (
|
|
|
|
// tslint:disable-next-line: use-simple-attributes
|
|
|
|
<ConfirmationModal
|
|
|
|
i18n={i18n}
|
|
|
|
onClose={() => {
|
|
|
|
onChangeState(MessageRequestState.default);
|
|
|
|
}}
|
|
|
|
title={
|
|
|
|
<Intl
|
|
|
|
i18n={i18n}
|
|
|
|
id={'MessageRequests--unblock-confirm-title'}
|
|
|
|
components={[
|
|
|
|
<ContactName
|
|
|
|
key="name"
|
|
|
|
name={name}
|
|
|
|
profileName={profileName}
|
|
|
|
phoneNumber={phoneNumber}
|
2020-07-24 01:35:32 +00:00
|
|
|
title={title}
|
|
|
|
i18n={i18n}
|
2020-05-27 21:37:06 +00:00
|
|
|
/>,
|
|
|
|
]}
|
|
|
|
/>
|
|
|
|
}
|
|
|
|
actions={[
|
|
|
|
{
|
|
|
|
text: i18n('MessageRequests--unblock'),
|
|
|
|
action: onUnblock,
|
|
|
|
style: 'affirmative',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text: i18n('MessageRequests--delete'),
|
|
|
|
action: onDelete,
|
|
|
|
style: 'negative',
|
|
|
|
},
|
|
|
|
]}
|
|
|
|
>
|
|
|
|
{i18n(`MessageRequests--unblock-${conversationType}-confirm-body`)}
|
|
|
|
</ConfirmationModal>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (state === MessageRequestState.deleting) {
|
|
|
|
return (
|
|
|
|
// tslint:disable-next-line: use-simple-attributes
|
|
|
|
<ConfirmationModal
|
|
|
|
i18n={i18n}
|
|
|
|
onClose={() => {
|
|
|
|
onChangeState(MessageRequestState.default);
|
|
|
|
}}
|
|
|
|
title={
|
|
|
|
<Intl
|
|
|
|
i18n={i18n}
|
|
|
|
id={`MessageRequests--delete-${conversationType}-confirm-title`}
|
|
|
|
components={[
|
|
|
|
<ContactName
|
|
|
|
key="name"
|
|
|
|
name={name}
|
|
|
|
profileName={profileName}
|
|
|
|
phoneNumber={phoneNumber}
|
2020-07-24 01:35:32 +00:00
|
|
|
title={title}
|
|
|
|
i18n={i18n}
|
2020-05-27 21:37:06 +00:00
|
|
|
/>,
|
|
|
|
]}
|
|
|
|
/>
|
|
|
|
}
|
|
|
|
actions={[
|
|
|
|
{
|
|
|
|
text: i18n(`MessageRequests--delete-${conversationType}`),
|
|
|
|
action: onDelete,
|
|
|
|
style: 'negative',
|
|
|
|
},
|
|
|
|
]}
|
|
|
|
>
|
|
|
|
{i18n(`MessageRequests--delete-${conversationType}-confirm-body`)}
|
|
|
|
</ConfirmationModal>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
};
|