import type {BlacklistItem} from "~/classes/blacklistItem";
import {Dialog, DialogContent, DialogTitle, Divider} from "@mui/material";
import NicknameList from "~/components/itemDialog/nicknameList";
import CommentsList from "~/components/itemDialog/commentsList";
import TagList from "~/components/itemDialog/tagList";
import TitleHeader from "~/components/itemDialog/titleHeader";
import useWindowDimensions from "~/hooks/windowDimensions";
import trimLink from "~/functions/trimLink";

export default function ItemDialog({ blacklistItem, open, handleClose }: { blacklistItem: BlacklistItem|null, open: boolean, handleClose: Function }){
    if (blacklistItem){
        const { width } = useWindowDimensions();
        return (
            <Dialog
                open={open}
                onClose={() => handleClose()}
            >
                <DialogTitle>
                    <TitleHeader name={blacklistItem?.link} handleClose={handleClose} isLink={true}/>
                    <TagList
                        afk={blacklistItem?.afk}
                        cheater={blacklistItem?.cheater}
                        griefer={blacklistItem?.griefer}
                        toxic={blacklistItem?.toxic}
                        useless={blacklistItem?.useless}
                        smurf={blacklistItem?.smurf}
                    />
                </DialogTitle>
                <Divider sx={{marginTop: '10px', marginBottom: '10px', alignSelf: 'center'}}/>
                <DialogContent>
                    <NicknameList nicknames={blacklistItem?.nicknames}/>
                    <CommentsList comments={blacklistItem?.comments}/>
                </DialogContent>
            </Dialog>
        )
    } else {
        return (
            <Dialog
                open={open}
                onClose={() => handleClose()}
            >
                <DialogContent>
                    Error: No item
                </DialogContent>
            </Dialog>
        )
    }

}