2019-07-30 23:27:28 +09:00
|
|
|
import React from 'react'
|
|
|
|
import useFetch from 'fetch-suspense'
|
2019-07-31 00:18:58 +09:00
|
|
|
import { Card, CardTitle, AvailabilityCell } from './Card'
|
2019-07-30 23:27:28 +09:00
|
|
|
import { FaNpm } from 'react-icons/fa'
|
|
|
|
|
2019-07-31 00:18:58 +09:00
|
|
|
function Availability({ name }) {
|
2019-07-30 23:27:28 +09:00
|
|
|
const response = useFetch(`/availability/npm/${name}`)
|
|
|
|
|
|
|
|
if (response.error) {
|
|
|
|
throw new Error(`npm: ${response.error}`)
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<AvailabilityCell
|
|
|
|
name={name}
|
|
|
|
availability={response.packageAvailability}
|
2019-07-31 00:18:58 +09:00
|
|
|
url={`https://www.npmjs.com/package/${name}`}
|
2019-07-30 23:27:28 +09:00
|
|
|
prefix="npmjs.com/package/"
|
2019-07-31 00:18:58 +09:00
|
|
|
icon={<FaNpm />}
|
2019-07-30 23:27:28 +09:00
|
|
|
/>
|
|
|
|
<AvailabilityCell
|
|
|
|
name={name}
|
|
|
|
availability={response.orgAvailability}
|
|
|
|
icon={<FaNpm />}
|
|
|
|
url="https://www.npmjs.com/org/"
|
|
|
|
prefix="npmjs.com/org/"
|
|
|
|
/>
|
|
|
|
</>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
export default function NpmCard({ name }) {
|
|
|
|
return (
|
2019-07-31 00:18:58 +09:00
|
|
|
<Card key={name}>
|
|
|
|
<CardTitle>npm</CardTitle>
|
|
|
|
<Availability name={name.toLowerCase()} />
|
2019-07-30 23:27:28 +09:00
|
|
|
</Card>
|
|
|
|
)
|
|
|
|
}
|