import React, { useState } from "react"; import { useTranslation } from "react-i18next"; import { Link as LinkRouter } from "react-router-dom"; import { Avatar, Badge, Button, CircularProgress, Dialog, DialogContent, Divider, FormControlLabel, Grid, IconButton, List, ListItemAvatar, ListItemButton, ListItemText, ListItem, ListItemIcon, Switch, TextField, Tooltip, Typography, } from "@mui/material"; import BoltIcon from "@mui/icons-material/Bolt"; import NumbersIcon from "@mui/icons-material/Numbers"; import PasswordIcon from "@mui/icons-material/Password"; import ContentCopy from "@mui/icons-material/ContentCopy"; import PersonAddAltIcon from "@mui/icons-material/PersonAddAlt"; import EmojiEventsIcon from "@mui/icons-material/EmojiEvents"; import { getCookie } from "../../utils/cookies"; type Props = { isOpen: boolean; handleClickCloseProfile: () => void; nickname: string; activeOrderId: string | number; lastOrderId: string | number; referralCode: string; handleSubmitInvoiceClicked: (e:any, invoice: string) => void; host: string; showRewardsSpinner: boolean; withdrawn: boolean; badInvoice: boolean | string; earnedRewards: number; setAppState: (state: any) => void; // TODO: move to a ContextProvider } const ProfileDialog = ({ isOpen, handleClickCloseProfile, nickname, activeOrderId, lastOrderId, referralCode, handleSubmitInvoiceClicked, host, showRewardsSpinner, withdrawn, badInvoice, earnedRewards, setAppState, }: Props): JSX.Element => { const { t } = useTranslation(); const [rewardInvoice, setRewardInvoice] = useState(""); const [showRewards, setShowRewards] = useState(false); const [openClaimRewards, setOpenClaimRewards] = useState(false); const copyTokenHandler = () => { const robotToken = getCookie("robot_token"); if (robotToken) { navigator.clipboard.writeText(robotToken); setAppState({copiedToken:true}); } }; const copyReferralCodeHandler = () => { navigator.clipboard.writeText(`http://${host}/ref/${referralCode}`); }; return ( {t("Your Profile")} {nickname ? ( ) : null} {activeOrderId ? ( ) : lastOrderId ? ( ) : ( ) } {getCookie("robot_token") ? ( , }} /> ) : t("Cannot remember") } setShowRewards(!showRewards)} /> } /> {showRewards && ( <> , }} /> {!openClaimRewards ? ( {`${earnedRewards} Sats`} ) : (
{ setRewardInvoice(e.target.value); }} />
)}
{showRewardsSpinner && (
)} {withdrawn && (
{t("There it goes, thank you!🥇")}
)} )}
); }; export default ProfileDialog;