components#ScrollableList TypeScript Examples

The following examples show how to use components#ScrollableList. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: index.tsx    From covid19-visualized with MIT License 6 votes vote down vote up
Daily: FunctionComponent = () => {
    const { data, loading } = useFetch<DailyType[]>(API_BASEURL + 'daily')(
        data => data
            .map((item, index) => {
                item.confirmed.perDay = getPerDayStats({ data, index, stats: 'confirmed' })
                item.recovered.perDay = getPerDayStats({ data, index, stats: 'recovered' })
                item.deaths.perDay = getPerDayStats({ data, index, stats: 'deaths' })
                return item
            })
            .sort(({ reportDate: prev }, { reportDate: next }) => (
                new Date(next).getTime() - new Date(prev).getTime()
            ))
    )

    return (
        <ScrollableList<DailyType> title="Daily Update" data={data} loading={loading}>
            {daily => (
                <Card
                    className="text-center"
                    header={<h5 className="text-center">{dateFormat(daily.reportDate)}</h5>}
                    footer={
                        <>
                            <h3>Total</h3>
                            <div className="divider-line mt-2 mb-4" style={{ width: '30%' }} />
                            <p>Confirmed: <span className="font is-weight-bold color is-txt-warning">{daily.confirmed.total}</span></p>
                            {/* <p>Recovered: <span className="font is-weight-bold color is-txt-success">{daily.recovered.total} ({getPercentage(daily.recovered.total, daily.confirmed.total)})</span></p> */}
                            <p>Deaths: <span className="font is-weight-bold color is-txt-danger">{daily.deaths.total} ({getPercentage(daily.deaths.total, daily.confirmed.total)})</span></p>
                        </>
                    }
                >
                    <p>Confirmed: <span className="font is-weight-bold color is-txt-warning">{daily.confirmed.perDay}</span></p>
                    {/* <p>Recovered: <span className="font is-weight-bold color is-txt-success">{daily.recovered.perDay}</span></p> */}
                    <p>Deaths: <span className="font is-weight-bold color is-txt-danger">{daily.deaths.perDay}</span></p>
                </Card>
            )}
        </ScrollableList>
    )
}
Example #2
Source File: index.tsx    From covid19-visualized with MIT License 6 votes vote down vote up
Daily: FunctionComponent = () => {
    const { data, loading } = useFetch<IDFormat<IDDaily[]>>(API_INDONESIA + 'harian')(
        data => {
            data.data = data.data
                .filter(({ jumlahKasusKumulatif }) => jumlahKasusKumulatif)
                .sort(({ tanggal: prev }, { tanggal: next }) => next - prev)
            return data
        }
    )

    return (
        <ScrollableList<IDDaily> title="Daily Update" loading={loading} data={data?.data}>
            {data => (
                <Card
                    className="text-center"
                    header={<h5 className="text-center">(Hari ke-#{data.harike}) {dateFormat(data.tanggal, false, 'id-ID')}</h5>}
                    footer={
                        <>
                            <h3>Akumulasi</h3>
                            <div className="divider-line mt-2 mb-4" style={{ width: '30%' }} />
                            <p>Positif: <span className="font is-weight-bold color is-txt-warning">{data.jumlahKasusKumulatif}</span></p>
                            <p>Aktif: <span className="font is-weight-bold color is-txt-warning">{data.jumlahpasiendalamperawatan} ({getPercentage(data.jumlahpasiendalamperawatan, data.jumlahKasusKumulatif)})</span></p>
                            <p>Sembuh: <span className="font is-weight-bold color is-txt-success">{data.jumlahPasienSembuh} ({getPercentage(data.jumlahPasienSembuh, data.jumlahKasusKumulatif)})</span></p>
                            <p>Meninggal: <span className="font is-weight-bold color is-txt-danger">{data.jumlahPasienMeninggal} ({getPercentage(data.jumlahPasienMeninggal, data.jumlahKasusKumulatif)})</span></p>
                        </>
                    }
                >
                    <p>Positif: <span className="font is-weight-bold color is-txt-warning">{data.jumlahKasusBaruperHari}</span></p>
                    <p>Sembuh: <span className="font is-weight-bold color is-txt-success">{data.jumlahKasusSembuhperHari}</span></p>
                    <p>Meninggal: <span className="font is-weight-bold color is-txt-danger">{data.jumlahKasusMeninggalperHari}</span></p>
                </Card>
            )}
        </ScrollableList>
    )
}
Example #3
Source File: cases.tsx    From covid19-visualized with MIT License 5 votes vote down vote up
Page: NextPage = () => {
    const { data, loading } = useFetch<IDFormat<IDCases[]>>(API_INDONESIA + 'kasus/old')()

    return (
        <>
            <Head>
                <title>Indonesia Case Details | COVID-19 Visualized</title>
                {meta}
            </Head>

            <div className="text-center my-12">
                <h1 className="my-2">Indonesia Detail Cases</h1>
                <h6 className="color is-txt-warning">{data?.warning}</h6>
            </div>

            <div className="divider-line" />

            <div className="btn-link my-24">
                <Link href="/indonesia">
                    <Button block color="secondary" text="< Back to Indonesia Cases" />
                </Link>
            </div>
            
            <ScrollableList<IDCases> title="Data Cases" data={data?.data} loading={loading}>
                {data => (
                    <Card
                        className="text-center"
                        header={<h5 className="text-center">(#{data.no}) {data.kota ? `${data.kota}, ${data.provinsi}` : data.provinsi}</h5>}
                        footer={
                            <span className="font is-size-small">
                                {data.keterangan || 'Tidak ada keterangan'}; {data.dirawatdi ? `(Sedang dirawat di ${data.dirawatdi}); ` : ''}{data.kondisiKesehatan ? `Kodisi: ${data.kondisiKesehatan};` : ''}
                            </span>
                        }
                    >
                        <p>Usia: <span className="font is-weight-bold">{data.usia ? `${data.usia} tahun` : 'Tidak diketahui'}</span></p>
                        <p>Jenis Kelamin: <span className="font is-weight-bold">{data.jk === 'P'
                            ? 'Wanita'
                            : data.jk === 'L'
                                ? 'Pria'
                                : 'Tidak diketahui'
                        }</span></p>
                        <p>Status: <span className={`font color is-weight-bold is-txt-${data.status === 'Aktif' ? 'warning' : data.status === 'Sembuh' ? 'success' : data.status === 'Meninggal' ? 'danger' : ''}`}>{data.status || 'Tidak diketahui'}</span></p>
                        <p>Kluster: <span className="font is-weight-bold ">{data.kluster || 'Tidak diketahui'}</span></p>
                        <p className="mt-8">Positif: <span className="font is-weight-bold">{data.positif ? dateFormat(+data.positif, false, 'id-ID') : 'Tidak diketahui'}</span></p>
                        <p>Mulai Gejala: <span className="font is-weight-bold">{data.mulaiGejala ? dateFormat(+data.mulaiGejala, false, 'id-ID') : 'Tidak diketahui'}</span></p>
                        <p>Mulai Di Isolasi: <span className="font is-weight-bold">{data.mulaiDiisolasi ? dateFormat(+data.mulaiDiisolasi, false, 'id-ID') : 'Tidak diketahui'}</span></p>
                    </Card>
                )}
            </ScrollableList>
        </>
    )
}