1
0
mirror of https://github.com/uetchy/namae.git synced 2025-07-02 06:20:02 +09:00
namae/src/components/TwitterCard.js

32 lines
718 B
JavaScript
Raw Normal View History

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 { FaTwitter } 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/twitter/${name}`)
if (response.error) {
throw new Error(`Twitter: ${response.error}`)
}
return (
<AvailabilityCell
name={name}
availability={response.availability}
2019-07-31 00:18:58 +09:00
url={`https://twitter.com/${name}`}
2019-07-30 23:27:28 +09:00
prefix="twitter.com/"
2019-07-31 00:18:58 +09:00
icon={<FaTwitter />}
2019-07-30 23:27:28 +09:00
/>
)
}
export default function TwitterCard({ name }) {
return (
<Card key={name}>
2019-07-31 00:18:58 +09:00
<CardTitle>Twitter</CardTitle>
<Availability name={name} />
2019-07-30 23:27:28 +09:00
</Card>
)
}