import React from 'react' import styled from 'styled-components' import useFetch from 'fetch-suspense' import { BarLoader } from 'react-spinners' function AvailabilityCell({ name, availability, link, prefix = '', suffix = '', icon, }) { return ( {icon} {prefix} {availability ? ( {name} ) : ( {name} )} {suffix} ) } export const Fallback = () => ( ) export function DedicatedAvailability({ name, service, link, prefix = '', suffix = '', icon, }) { const response = useFetch(`/availability/${service}/${name}`) if (response.error) { throw new Error(`${service}: ${response.error}`) } return ( ) } export function ExistentialAvailability({ name, target, link, prefix = '', suffix = '', icon, }) { const response = useFetch(target, null, { metadata: true }) if (response.status !== 404 && response.status !== 200) { throw new Error(`${name}: ${response.status}`) } const availability = response.status === 404 return ( ) } const ItemContainer = styled.div` display: flex; flex-direction: row; align-items: flex-start; margin-top: 8px; word-break: break-all; ` const Item = styled.span` margin-left: 6px; font-family: monospace; font-size: 1rem; a { text-decoration: none; color: inherit; } `