utils#API_INDONESIA TypeScript Examples
The following examples show how to use
utils#API_INDONESIA.
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 |
Summary: FunctionComponent = () => {
const { data, loading } = useFetch<IDSummary>(API_INDONESIA)()
return (
<SummaryComponent
loading={loading}
data={{
confirmed: data?.jumlahKasus,
recovered: data?.sembuh,
deaths: data?.meninggal
}}
/>
)
}
Example #2
Source File: index.tsx From covid19-visualized with MIT License | 6 votes |
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 |
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>
</>
)
}
Example #4
Source File: index.tsx From covid19-visualized with MIT License | 5 votes |
Page: NextPage = () => {
const { data } = useFetch<IDFormat<IDProvince[]>>(API_INDONESIA + 'provinsi')(
data => {
data.data = data.data.filter(({ kodeProvi }) => kodeProvi)
return data
}
)
return (
<>
<Head>
<title>Indonesia Daily Update | COVID-19 Visualized</title>
{meta}
</Head>
<div className="text-center my-12">
<h1 className="my-2">Indonesia Update</h1>
</div>
<div className="divider-line" />
<Summary />
<div className="btn-link my-24">
<Link href="/indonesia/province">
<Button className="my-4" block color="primary" text="See Province Cases" />
</Link>
<Link href="/indonesia/cases">
<Button className="my-4" block color="success" text="See Case details" />
</Link>
<Link href="/">
<Button className="my-4" block color="secondary" text="< Back to Home" />
</Link>
</div>
<h2 className="text-center mt-32 mb-12">Indonesia Visualization</h2>
<Visualization
id="indonesia-visualization"
data={data?.data}
visualize={visualize.indonesia}
legends={indonesiaLegends.map(({ color, value }) => (
<div key={color} className="legends-item font is-size-small">
<div className="legends-detail">{value === 0 ? `Tidak ada kasus positif` : `${value} atau lebih kasus positif`}</div>
<div className="legends-color mx-4" style={{ backgroundColor: color }} />
</div>
))}
/>
<Daily />
</>
)
}
Example #5
Source File: province.tsx From covid19-visualized with MIT License | 5 votes |
Page: NextPage = () => {
const { data, loading } = useFetch<IDFormat<IDProvince[]>>(API_INDONESIA + 'provinsi')(
data => {
data.data = data.data.filter(({ kodeProvi }) => kodeProvi)
return data
}
)
return (
<>
<Head>
<title>Indonesia Province | COVID-19 Visualized</title>
{meta}
</Head>
<div className="text-center my-12">
<h1 className="my-2">Indonesia Province</h1>
</div>
<div className="divider-line mb-32" />
<div className="btn-link mb-24">
<Link href="/indonesia">
<Button block color="secondary" text="< Back to Indonesia Cases" />
</Link>
</div>
<DataSearch<IDProvince>
data={data?.data}
loading={loading}
searchPlaceholder="Search province... (eg: jakarta)"
searchFilter={(keyword, item) => item.provinsi.toLowerCase().includes(keyword)}
>
{(data, keyword) => data.length
? (
<FlexList<IDProvince> data={data} wrapperClass="my-12" itemClass="my-12">
{province => (
<Region
chart={{
confirmed: province.kasusPosi,
recovered: province.kasusSemb,
deaths: province.kasusMeni
}}
header={`(#${province.kodeProvi}) ${province.provinsi}`}
>
<p>Total Positif: <span className="font is-weight-bold color is-txt-warning">{province.kasusPosi}</span></p>
<p className="mt-8">Aktif: <span className="font is-weight-bold color is-txt-warning">{getActiveCaseID(province)}</span></p>
<p>Sembuh: <span className="font is-weight-bold color is-txt-success">{province.kasusSemb}</span></p>
<p>Meninggal: <span className="font is-weight-bold color is-txt-danger">{province.kasusMeni}</span></p>
</Region>
)}
</FlexList>
) : (
<h3 className="text-center my-24">{
keyword.length
? `No matching province "${keyword}" found.`
: 'Please type the name of province that you want to search.'
}</h3>
)
}
</DataSearch>
</>
)
}