transaction modal

This commit is contained in:
Elijah Lucian 2021-07-17 11:58:48 -06:00
parent 4a1507eba4
commit 433de53f74
3 changed files with 27 additions and 10 deletions

View File

@ -31,6 +31,11 @@ export const TransactionForm = ({ stackId, onSave, onCancel }: Props) => {
onSave?.() onSave?.()
} }
const handleCancel = () => {
console.log('cancelling')
onCancel?.()
}
return ( return (
<Form <Form
form={form} form={form}
@ -45,7 +50,7 @@ export const TransactionForm = ({ stackId, onSave, onCancel }: Props) => {
<Input /> <Input />
</FormItem> </FormItem>
<Row> <Row>
<Button onClick={onCancel}>Cancel</Button> <Button onClick={handleCancel}>Cancel</Button>
<Button htmlType="submit">Save</Button> <Button htmlType="submit">Save</Button>
</Row> </Row>
</Form> </Form>

View File

@ -1,5 +1,5 @@
import { ModalProps } from 'antd' import { ModalProps } from 'antd'
import { ReactElement, cloneElement } from 'react' import { ReactElement } from 'react'
import './style.scss' import './style.scss'
type Props = ModalProps & { children: ReactElement } type Props = ModalProps & { children: ReactElement }
@ -10,7 +10,5 @@ export type DankFormProps = {
} }
export const Modal = ({ children, visible }: Props) => { export const Modal = ({ children, visible }: Props) => {
const el = cloneElement(children, (props: DankFormProps) => ({ ...props })) return visible ? <div className="dank-modal">{children}</div> : null
return visible ? <div className="dank-modal">{el}</div> : null
} }

View File

@ -1,9 +1,10 @@
import { Stack } from '../../types'
import './style.scss'
import _ from 'lodash'
import { useState } from 'react' import { useState } from 'react'
import { Modal } from '../../layout/Modal' import { Modal } from '../../layout/Modal'
import { TransactionForm } from '../../forms/TransactionForm' import { TransactionForm } from '../../forms/TransactionForm'
import { Stack } from '../../types'
import _ from 'lodash'
import './style.scss'
type Props = { type Props = {
stack: Stack stack: Stack
@ -22,6 +23,15 @@ export const FundBar = ({ stack }: Props) => {
setNewTx(true) setNewTx(true)
} }
const handleCancel = () => {
console.log('cancelling tx')
setNewTx(false)
}
const handleSave = () => {
console.log('tx saved!')
}
return ( return (
<> <>
<div className="fundbar"> <div className="fundbar">
@ -39,8 +49,12 @@ export const FundBar = ({ stack }: Props) => {
${Math.floor(current)} / ${max} ${Math.floor(current)} / ${max}
</div> </div>
</div> </div>
<Modal visible={newTx} onCancel={() => setNewTx(false)}> <Modal visible={newTx}>
<TransactionForm stackId={stack.id} /> <TransactionForm
stackId={stack.id}
onSave={handleSave}
onCancel={handleCancel}
/>
</Modal> </Modal>
</> </>
) )