-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added functions to handle solve options
- Loading branch information
1 parent
725f67a
commit 1e190ad
Showing
3 changed files
with
118 additions
and
63 deletions.
There are no files selected for viewing
105 changes: 105 additions & 0 deletions
105
src/components/menu-solve-options/menu-solve-options.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 */} | ||
<div className="flex items-center justify-center pt-5 gap-2"> | ||
<TooltipProvider delayDuration={100}> | ||
<Tooltip> | ||
<TooltipTrigger asChild> | ||
<Button variant={"ghost"} onClick={handleDeleteSolve}> | ||
<Cross1Icon /> | ||
</Button> | ||
</TooltipTrigger> | ||
<TooltipContent> | ||
<p>Delete</p> | ||
</TooltipContent> | ||
</Tooltip> | ||
<Tooltip> | ||
<TooltipTrigger asChild> | ||
<Button | ||
variant={"ghost"} | ||
className="font-light text-md" | ||
onClick={handlePenaltyPlus2} | ||
> | ||
+2 | ||
</Button> | ||
</TooltipTrigger> | ||
<TooltipContent> | ||
<p>+2 Penalty</p> | ||
</TooltipContent> | ||
</Tooltip> | ||
<Tooltip> | ||
<TooltipTrigger asChild> | ||
<Button variant={"ghost"} onClick={handleBookmarkSolve}> | ||
<BookmarkIcon /> | ||
</Button> | ||
</TooltipTrigger> | ||
<TooltipContent> | ||
<p>Bookmark</p> | ||
</TooltipContent> | ||
</Tooltip> | ||
<Tooltip> | ||
<TooltipTrigger asChild> | ||
<Button variant={"ghost"}> | ||
<CopyIcon /> | ||
</Button> | ||
</TooltipTrigger> | ||
<TooltipContent> | ||
<p>Copy</p> | ||
</TooltipContent> | ||
</Tooltip> | ||
</TooltipProvider> | ||
</div> | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters