Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add SchedulerConfirmationModal component for starting scheduled sweep #803

Merged
merged 4 commits into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
16 changes: 4 additions & 12 deletions src/components/Jam.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import FeeConfigModal from './settings/FeeConfigModal'

import styles from './Jam.module.css'
import { useFeeConfigValues } from '../hooks/Fees'
import SchedulerConfirmationModal from './SchedulerConfirmationModal'

const DEST_ADDRESS_COUNT_PROD = 3
const DEST_ADDRESS_COUNT_TEST = 1
Expand Down Expand Up @@ -535,19 +536,10 @@ export default function Jam({ wallet }: JamProps) {
})}

<p className="text-secondary mb-4">{t('scheduler.description_fees')}</p>

<rb.Button
className="w-100 mb-4"
variant="dark"
size="lg"
type="submit"
<SchedulerConfirmationModal
onConfirm={handleSubmit}
disabled={isOperationDisabled || isSubmitting || !isValid}
>
<div className="d-flex justify-content-center align-items-center">
{t('scheduler.button_start')}
<Sprite symbol="caret-right" width="24" height="24" className="ms-1" />
</div>
</rb.Button>
/>
</rb.Form>
</>
)}
Expand Down
6 changes: 6 additions & 0 deletions src/components/SchedulerConfirmationModal.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.modalFooter :global(.btn) {
flex-grow: 1;
min-height: 2.8rem;
font-weight: 500;
border-color: none !important;
}
46 changes: 46 additions & 0 deletions src/components/SchedulerConfirmationModal.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import * as rb from 'react-bootstrap'
import styles from './SchedulerConfirmationModal.module.css'
import { useState } from 'react'
import Sprite from './Sprite'
import { useTranslation } from 'react-i18next'

interface SchedulerConfirmationModalProps {
onConfirm: () => void
disabled: boolean
}

export default function SchedulerConfirmationModal({ onConfirm, disabled }: SchedulerConfirmationModalProps) {
const { t } = useTranslation()
const [show, setShow] = useState(false)

const handleClose = () => setShow(false)
const handleShow = () => setShow(true)

return (
<>
<rb.Button className="w-100 mb-4" variant="dark" size="lg" disabled={disabled} onClick={handleShow}>
<div className="d-flex justify-content-center align-items-center">
{t('scheduler.button_start')}
<Sprite symbol="caret-right" width="24" height="24" className="ms-1" />
</div>
</rb.Button>

<rb.Modal show={show} onHide={handleClose} dialogClassName={styles['modal']}>
<rb.Modal.Header closeButton>
<rb.Modal.Title>
<div>{t('scheduler.confirm_modal.title')}</div>
</rb.Modal.Title>
</rb.Modal.Header>
<rb.Modal.Body>{t('scheduler.confirm_modal.body')}</rb.Modal.Body>
<rb.Modal.Footer className={styles['modalFooter']}>
<rb.Button variant="light" onClick={handleClose} className="d-flex justify-content-center align-items-center">
{t('modal.confirm_button_reject')}
</rb.Button>
<rb.Button variant="dark" onClick={onConfirm}>
{t('modal.confirm_button_accept')}
</rb.Button>
</rb.Modal.Footer>
</rb.Modal>
</>
)
}
4 changes: 4 additions & 0 deletions src/i18n/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -659,6 +659,10 @@
"subtitle": "Successfully completed a single scheduled transaction.",
"subtitle_other": "Successfully completed {{ count }} scheduled transactions.",
"text_button_submit": "Continue"
},
"confirm_modal": {
"title": "Start Scheduled Sweep",
"body": "Are you sure you want to start the scheduled sweep?"
}
},
"modal": {
Expand Down