import { useCallback, useMemo, useState } from "react"; import clsx from 'clsx'; import "./rds-comp-adaptive-cards.scss"; import RdsBox from "../../raaghu-elements/rds-box/rds-box"; import RdsTypography from "../../raaghu-elements/rds-typography/rds-typography"; import RdsStack from "../../raaghu-elements/rds-stack/rds-stack"; import RdsButtonDropdown from "../../raaghu-elements/rds-button-dropdown/rds-button-dropdown"; import RdsButton from "../../raaghu-elements/rds-button/rds-button"; import RdsCardDetail from "../../raaghu-elements/rds-card-detail/rds-card-detail"; import { CardHeader, CardContent, CardActions, IconButton } from "@mui/material"; import { Close as CloseIcon, ExpandMore as ExpandMoreIcon } from "@mui/icons-material"; import { FootballScorecardCard, ActivityUpdateCard, CalendarReminderForm, RestaurantOrderForm, ImageGalleryCard, InputFormCard, AdaptiveCardProps, } from "./rds-comp-adaptive-cards-helpers"; import { capitalizeFirstWord } from "./rds-comp-adaptive-cards-utils"; type FootballProps = { leagueName?: string; leagueAvatar?: string; isLive?: boolean; date?: string; isFinal?: boolean; homeTeam?: { name?: string; logo?: string; status?: string; }; awayTeam?: { name?: string; logo?: string; status?: string; }; homeScore?: number; awayScore?: number; time?: string; finalText?: string; }; type ActivityProps = { avatar?: string; name?: string; date?: string; radioOptions?: { value: string; label: string; desc: string }[]; }; const ALLOWED_BUTTON_STYLES = ["filled", "outlined", "transparent"] as const; type ButtonStyle = (typeof ALLOWED_BUTTON_STYLES)[number]; const VARIANT_DEFAULTS = { cardTitle: "Title", showHeader: false, showBtn1: false, showBtn2: false, btn1style: "transparent", btn2style: "filled", btn1Label: "Cancel", btn2Label: "Done", type: "Default", showDismiss: false, closeIcon: false, label: "", smallText: "", }; const getRdsButtonStyle = (style: unknown): ButtonStyle => ALLOWED_BUTTON_STYLES.includes(style as ButtonStyle) ? (style as ButtonStyle) : "filled"; const RdsCompAdaptiveCards = (props: AdaptiveCardProps) => { const type = props.type || "Default"; const merged = useMemo(() => ({ ...VARIANT_DEFAULTS, ...props }), [props]); const { showHeader, showDismiss, cardTitle, showBtn1, showBtn2, btn1style, btn2style, btn1Label, btn2Label, smallText, cardText, closeIcon, label, block, images, leagueName, leagueAvatar, isLive, matchDate, isFinal, homeTeamName, homeTeamLogo, homeTeamStatus, awayTeamName, awayTeamLogo, awayTeamStatus, homeScore, awayScore, time, footballProps = {} as Partial, activityProps = {} as Partial, } = merged; const resolvedBtn1Style = getRdsButtonStyle(btn1style); const resolvedBtn2Style = getRdsButtonStyle(btn2style); const calendarLabel = type === "CalenderReminder" ? label || VARIANT_DEFAULTS.label : label; const calendarSmallText = type === "CalenderReminder" ? smallText || VARIANT_DEFAULTS.smallText : smallText; const inputFormLabel = type === "InputForm" ? label || VARIANT_DEFAULTS.label : undefined; const inputFormSmallText = type === "InputForm" ? smallText || VARIANT_DEFAULTS.smallText : undefined; const [entree, setEntree] = useState(""); const [side, setSide] = useState(""); const [drink, setDrink] = useState(""); const [visible, setVisible] = useState(true); const handleDismiss = useCallback(() => setVisible(false), []); const activityDropdownOptions = useMemo( () => (activityProps?.radioOptions ?? []).map((opt, idx) => ({ id: opt.value ?? idx, label: opt.label, size: "small" as const, styleType: "outline" as const, avatarSrc: undefined, checked: undefined, disabled: undefined, })), [activityProps?.radioOptions] ); if (!visible) return null; if (type === "ImageGallery") { return ( ); } if (type === "FootballScorecard") { return ( ); } return ( visible && ( {type === "Default" ? ( {showDismiss && } {showHeader && ( {cardTitle} )} {closeIcon && ( )} {smallText && ( {smallText} )} {cardText || "Instance Slot"} {showBtn1 && ( )} {showBtn2 && ( )} ) : ( <> {showDismiss && } {cardTitle} ) } action={ closeIcon && ( ) } /> {type === "CalenderReminder" && ( )} {type === "InputForm" && ( )} {type === "ActivityUpdateCard" && (
)} {type === "RestaurantOrder" && ( )}
{type === "RestaurantOrder" ? ( showBtn1 ? ( ) : null ) : type === "CalenderReminder" ? null : ( <> {showBtn1 && (type === "InputForm" ? ( ) : type === "ActivityUpdateCard" ? ( {}} state="default" showRadio={true} showUserAvatar={true} multiSelect={false} isShowLeftIcon={false} rightIcon={} /> ) : ( ))} {showBtn2 && type !== "InputForm" && ( )} )} )}
) ); }; RdsCompAdaptiveCards.displayName = "RdsCompAdaptiveCards"; export default RdsCompAdaptiveCards;