diff --git a/src/components/ui/coaching-sessions/agreements.tsx b/src/components/ui/coaching-sessions/agreements.tsx deleted file mode 100644 index 02dbe05..0000000 --- a/src/components/ui/coaching-sessions/agreements.tsx +++ /dev/null @@ -1,299 +0,0 @@ -"use client"; - -import { Button } from "@/components/ui/button"; -import { - Card, - CardContent, - CardDescription, - CardFooter, - CardHeader, - CardTitle, -} from "@/components/ui/card"; -import { Label } from "@/components/ui/label"; -import { - Select, - SelectContent, - SelectGroup, - SelectItem, - SelectLabel, - SelectTrigger, - SelectValue, -} from "@/components/ui/select"; -import { fetchAgreementsByCoachingSessionId } from "@/lib/api/agreements"; -import { Agreement } from "@/types/agreement"; -import { Id } from "@/types/general"; -import Link from "next/link"; -import { useEffect, useState } from "react"; -import { DateTime } from "ts-luxon"; - -import Image from "next/image"; -import { - File, - Home, - LineChart, - ListFilter, - MoreHorizontal, - Package, - Package2, - PanelLeft, - PlusCircle, - Search, - Settings, - ShoppingCart, - Users2, -} from "lucide-react"; - -import { Badge } from "@/components/ui/badge"; -import { - DropdownMenu, - DropdownMenuCheckboxItem, - DropdownMenuContent, - DropdownMenuItem, - DropdownMenuLabel, - DropdownMenuSeparator, - DropdownMenuTrigger, -} from "@/components/ui/dropdown-menu"; -import { Input } from "@/components/ui/input"; -import { Sheet, SheetContent, SheetTrigger } from "@/components/ui/sheet"; -import { - Table, - TableBody, - TableCell, - TableHead, - TableHeader, - TableRow, -} from "@/components/ui/table"; -import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"; -import { - Tooltip, - TooltipContent, - TooltipTrigger, -} from "@/components/ui/tooltip"; - -export interface AgreementsProps { - /** The current active coaching session Id */ - coachingSessionId: Id; -} - -const Agreements: React.FC<{ - coachingSessionId: Id; - // onChange: (value: string) => void; - // onKeyDown: () => void; -}> = ({ coachingSessionId /*, onChange, onKeyDown*/ }) => { - const WAIT_INTERVAL = 1000; - const [timer, setTimer] = useState(undefined); - const [agreements, setAgreements] = useState([]); - const [agreementId, setAgreementId] = useState(""); - const [agreementBody, setAgreementBody] = useState(""); - - useEffect(() => { - async function loadAgreements() { - if (!coachingSessionId) return; - - await fetchAgreementsByCoachingSessionId(coachingSessionId) - .then((agreements) => { - // Apparently it's normal for this to be triggered twice in modern - // React versions in strict + development modes - // https://stackoverflow.com/questions/60618844/react-hooks-useeffect-is-called-twice-even-if-an-empty-array-is-used-as-an-ar - console.debug("setAgreements: " + JSON.stringify(agreements)); - setAgreements(agreements); - }) - .catch(([err]) => { - console.error("Failed to fetch Agreements: " + err); - }); - } - loadAgreements(); - }, [coachingSessionId]); - - const handleAgreementSelectionChange = (newValue: string) => { - console.debug("newValue (hASC): " + newValue); - setAgreementBody(newValue); - //setAgreementId(); - }; - - const handleAgreementChange = (e: React.ChangeEvent) => { - const newValue = e.target.value; - console.debug("newValue (hAC): " + newValue); - setAgreementBody(newValue); - - if (timer) { - clearTimeout(timer); - } - - const newTimer = window.setTimeout(() => { - //onChange(newValue); - }, WAIT_INTERVAL); - - setTimer(newTimer); - }; - - const handleOnKeyDown = (e: React.KeyboardEvent) => { - //onKeyDown(); - }; - - useEffect(() => { - return () => { - if (timer) { - clearTimeout(timer); - } - }; - }, [timer]); - - return ( -
-
-
- - - Agreements - - Manage agreements for this session - - - - - - - Body - - Created - - - Last updated - - - Actions - - - - - {agreements.map((agreement) => ( - - - {agreement.body} - - - {agreement.created_at.toLocaleString( - DateTime.DATETIME_FULL - )} - - - {agreement.updated_at.toLocaleString( - DateTime.DATETIME_FULL - )} - - - - - - - - Actions - Edit - Delete - - - - - ))} - {agreements.length == 0 && ( - -
No agreements
-
- )} -
-
-
- -
- Showing{" "} - - {agreements.length > 0 ? <>1 - : <>} {agreements.length} - {" "} - of {agreements.length} agreements -
-
-
-
-
-
- ); -}; - -export { Agreements }; - -// export function Agreements({ -// coachingSessionId: coachingSessionId, -// ...props -// }: AgreementsProps) { -// const [agreements, setAgreements] = useState([]); - -// useEffect(() => { -// async function loadAgreements() { -// if (!coachingSessionId) return; - -// await fetchAgreementsByCoachingSessionId(coachingSessionId) -// .then((agreements) => { -// // Apparently it's normal for this to be triggered twice in modern -// // React versions in strict + development modes -// // https://stackoverflow.com/questions/60618844/react-hooks-useeffect-is-called-twice-even-if-an-empty-array-is-used-as-an-ar -// console.debug("setAgreements: " + JSON.stringify(agreements)); -// setAgreements(agreements); -// }) -// .catch(([err]) => { -// console.error("Failed to fetch Agreements: " + err); -// }); -// } -// loadAgreements(); -// }, [coachingSessionId]); - -// return ( -//
-//
-// {/* */} -// -//
-//
-// -//
-//
-// -//
-//
-// ); -// }