Skip to content

Commit

Permalink
refactor: Adapt confirm dialig for save and delete case.
Browse files Browse the repository at this point in the history
  • Loading branch information
mheggelund committed Feb 27, 2024
1 parent 380a0e8 commit 56c979a
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 8 deletions.
11 changes: 11 additions & 0 deletions src/components/ConfirmDialog/ConfirmDialog.styled.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { Dialog } from '@equinor/eds-core-react';
import styled from 'styled-components';
import { spacings } from '../../tokens/spacings';

export const Actions = styled(Dialog.Actions)`
display: flex;
flex: row;
flex-direction: row;
column-gap: ${spacings.SMALL};
align-items: start;
`;
22 changes: 14 additions & 8 deletions src/components/ConfirmDialog/ConfirmDialog.tsx
Original file line number Diff line number Diff line change
@@ -1,30 +1,36 @@
import { Button, Dialog, Typography } from '@equinor/eds-core-react';
import * as Styled from './ConfirmDialog.styled';

export const ConfirmDialog = ({
isOpen,
message,
danger,
confirmAction,
setIsOpen,
}: {
isOpen: boolean;
message: string;
danger: boolean;
confirmAction: () => void;
setIsOpen: React.Dispatch<React.SetStateAction<boolean>>;
}) => {
return (
<Dialog open={isOpen}>
<Dialog.Header>
<Dialog.Title>Confirm</Dialog.Title>
</Dialog.Header>
<Dialog.CustomContent>
<Typography variant="body_short">{message}</Typography>
</Dialog.CustomContent>
<Dialog.Actions>
<Button onClick={confirmAction}>OK</Button>
<Button variant="ghost" onClick={() => setIsOpen(false)}>
Cancel
<Styled.Actions>
<Button
variant="outlined"
color={danger ? 'danger' : undefined}
onClick={() => setIsOpen(false)}
>
{'Cancle'}
</Button>
</Dialog.Actions>
<Button color={danger ? 'danger' : undefined} onClick={confirmAction}>
{danger ? 'Delete' : 'Ok'}
</Button>
</Styled.Actions>
</Dialog>
);
};
2 changes: 2 additions & 0 deletions src/features/Compute/CaseGroup/CaseButtons/CaseButtons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ export const CaseButtons = ({
<ConfirmDialog
isOpen={deleteConfirm}
message="By pressing OK, the case and belonging results will be deleted."
danger={true}
confirmAction={handleConfirmDelete}
setIsOpen={setDeleteConfirm}
></ConfirmDialog>
Expand All @@ -226,6 +227,7 @@ export const CaseButtons = ({
isOpen={saveConfirm}
message="By pressing OK, the current case will be overwritten, deleting old
results."
danger={false}
confirmAction={handleConfirmSave}
setIsOpen={setSaveConfirm}
></ConfirmDialog>
Expand Down

0 comments on commit 56c979a

Please sign in to comment.