import React from "react"; import {useSelector} from "react-redux"; import {selectUserAge, selectUserGender, selectUserUpkAnswers, selectUserZip} from "@/models/userUpkAnswerSlice.ts"; import {titleCase} from "@/lib/utils.ts"; import { formatDistanceToNow } from 'date-fns' import {Card, CardContent, CardHeader} from "@/components/ui/card"; import {Calendar, MapPin, User, PersonStanding} from "lucide-react"; import {UserProfileKnowledge, UserProfile} from "@/api"; import {ColumnDef, flexRender, getCoreRowModel, useReactTable} from "@tanstack/react-table"; import {Table, TableBody, TableCell, TableHead, TableHeader, TableRow} from "@/components/ui/table.tsx"; import {useAppSelector} from "@/hooks.ts"; export const UpkGrid = () => { const columns: ColumnDef[] = [ { accessorKey: "property_label", header: "Label", }, { accessorKey: "answer", header: "Answer", cell: ({getValue}) => getValue()[0].value ?? getValue()[0].label }, ] const data = useSelector(selectUserUpkAnswers) const table = useReactTable({ data, columns, getCoreRowModel: getCoreRowModel(), }) return (
{table.getHeaderGroups().map((headerGroup) => ( {headerGroup.headers.map((header) => { return ( {header.isPlaceholder ? null : flexRender( header.column.columnDef.header, header.getContext() )} ) })} ))} { table.getRowModel().rows.map((row) => ( {row.getVisibleCells().map((cell) => ( {flexRender(cell.column.columnDef.cell, cell.getContext())} ))} )) }
) } export const ContactCard = () => { const age = useSelector(selectUserAge) const zip = useSelector(selectUserZip) const gender = useSelector(selectUserGender) const userProfile: UserProfile = useAppSelector(state => state.userProfile) const created: string = formatDistanceToNow(new Date(userProfile.user.created), { addSuffix: true }) return (
Created: {created}
{titleCase(gender ?? " - " as string)}
{age ?? " - "} years old
{zip ?? " - "}
); }; const Demographics = () => { return ( <> ) } export { Demographics }