From 1e190ad739ebe137ac12f8e23216c288a76d39db Mon Sep 17 00:00:00 2001 From: Bryan Lundberg Date: Sat, 14 Sep 2024 06:17:47 -0600 Subject: [PATCH] added functions to handle solve options --- .../menu-solve-options/menu-solve-options.tsx | 105 ++++++++++++++++++ .../sheet-solve-details/SheetSolveDetails.tsx | 74 ++---------- src/components/solves/SolvesArea.tsx | 2 +- 3 files changed, 118 insertions(+), 63 deletions(-) create mode 100644 src/components/menu-solve-options/menu-solve-options.tsx diff --git a/src/components/menu-solve-options/menu-solve-options.tsx b/src/components/menu-solve-options/menu-solve-options.tsx new file mode 100644 index 00000000..e61486a8 --- /dev/null +++ b/src/components/menu-solve-options/menu-solve-options.tsx @@ -0,0 +1,105 @@ +import { Button } from "@/components/ui/button"; +import { + Tooltip, + TooltipContent, + TooltipProvider, + TooltipTrigger, +} from "@/components/ui/tooltip"; +import { Solve } from "@/interfaces/Solve"; +import updateSolve from "@/lib/updateSolve"; +import { useTimerStore } from "@/store/timerStore"; +import { BookmarkIcon, CopyIcon, Cross1Icon } from "@radix-ui/react-icons"; + +export default function MenuSolveOptions({ solve }: { solve: Solve | null }) { + const { selectedCube, cubes, mergeUpdateSelectedCube } = useTimerStore(); + if (!solve && !selectedCube) return null; + + const handleDeleteSolve = async () => { + if (solve && selectedCube) { + const updatedCube = await updateSolve({ + solveId: solve.id, + selectedCube: selectedCube, + type: "DELETE", + }); + mergeUpdateSelectedCube(updatedCube, cubes); + } + }; + + const handlePenaltyPlus2 = async () => { + if (solve && selectedCube) { + const updatedCube = await updateSolve({ + solveId: solve.id, + selectedCube: selectedCube, + type: "+2", + }); + mergeUpdateSelectedCube(updatedCube, cubes); + } + }; + + const handleBookmarkSolve = async () => { + if (solve && selectedCube) { + const updatedCube = await updateSolve({ + solveId: solve.id, + selectedCube: selectedCube, + type: "BOOKMARK", + }); + mergeUpdateSelectedCube(updatedCube, cubes); + } + }; + + const handleClipboardSolve = () => {}; + + return ( + <> + {/* options */} +
+ + + + + + +

Delete

+
+
+ + + + + +

+2 Penalty

+
+
+ + + + + +

Bookmark

+
+
+ + + + + +

Copy

+
+
+
+
+ + ); +} diff --git a/src/components/sheets/sheet-solve-details/SheetSolveDetails.tsx b/src/components/sheets/sheet-solve-details/SheetSolveDetails.tsx index e86c03f1..388a2e99 100644 --- a/src/components/sheets/sheet-solve-details/SheetSolveDetails.tsx +++ b/src/components/sheets/sheet-solve-details/SheetSolveDetails.tsx @@ -1,29 +1,18 @@ +import MenuSolveOptions from "@/components/menu-solve-options/menu-solve-options"; import { ScrambleDisplay } from "@/components/scramble-display"; -import { Button } from "@/components/ui/button"; -import { Label } from "@/components/ui/label"; import { SheetContent, SheetDescription, SheetHeader, SheetTitle, } from "@/components/ui/sheet"; -import { Textarea } from "@/components/ui/textarea"; -import { - Tooltip, - TooltipContent, - TooltipProvider, - TooltipTrigger, -} from "@/components/ui/tooltip"; import formatTime from "@/lib/formatTime"; import { useDialogSolve } from "@/store/DialogSolve"; import { useTimerStore } from "@/store/timerStore"; import { - BookmarkIcon, CalendarIcon, ClockIcon, CodeSandboxLogoIcon, - CopyIcon, - TrashIcon, } from "@radix-ui/react-icons"; import { DateTime } from "luxon"; import { useLocale } from "next-intl"; @@ -56,9 +45,14 @@ export default function SheetSolveDetails() { visualization="3D" /> -

- {formatTime(solve?.time || 0)} -

+
+ + {formatTime(solve?.time || 0).split(".")[0]} + + + .{formatTime(solve?.time || 0).split(".")[1]} + +

@@ -76,56 +70,12 @@ export default function SheetSolveDetails() {

{/* comment */} -
+ {/*