You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
725 B
29 lines
725 B
import Spinner from '@app/assets/spinner.svg';
|
|
import Tag from '@app/components/Common/Tag';
|
|
import { BuildingOffice2Icon } from '@heroicons/react/24/outline';
|
|
import type { ProductionCompany, TvNetwork } from '@server/models/common';
|
|
import useSWR from 'swr';
|
|
|
|
type CompanyTagProps = {
|
|
type: 'studio' | 'network';
|
|
companyId: number;
|
|
};
|
|
|
|
const CompanyTag = ({ companyId, type }: CompanyTagProps) => {
|
|
const { data, error } = useSWR<TvNetwork | ProductionCompany>(
|
|
`/api/v1/${type}/${companyId}`
|
|
);
|
|
|
|
if (!data && !error) {
|
|
return (
|
|
<Tag>
|
|
<Spinner className="h-4 w-4" />
|
|
</Tag>
|
|
);
|
|
}
|
|
|
|
return <Tag iconSvg={<BuildingOffice2Icon />}>{data?.name}</Tag>;
|
|
};
|
|
|
|
export default CompanyTag;
|