2021-03-20 16:51:34 +01:00
|
|
|
import React from 'react';
|
2021-11-13 14:15:31 +01:00
|
|
|
import { useIntl } from 'react-intl';
|
2021-10-14 17:13:12 +02:00
|
|
|
|
2021-10-27 13:28:06 +02:00
|
|
|
import { Dialog, DialogBody, DialogFooter } from '@strapi/design-system/Dialog';
|
|
|
|
import { Flex } from '@strapi/design-system/Flex';
|
|
|
|
import { Text } from '@strapi/design-system/Text';
|
|
|
|
import { Stack } from '@strapi/design-system/Stack';
|
|
|
|
import { Button } from '@strapi/design-system/Button';
|
2021-11-19 19:39:57 +01:00
|
|
|
import ExclamationMarkCircle from '@strapi/icons/ExclamationMarkCircle';
|
2021-03-20 16:51:34 +01:00
|
|
|
|
|
|
|
const ConfirmModal = ({ isOpen, onClose, onSubmit, type }) => {
|
2021-11-13 14:15:31 +01:00
|
|
|
const { formatMessage } = useIntl();
|
|
|
|
|
2021-03-21 17:55:14 +01:00
|
|
|
if (!isOpen) return null;
|
|
|
|
|
2021-03-20 16:51:34 +01:00
|
|
|
return (
|
2021-10-14 17:13:12 +02:00
|
|
|
<Dialog
|
|
|
|
onClose={onClose}
|
|
|
|
title="Confirmation"
|
2021-03-20 16:51:34 +01:00
|
|
|
isOpen={isOpen}
|
2021-10-14 17:13:12 +02:00
|
|
|
>
|
2021-11-19 19:39:57 +01:00
|
|
|
<DialogBody icon={<ExclamationMarkCircle />}>
|
2021-10-14 17:13:12 +02:00
|
|
|
<Stack size={2}>
|
2021-10-27 13:28:06 +02:00
|
|
|
<Flex justifyContent="center">
|
2021-11-13 14:15:31 +01:00
|
|
|
<Text id="confirm-description" style={{ textAlign: 'center' }}>
|
|
|
|
{formatMessage({ id: `config-sync.popUpWarning.warning.${type}_1` })}<br />
|
|
|
|
{formatMessage({ id: `config-sync.popUpWarning.warning.${type}_2` })}
|
|
|
|
</Text>
|
2021-10-27 13:28:06 +02:00
|
|
|
</Flex>
|
2021-10-14 17:13:12 +02:00
|
|
|
</Stack>
|
|
|
|
</DialogBody>
|
|
|
|
<DialogFooter
|
|
|
|
startAction={(
|
|
|
|
<Button
|
|
|
|
onClick={() => {
|
|
|
|
onClose();
|
|
|
|
}}
|
|
|
|
variant="tertiary"
|
|
|
|
>
|
2021-11-13 14:15:31 +01:00
|
|
|
{formatMessage({ id: 'config-sync.popUpWarning.button.cancel' })}
|
2021-10-14 17:13:12 +02:00
|
|
|
</Button>
|
|
|
|
)}
|
|
|
|
endAction={(
|
2021-11-13 14:15:31 +01:00
|
|
|
<Button
|
|
|
|
variant="secondary"
|
|
|
|
onClick={() => {
|
|
|
|
onClose();
|
|
|
|
onSubmit();
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
{formatMessage({ id: `config-sync.popUpWarning.button.${type}` })}
|
2021-10-14 17:13:12 +02:00
|
|
|
</Button>
|
|
|
|
)} />
|
|
|
|
</Dialog>
|
2021-03-20 16:51:34 +01:00
|
|
|
);
|
2021-10-14 17:13:12 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
export default ConfirmModal;
|