// "use client"; // import React, { useState, useEffect } from "react"; // import { motion, useMotionValue, useTransform, useAnimation } from "framer-motion"; // import { useRouter } from "next/navigation"; // // 1. Updated ColorWay interface // interface ColorWay { // card: string; // text: string; // titleColor: string; // Added title color // } // // 2. Updated COLOR_WAYS array // const COLOR_WAYS: ColorWay[] = [ // { card: "#FEEEDF", text: "#173C46", titleColor: "#173C46" }, // { card: "#FEEEDF", text: "#EA627F", titleColor: "#173C46" }, // Example: Title is dark, text is pink // { card: "#DEE5D4", text: "#173C46", titleColor: "#EA627F" }, // { card: "#DEE5D4", text: "#EA627F", titleColor: "#173C46" }, // { card: "#B8C0AD", text: "#173C46", titleColor: "#173C46" }, // { card: "#B8C0AD", text: "#173C46", titleColor: "#EA627F" }, // ]; // interface CardData { // id: number; // title: string; // summary: string; // tracks: string[]; // } // const SwipeCards: React.FC<{ initialCards: CardData[] }> = ({ initialCards }) => { // const [cards, setCards] = useState(initialCards); // const router = useRouter(); // // Update cards state when initialCards prop changes // useEffect(() => { // setCards(initialCards); // }, [initialCards]); // const removeCard = () => { // setCards((prev) => prev.slice(0, prev.length - 1)); // }; // const handleAccept = (cardData: CardData) => { // removeCard(); // // Redirect to chatbot with card data // router.push(`/chatbot?title=${encodeURIComponent(cardData.title)}&summary=${encodeURIComponent(cardData.summary)}`); // }; // const handleReject = () => { // removeCard(); // }; // const handleReset = () => { // setCards([]); // Reset to initial cards // }; // return ( //
// {cards.length > 0 ? ( // cards.map((card, index) => { // const colorWay = COLOR_WAYS[card.id % COLOR_WAYS.length]; // return ( // // ); // }) // ) : ( // // ... (empty state) //
//

// No more cards! //

//

// You've swiped through them all. //

// //
// )} //
// ); // }; // interface CardProps { // cardData: CardData; // colorWay: ColorWay; // isFront: boolean; // onAccept: (cardData: CardData) => void; // onReject: () => void; // } // const Card: React.FC = ({ cardData, colorWay, isFront, onAccept, onReject }) => { // const { title, summary, tracks } = cardData; // const x = useMotionValue(0); // const rotate = useTransform(x, [-250, 250], [-25, 25]); // const opacity = useTransform( // x, // [-250, -100, 0, 100, 250], // [0, 1, 1, 1, 0], // ); // const controls = useAnimation(); // const acceptOpacity = useTransform(x, [50, 150], [0, 1]); // const rejectOpacity = useTransform(x, [-150, -50], [1, 0]); // const badgeRotate = useTransform(x, [-150, 150], [-15, 15]); // const handleDragEnd = async (event: MouseEvent | TouchEvent | PointerEvent, info: { offset: { x: number } }) => { // if (info.offset.x > 100) { // // Card accepted // await controls.start({ x: 1000, opacity: 0, transition: { duration: 0.1 } }); // Animate off-screen quickly // onAccept(cardData); // Then call onAccept which removes the card and redirects // } else if (info.offset.x < -100) { // // Card rejected // await controls.start({ x: -1000, opacity: 0, transition: { duration: 0.1 } }); // Animate off-screen quickly // onReject(); // Then call onReject which removes the card // } else { // // Card not swiped far enough, snap back to center // controls.start({ x: 0, rotate: 0, opacity: 1, transition: { type: "spring", stiffness: 300, damping: 30 } }); // } // }; // return ( // // {/* Accept/Reject Badges */} // //

Accept

//
// //

Reject

//
// {/* Card Content */} //
// {/* 3. Applied the specific titleColor here */} //

// {title} //

// {/* This summary

will inherit colorWay.text from the parent */} //

{summary}

//
//
// {tracks.slice(0, 2).map((track, index) => ( // // {track} // {index === 0 && tracks.length > 1 && ", "} // // ))} //
//
// ); // }; // export default SwipeCards;