import { A } from "@solidjs/router";
import type { UserImage } from "../../network";
import { SearchCardContact } from "./SearchCardContact";
import { SearchCardEvent } from "./SearchCardEvent";
import { SearchCardLocation } from "./SearchCardLocation";

const UnwrappedSearchCard = (props: { item: UserImage }) => {
	const { item } = props;

	switch (item.type) {
		case "location":
			return <SearchCardLocation item={item} />;
		case "event":
			return <SearchCardEvent item={item} />;
		case "contact":
			return <SearchCardContact item={item} />;
		default:
			return null;
	}
};

export const SearchCard = (props: { item: UserImage }) => {
	return (
		<A
			href={`/entity/${props.item.data.ID}`}
			class="w-full h-[144px] border relative border-neutral-200 cursor-pointer overflow-hidden rounded-xl"
		>
			<UnwrappedSearchCard item={props.item} />
		</A>
	);
};
