diff --git a/src/components/SupportButton.tsx b/src/components/SupportButton.tsx index a54955f..74a29c9 100644 --- a/src/components/SupportButton.tsx +++ b/src/components/SupportButton.tsx @@ -1,42 +1,45 @@ -import { useState } from 'react' -import { createPortal } from 'react-dom' -import Icon from './Icon' +import { useState } from "react"; +import { createPortal } from "react-dom"; +import Icon from "./Icon"; -const SUPPORT_PHONE = '02111111111' -const SUPPORT_PHONE_DISPLAY = '۰۲۱-۱۱۱۱۱۱۱۱' +const SUPPORT_PHONE = "02111111111"; +const SUPPORT_PHONE_DISPLAY = "۰۲۱-۱۱۱۱۱۱۱۱"; function isMobileDevice() { - return 'ontouchstart' in window || navigator.maxTouchPoints > 0 + return "ontouchstart" in window || navigator.maxTouchPoints > 0; } export default function SupportButton({ className }: { className?: string }) { - const [open, setOpen] = useState(false) - const [copied, setCopied] = useState(false) + const [open, setOpen] = useState(false); + const [copied, setCopied] = useState(false); const handleClick = () => { if (isMobileDevice()) { window.location.href = `tel:${SUPPORT_PHONE}` } else { - setOpen(true) + setOpen(true); } - } + }; const handleCopy = async () => { try { - await navigator.clipboard.writeText(SUPPORT_PHONE) - setCopied(true) - setTimeout(() => setCopied(false), 2000) + await navigator.clipboard.writeText(SUPPORT_PHONE); + setCopied(true); + setTimeout(() => setCopied(false), 2000); } catch { // silent fallback } - } + }; return ( <> @@ -44,33 +47,47 @@ export default function SupportButton({ className }: { className?: string }) { {open && createPortal( <> -
setOpen(false)} /> -
- -
+
setOpen(false)} + /> +
+
+

+ {copied ? ( + "کپی شد!" + ) : ( +

+ شماره تماس پشتیبانی:{" "} + {SUPPORT_PHONE_DISPLAY} + +
+ )} +

-

- {copied ? 'کپی شد!' : `شماره تماس پشتیبانی: ${SUPPORT_PHONE_DISPLAY}`} -

, document.body, )} - ) + ); }