import React, { FC, useCallback, useMemo } from 'react'; import { useFetch } from '@gitroom/helpers/utils/custom.fetch'; import useSWR from 'swr'; export const OrderList: FC<{ type: 'seller' | 'buyer' }> = (props) => { const fetch = useFetch(); const { type } = props; const getOrderDetails = useCallback(async () => { return (await fetch(`/marketplace/orders?type=${type}`)).json(); }, [type]); const { data, isLoading } = useSWR( `/marketplace/orders/${type}`, getOrderDetails ); const biggerRow = useMemo(() => { return data?.orders?.reduce((all: any, current: any) => { if (current.details.length > all) return current.details.length; return all; }, 0); }, [data]); if (isLoading || !data?.orders?.length) return <>; return (

Orders

{data.orders.map((order: any) => ( {order.details.map((details: any, index: number) => ( ))} ))}
{type === 'seller' ? 'Buyer' : 'Seller'} Price State
{order.name}
platform {details.integration.name}
{details.integration.name} ({details.total}/ {details.submitted})
{order.price} {order.status}
); };