"use client";

import { Box, Divider, IconButton, Tooltip } from "@mui/material";
import PowerSettingsNewIcon from "@mui/icons-material/PowerSettingsNew";
import ModeEditIcon from "@mui/icons-material/ModeEdit";
import VpnKeyIcon from "@mui/icons-material/VpnKey";
import { useState } from "react";
import Update from "@/core/components/Profile/Update";
import ChangePass from "@/core/components/Profile/ChangePass";
import { useAuth } from "@/lib/contexts/auth";

const ProfileActions = () => {
    const { getUser } = useAuth();
    const [openUpdate, setOpenUpdate] = useState(false);
    const [openChangePass, setOpenChangePass] = useState(false);

    const openUpdateProfile = () => {
        getUser();
        setOpenUpdate(true);
    };

    return (
        <>
            <Box sx={{ display: "flex", justifyContent: "center" }}>
                <Tooltip title="ویرایش پروفایل" arrow>
                    <IconButton aria-label="ویرایش پروفایل" color="success" onClick={openUpdateProfile}>
                        <ModeEditIcon />
                    </IconButton>
                </Tooltip>
                <Divider orientation="vertical" variant="middle" flexItem sx={{ mx: 1 }} />
                <Tooltip title="خروج" arrow>
                    <IconButton aria-label="خروج" color="error">
                        <PowerSettingsNewIcon />
                    </IconButton>
                </Tooltip>
                <Divider orientation="vertical" variant="middle" flexItem sx={{ mx: 1 }} />
                <Tooltip title="تغییر رمز عبور" arrow>
                    <IconButton
                        aria-label="تغییر رمز عبور"
                        color="primary"
                        onClick={() => {
                            setOpenChangePass(true);
                        }}
                    >
                        <VpnKeyIcon />
                    </IconButton>
                </Tooltip>
            </Box>
            <Update open={openUpdate} setOpen={setOpenUpdate} />
            <ChangePass open={openChangePass} setOpen={setOpenChangePass} />
        </>
    );
};
export default ProfileActions;
