Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions frontend/src/components/Dialogs/CancelOrder.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import React from 'react';
import { useTranslation } from 'react-i18next';
import {
Dialog,
DialogTitle,
DialogActions,
DialogContent,
DialogContentText,
Button,
} from '@mui/material';

interface Props {
open: boolean;
onClose: () => void;
onAccept: () => void;
}

const CancelOrderDialog = ({ open, onClose, onAccept }: Props): JSX.Element => {
const { t } = useTranslation();

return (
<Dialog open={open} onClose={onClose}>
<DialogTitle>{t('Cancel the order?')}</DialogTitle>

<DialogContent>
<DialogContentText>
{t(
'If the order is cancelled now but you already tried to pay the invoice, you might loose your bond.',
)}
</DialogContentText>
</DialogContent>

<DialogActions>
<Button
onClick={() => {
onClose();
}}
>
{t('Back')}
</Button>
<Button onClick={onAccept}>{t('Confirm cancellation')}</Button>
</DialogActions>
</Dialog>
);
};

export default CancelOrderDialog;
25 changes: 18 additions & 7 deletions frontend/src/components/TradeBox/CancelButton.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import React from 'react';
import React, { useState } from 'react';
import { useTranslation } from 'react-i18next';
import { Box, Tooltip } from '@mui/material';
import { type Order } from '../../models';
import { LoadingButton } from '@mui/lab';
import CancelOrderDialog from '../Dialogs/CancelOrder';

interface CancelButtonProps {
order: Order | null;
Expand All @@ -20,6 +21,7 @@ const CancelButton = ({
loading = false,
}: CancelButtonProps): JSX.Element => {
const { t } = useTranslation();
const [openCancelWarning, setOpenCancelWarning] = useState<boolean>(false);

const showCancelButton =
Boolean(order?.is_maker && [0, 1, 2].includes(order?.status)) ||
Expand All @@ -37,19 +39,21 @@ const CancelButton = ({
enterTouchDelay={500}
enterDelay={700}
enterNextDelay={2000}
title={
noConfirmation
? t('Cancel order and unlock bond instantly')
: t('Unilateral cancelation (bond at risk!)')
}
title={noConfirmation ? t('Cancel order') : t('Unilateral cancelation (bond at risk!)')}
>
<div>
<LoadingButton
size='small'
loading={loading}
variant='outlined'
color='secondary'
onClick={noConfirmation ? onClickCancel : openCancelDialog}
onClick={
noConfirmation
? () => {
setOpenCancelWarning(true);
}
: openCancelDialog
}
>
{t('Cancel')}
</LoadingButton>
Expand All @@ -58,6 +62,13 @@ const CancelButton = ({
) : (
<></>
)}
<CancelOrderDialog
open={openCancelWarning}
onClose={() => {
setOpenCancelWarning(false);
}}
onAccept={onClickCancel}
/>
{showCollabCancelButton ? (
<LoadingButton
size='small'
Expand Down
141 changes: 72 additions & 69 deletions frontend/static/locales/ca.json

Large diffs are not rendered by default.

141 changes: 72 additions & 69 deletions frontend/static/locales/cs.json

Large diffs are not rendered by default.

141 changes: 72 additions & 69 deletions frontend/static/locales/de.json

Large diffs are not rendered by default.

141 changes: 72 additions & 69 deletions frontend/static/locales/en.json

Large diffs are not rendered by default.

141 changes: 72 additions & 69 deletions frontend/static/locales/es.json

Large diffs are not rendered by default.

141 changes: 72 additions & 69 deletions frontend/static/locales/eu.json

Large diffs are not rendered by default.

141 changes: 72 additions & 69 deletions frontend/static/locales/fr.json

Large diffs are not rendered by default.

141 changes: 72 additions & 69 deletions frontend/static/locales/it.json

Large diffs are not rendered by default.

141 changes: 72 additions & 69 deletions frontend/static/locales/ja.json

Large diffs are not rendered by default.

141 changes: 72 additions & 69 deletions frontend/static/locales/pl.json

Large diffs are not rendered by default.

141 changes: 72 additions & 69 deletions frontend/static/locales/pt.json

Large diffs are not rendered by default.

141 changes: 72 additions & 69 deletions frontend/static/locales/ru.json

Large diffs are not rendered by default.

141 changes: 72 additions & 69 deletions frontend/static/locales/sv.json

Large diffs are not rendered by default.

141 changes: 72 additions & 69 deletions frontend/static/locales/sw.json

Large diffs are not rendered by default.

141 changes: 72 additions & 69 deletions frontend/static/locales/th.json

Large diffs are not rendered by default.

141 changes: 72 additions & 69 deletions frontend/static/locales/zh-SI.json

Large diffs are not rendered by default.

141 changes: 72 additions & 69 deletions frontend/static/locales/zh-TR.json

Large diffs are not rendered by default.