mirror of
https://github.com/formbricks/formbricks.git
synced 2026-05-07 22:31:35 -05:00
b9a8e9d12c
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>
33 lines
906 B
TypeScript
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>
|
|
);
|
|
};
|