-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
confirm delete modal for removing documents and annexes
- Loading branch information
Showing
11 changed files
with
188 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import React, { useState } from 'react'; | ||
import { useIntl } from 'react-intl'; | ||
|
||
import Spinner from 'components/ui/spinner'; | ||
|
||
const ConfirmModal = ({ | ||
title, | ||
text, | ||
confirmText, | ||
cancelText, | ||
onCancel, | ||
onConfirm | ||
}) => { | ||
const intl = useIntl(); | ||
const [submitting, setSubmitting] = useState(false); | ||
const [errorMessage, setErrorMessage] = useState(null); | ||
const _cancelText = cancelText || intl.formatMessage({ id: 'cancel', defaultMessage: 'Cancel' }); | ||
const _confirmText = confirmText || intl.formatMessage({ id: 'confirm', defaultMessage: 'Confirm' }); | ||
|
||
const handleConfirm = () => { | ||
setSubmitting(true); | ||
onConfirm({ | ||
onSuccess: () => { | ||
setErrorMessage(null); | ||
}, | ||
onError: (errorMessage) => { | ||
setSubmitting(false); | ||
setErrorMessage(errorMessage); | ||
} | ||
}); | ||
}; | ||
|
||
return ( | ||
<div className="c-confirm-modal"> | ||
<Spinner | ||
isLoading={submitting} | ||
className="-tiny" | ||
/> | ||
|
||
{title && <h2 className="c-title -extrabig">{title}</h2>} | ||
<p className="c-text"> | ||
{text} | ||
</p> | ||
<p className="c-text -error"> | ||
{errorMessage} | ||
</p> | ||
<div className="actions"> | ||
<button className="c-button -primary" data-test-id="confirm-modal-cancel" onClick={onCancel}> | ||
{_cancelText} | ||
</button> | ||
<button className="c-button -dangerous" data-test-id="confirm-modal-confirm" onClick={handleConfirm}> | ||
{_confirmText} | ||
</button> | ||
</div> | ||
</div> | ||
) | ||
}; | ||
|
||
export default ConfirmModal; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
.c-confirm-modal { | ||
padding: 20px; | ||
|
||
p { | ||
font-size: $font-size-big; | ||
} | ||
|
||
p.-error { | ||
color: $color-error; | ||
font-size: $font-size-default; | ||
} | ||
|
||
.actions { | ||
display: flex; | ||
margin-top: 30px; | ||
gap: 20px; | ||
justify-content: flex-end; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.