feat : formating code by prettier
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { Dispatch, SetStateAction } from "react";
|
||||
import { Dispatch, SetStateAction, useState } from "react";
|
||||
import MuiModal from "../../../../common/modal";
|
||||
import Button from "../../../../components/button";
|
||||
import { IoCopy } from "react-icons/io5";
|
||||
@@ -6,6 +6,8 @@ import Alert from "../../../../components/alert/Alert";
|
||||
import ProgressSpace from "../../../../components/progressSpace";
|
||||
import toast from "react-hot-toast";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { useDispatch } from "react-redux";
|
||||
import { setCategoryId } from "../../../../redux/slices/categoryId";
|
||||
|
||||
const ModalConfigDetails = ({
|
||||
isOpen,
|
||||
@@ -16,7 +18,11 @@ const ModalConfigDetails = ({
|
||||
isShowTraffic,
|
||||
textCopy,
|
||||
maxTraffic,
|
||||
traffic
|
||||
traffic,
|
||||
type,
|
||||
username,
|
||||
password,
|
||||
categoryId,
|
||||
}: {
|
||||
isOpen: boolean;
|
||||
setIsOpen: Dispatch<SetStateAction<boolean>>;
|
||||
@@ -27,17 +33,27 @@ const ModalConfigDetails = ({
|
||||
textCopy: string;
|
||||
maxTraffic: number | "unlimited";
|
||||
traffic: number;
|
||||
type: string;
|
||||
username: string;
|
||||
password: string;
|
||||
categoryId: number;
|
||||
}) => {
|
||||
const navigate = useNavigate()
|
||||
const navigate = useNavigate();
|
||||
const dispatch = useDispatch();
|
||||
const [copyText, setCopyText] = useState<string>("");
|
||||
const copyToClipboard = async (textToCopy: string) => {
|
||||
try {
|
||||
await navigator.clipboard.writeText(textToCopy);
|
||||
toast.success("متن با موفقیت کپی شد!");
|
||||
} catch (err) {
|
||||
toast.error(`Failed to copy: , ${err}`);
|
||||
try {
|
||||
await navigator.clipboard.writeText(copyText);
|
||||
toast.success("متن با موفقیت کپی شد!");
|
||||
} catch (err) {
|
||||
toast.error(`Failed to copy: , ${err}`);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<MuiModal
|
||||
isOpenModal={isOpen}
|
||||
@@ -49,20 +65,59 @@ const ModalConfigDetails = ({
|
||||
<h1 className="w-full h-full text-center rounded-md p-1 md:p-2 bg-gray-800">
|
||||
تاریخ خرید : {dateBuy}
|
||||
</h1>
|
||||
<div className="w-full h-full flex flex-row-reverse gap-2 justify-center items-center">
|
||||
<div className="w-full h-full flex flex-row-reverse gap-2 flex-wrap justify-center items-center">
|
||||
{isDisabled ? (
|
||||
<div className="w-full h-full grid grid-cols-1 justify-center items-center">
|
||||
<Button extra="!m-0 !px-2 !py-1 shadow-md shadow-secondTheme !bg-secondTheme font-bold hover:!bg-gray-800 hover:!shadow-gray-800 ">
|
||||
<div className="w-full h-full flex flex-wrap justify-center items-center">
|
||||
<Button extra="!m-0 !px-2 !py-1 shadow-md flex-1 shadow-secondTheme !bg-secondTheme font-bold hover:!bg-gray-800 hover:!shadow-gray-800 ">
|
||||
تمدید
|
||||
</Button>
|
||||
</div>
|
||||
) : (
|
||||
<>
|
||||
<Button onClick={() => copyToClipboard(textCopy)} extra="!m-0 !px-2 !py-1.5 flex flex-row-reverse justify-center items-center gap-1 shadow-md shadow-white">
|
||||
کپی
|
||||
<IoCopy />
|
||||
</Button>
|
||||
<Button onClick={()=> navigate('/tutorial')} extra="!m-0 !px-2 !py-1.5 shadow-md shadow-white">
|
||||
{type === "gaming" ? (
|
||||
<>
|
||||
<Button
|
||||
onClick={() => {
|
||||
setCopyText(username);
|
||||
copyToClipboard(username);
|
||||
}}
|
||||
extra="!m-0 !px-2 !py-1.5 flex flex-row-reverse justify-center items-center gap-1 shadow-md shadow-white"
|
||||
>
|
||||
کپی یوزرنیم
|
||||
<IoCopy />
|
||||
</Button>
|
||||
<Button
|
||||
onClick={() => {
|
||||
setCopyText(password);
|
||||
copyToClipboard(password);
|
||||
}}
|
||||
extra="!m-0 !px-2 !py-1.5 flex flex-row-reverse justify-center items-center gap-1 shadow-md shadow-white"
|
||||
>
|
||||
کپی پسورد
|
||||
<IoCopy />
|
||||
</Button>
|
||||
</>
|
||||
) : (
|
||||
<Button
|
||||
onClick={() => {
|
||||
setCopyText(textCopy);
|
||||
copyToClipboard(textCopy);
|
||||
}}
|
||||
extra="!m-0 !px-2 !py-1.5 flex flex-row-reverse justify-center items-center gap-1 shadow-md shadow-white"
|
||||
>
|
||||
کپی
|
||||
<IoCopy />
|
||||
</Button>
|
||||
)}
|
||||
<Button
|
||||
onClick={() => {
|
||||
if (categoryId) {
|
||||
dispatch(setCategoryId(categoryId));
|
||||
navigate("/tutorial");
|
||||
}
|
||||
}}
|
||||
extra="!m-0 !px-2 !py-1.5 shadow-md shadow-white"
|
||||
>
|
||||
آموزش
|
||||
</Button>
|
||||
</>
|
||||
|
||||
Reference in New Issue
Block a user