Skip to content

Commit

Permalink
Schema fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaron-9900 committed May 2, 2021
1 parent f7a6638 commit 1c5ec72
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/components/folder-schema/folder-schema.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export const FolderSchema = (props: FolderSchemaProps): JSX.Element => {
{schema?.children.map((child) => {
return (
<StyledListItem
key={child.path}
key={child.name + child.path}
onClick={() => onFolderClick(child)}
extra={child.isDirectory ? <FolderFilled /> : null}
>
Expand Down
28 changes: 23 additions & 5 deletions src/components/items-list/item-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,19 @@ export const ItemList = observer(
rate,
balance,
} = props
const [modalOpen, setModalOpen] = useState(false)
type ModalState = { [index: number]: boolean }
const firstState = items.submissions.reduce((cb, element) => {
cb[element.id] = false
return cb
}, {} as ModalState)
const [modalOpen, setModalOpen] = useState<ModalState>(firstState)
function toggleModal(id: number, value: boolean) {
setModalOpen((prevValue) => {
const newState = { ...prevValue }
newState[id] = value
return { ...newState }
})
}
return (
<List itemLayout="vertical">
{items.submissions.map((submission: SubmissionModel) => {
Expand All @@ -105,7 +117,7 @@ export const ItemList = observer(
status={submission.submissionStatus}
action="accepted"
icon={CheckOutlined}
onClick={() => setModalOpen(true)}
onClick={(value: boolean) => toggleModal(submission.id, true)}
key="list-vertical-like-o"
/>,
<StyledIconText
Expand All @@ -127,11 +139,17 @@ export const ItemList = observer(
)
return resp
}}
visible={modalOpen}
setVisible={setModalOpen}
visible={modalOpen[submission.id]}
setVisible={(value: boolean) => toggleModal(submission.id, value)}
onCancel={() => null}
modalPrimaryText={""}
InnerComponent={() => <Payment yourValue={balance ?? 0} yourPayment={rate ?? 0} id={submission.id.toString()}/>}
InnerComponent={() => (
<Payment
yourValue={balance ?? 0}
yourPayment={rate ?? 0}
id={submission.id.toString()}
/>
)}
/>
<List.Item.Meta
avatar={
Expand Down
1 change: 0 additions & 1 deletion src/components/modals/async-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ export const AsyncModal = (props: AsyncModalProps): JSX.Element => {
onCancel()
setVisible(false)
}

return (
<>
<Modal
Expand Down

0 comments on commit 1c5ec72

Please sign in to comment.