Files
formbricks-formbricks/packages/ui/PictureSelectionResponse/index.tsx
T
Piyush Gupta b9a8e9d12c feat: picture selection question (#1388)
Co-authored-by: Olasunkanmi Balogun <olasunkanmiibalogun@gmail.com>
Co-authored-by: Johannes <johannes@formbricks.com>
Co-authored-by: Johannes <72809645+jobenjada@users.noreply.github.com>
Co-authored-by: pandeymangg <anshuman.pandey9999@gmail.com>
2023-10-30 05:32:49 +00:00

33 lines
906 B
TypeScript

"use client";
import Image from "next/image";
interface PictureSelectionResponseProps {
choices: { id: string; imageUrl: string }[];
selected: string | number | string[];
}
export const PictureSelectionResponse = ({ choices, selected }: PictureSelectionResponseProps) => {
if (typeof selected !== "object") return null;
const choiceImageMapping = choices.reduce((acc, choice) => {
acc[choice.id] = choice.imageUrl;
return acc;
}, {} as Record<string, string>);
return (
<div className="my-1 flex flex-wrap gap-x-5 gap-y-4">
{selected.map((id) => (
<div className="relative h-32 w-56">
<Image
src={choiceImageMapping[id]}
alt={choiceImageMapping[id].split("/").pop() || "Image"}
fill
style={{ objectFit: "cover" }}
className="rounded-lg"
/>
</div>
))}
</div>
);
};