1
0
mirror of https://github.com/oceanprotocol/market.git synced 2024-12-02 05:57:29 +01:00
EnzoVezzaro 85b66c29b0
fix loading results on compute jobs (#1716)
* added interval and block spinner after initial loading

* refactor fetch jobs to fix loading issues

* restore compute jobs in profile

Co-authored-by: mihaisc <mihai.scarlat@smartcontrol.ro>
2022-10-10 15:55:37 +01:00

40 lines
973 B
TypeScript

import React, { ReactElement, ReactNode, useState } from 'react'
import Button from '@shared/atoms/Button'
import styles from './History.module.css'
import Caret from '@images/caret.svg'
export default function ComputeHistory({
title,
children,
refetchJobs
}: {
title: string
children: ReactNode
refetchJobs?: any
}): ReactElement {
const [open, setOpen] = useState(false)
async function handleClick() {
await refetchJobs(true)
setOpen(!open)
}
return (
<div className={`${styles.actions} ${open === true ? styles.open : ''}`}>
{/* TODO: onClick on h3 is nasty but we're in a hurry */}
<h3 className={styles.title} onClick={handleClick}>
{`${title} `}
<Button
style="text"
size="small"
onClick={handleClick}
className={styles.toggle}
>
{open ? 'Hide' : 'Show'} <Caret />
</Button>
</h3>
{open === true && children}
</div>
)
}