2021-05-28 19:11:19 +00:00
|
|
|
// Copyright 2021 Signal Messenger, LLC
|
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2021-10-26 19:15:33 +00:00
|
|
|
import type { ReactElement } from 'react';
|
|
|
|
import React, { useCallback, useState } from 'react';
|
2021-05-28 19:11:19 +00:00
|
|
|
|
2021-08-26 20:51:55 +00:00
|
|
|
import { Button, ButtonSize, ButtonVariant } from '../Button';
|
2021-09-07 19:55:03 +00:00
|
|
|
import { SystemMessage } from './SystemMessage';
|
2021-10-26 19:15:33 +00:00
|
|
|
import type { ConversationType } from '../../state/ducks/conversations';
|
|
|
|
import type { LocalizerType } from '../../types/Util';
|
2021-05-28 19:11:19 +00:00
|
|
|
import { Intl } from '../Intl';
|
|
|
|
import { Emojify } from './Emojify';
|
|
|
|
|
|
|
|
import { DeliveryIssueDialog } from './DeliveryIssueDialog';
|
|
|
|
|
|
|
|
export type PropsDataType = {
|
|
|
|
sender?: ConversationType;
|
2021-07-27 20:30:41 +00:00
|
|
|
inGroup: boolean;
|
2021-05-28 19:11:19 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
type PropsHousekeepingType = {
|
|
|
|
i18n: LocalizerType;
|
|
|
|
};
|
|
|
|
|
2022-12-21 03:25:10 +00:00
|
|
|
export type PropsType = PropsDataType & PropsHousekeepingType;
|
2021-05-28 19:11:19 +00:00
|
|
|
|
|
|
|
export function DeliveryIssueNotification(
|
|
|
|
props: PropsType
|
|
|
|
): ReactElement | null {
|
2022-12-21 03:25:10 +00:00
|
|
|
const { i18n, inGroup, sender } = props;
|
2021-05-28 19:11:19 +00:00
|
|
|
const [isDialogOpen, setIsDialogOpen] = useState<boolean>(false);
|
|
|
|
|
|
|
|
const openDialog = useCallback(() => {
|
|
|
|
setIsDialogOpen(true);
|
|
|
|
}, [setIsDialogOpen]);
|
|
|
|
const closeDialog = useCallback(() => {
|
|
|
|
setIsDialogOpen(false);
|
|
|
|
}, [setIsDialogOpen]);
|
|
|
|
|
|
|
|
if (!sender) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
2021-09-07 19:55:03 +00:00
|
|
|
<>
|
|
|
|
<SystemMessage
|
|
|
|
contents={
|
2021-09-02 17:34:00 +00:00
|
|
|
<Intl
|
|
|
|
id="DeliveryIssue--notification"
|
|
|
|
components={{
|
|
|
|
sender: <Emojify text={sender.firstName || sender.title} />,
|
|
|
|
}}
|
|
|
|
i18n={i18n}
|
|
|
|
/>
|
2021-09-07 19:55:03 +00:00
|
|
|
}
|
|
|
|
icon="info"
|
|
|
|
button={
|
|
|
|
<Button
|
|
|
|
onClick={openDialog}
|
|
|
|
size={ButtonSize.Small}
|
|
|
|
variant={ButtonVariant.SystemMessage}
|
|
|
|
>
|
|
|
|
{i18n('DeliveryIssue--learnMore')}
|
|
|
|
</Button>
|
|
|
|
}
|
|
|
|
/>
|
2021-05-28 19:11:19 +00:00
|
|
|
{isDialogOpen ? (
|
|
|
|
<DeliveryIssueDialog
|
|
|
|
i18n={i18n}
|
2021-07-27 20:30:41 +00:00
|
|
|
inGroup={inGroup}
|
2021-05-28 19:11:19 +00:00
|
|
|
sender={sender}
|
|
|
|
onClose={closeDialog}
|
|
|
|
/>
|
|
|
|
) : null}
|
2021-09-07 19:55:03 +00:00
|
|
|
</>
|
2021-05-28 19:11:19 +00:00
|
|
|
);
|
|
|
|
}
|