import { IconButton, Menu, MenuItem } from "@mui/material"; import React from "react"; import { useShallow } from "zustand/shallow"; import { ticksToSec } from "@/utils/date/time"; import { usePlaybackStore } from "@/utils/store/playback"; const ChaptersListButton = () => { const { itemChapters, seekTo } = usePlaybackStore( useShallow((state) => ({ itemChapters: state.metadata.item?.Chapters, seekTo: state.seekTo, })), ); const [showChapterList, setShowChapterList] = React.useState(null); const handleShowChapterList = (event: React.MouseEvent) => { setShowChapterList(event.currentTarget); }; return ( <> list setShowChapterList(null)} anchorOrigin={{ vertical: "top", horizontal: "center", }} transformOrigin={{ vertical: "bottom", horizontal: "center", }} > {itemChapters?.length && itemChapters?.map((chapter) => ( { seekTo(ticksToSec(chapter.StartPositionTicks ?? 0)); setShowChapterList(null); // Close the chapter list menu }} > {chapter.Name} ))} ); }; export default ChaptersListButton;