import { StarIcon } from '@heroicons/react/24/outline';
import Tag from 'components/tag';
import { getCollection, getMetaobjectsByIds } from 'lib/shopify';
import { Metaobject } from 'lib/shopify/types';
import Link from 'next/link';
const { STORE_PREFIX } = process.env;
const validStores = ['car-part-planet', 'reman-transmission', 'transmission-locator'];
const LinkBlock = async ({ collectionId, title }: { collectionId?: string; title?: string }) => {
if (!collectionId || !title) return null;
const collection = await getCollection({ id: collectionId });
if (!collection) return null;
return (
{title}
);
};
const TransmissionCode = async ({ collectionHandle }: { collectionHandle: string }) => {
const collection = await getCollection({ handle: collectionHandle });
if (!collection || !collection.plpType || !validStores.includes(STORE_PREFIX!)) {
return null;
}
let transmissionCodes = [] as Metaobject[];
if (
(collection.plpType === 'Product Type' || collection.plpType === 'Make') &&
collection.transmissionCodeLinks
) {
transmissionCodes = await getMetaobjectsByIds(collection.transmissionCodeLinks);
}
if (!transmissionCodes.length) {
return null;
}
return (
{`Browse By Transmission Code`}
Popular Transmission Codes
{transmissionCodes.map((transmissionCode) => (
))}
);
};
export default TransmissionCode;