diff --git a/.env b/.env index 2172812..1f2fb8d 100644 --- a/.env +++ b/.env @@ -6,8 +6,8 @@ VITE_DANAK_BASE_URL ='https://api.danakcorp.com' VITE_SOCKET_URL = 'wss://dmail-api.danakcorp.com/email' # VITE_SOCKET_URL = 'ws://192.168.1.118:4000/email' -# VITE_BASE_URL = 'https://dmail-api.danakcorp.com' -VITE_BASE_URL = 'http://192.168.1.101:4000' +VITE_BASE_URL = 'https://dmail-api.danakcorp.com' +# VITE_BASE_URL = 'http://192.168.1.101:4000' VITE_SERVICE_ID = 'e51afdc3-ea0b-49cf-8f49-2a6f131b024e' diff --git a/src/langs/fa.json b/src/langs/fa.json index 035042f..d976f5b 100644 --- a/src/langs/fa.json +++ b/src/langs/fa.json @@ -150,7 +150,11 @@ "2fa_step_2": "QR Code را اسکن کنید یا کد را به صورت دستی وارد کنید", "2fa_step_3": "کد 6 رقمی تولید شده توسط برنامه را وارد کنید", "note": "توجه", - "2fa_note": "کد های پشتیبان خود را در مکانی امن نگهداری کنید" + "2fa_note": "کد های پشتیبان خود را در مکانی امن نگهداری کنید", + "disable_2fa": "غیر فعال کردن دو مرحله ای", + "enter_2fa_code": "کد دو مرحله ای خود را وارد کنید", + "cancel": "انصراف", + "confirm_disable": "تایید غیر فعال سازی" }, "success": "عملیات با موفقیت انجام شد", "attachment_select": "اضافه کردن فایل ضمیمه", diff --git a/src/pages/setting/components/Enabled.tsx b/src/pages/setting/components/Enabled.tsx new file mode 100644 index 0000000..a0a8574 --- /dev/null +++ b/src/pages/setting/components/Enabled.tsx @@ -0,0 +1,103 @@ +import { FC, useState } from 'react' +import { useTranslation } from 'react-i18next' +import { Logout, TickCircle } from 'iconsax-react' +import Button from '@/components/Button' +import Input from '@/components/Input' +import { clx } from '@/helpers/utils' +import { toast } from '@/components/Toast' +import { ErrorType } from '@/helpers/types' +import { useDisableTwoFactor } from '../hooks/useSettingData' + +const Enabled: FC = () => { + + const { t } = useTranslation() + const [show, setShow] = useState(false) + const [token, setToken] = useState('') + const { mutate: disableTwoFactor } = useDisableTwoFactor() + + const handleDisableTwoFactor = () => { + if (token.length !== 6) { + toast(t('setting.invalid_code_length'), 'error') + return + } + + disableTwoFactor(token, { + onSuccess: () => { + setShow(false) + setToken('') + window.location.reload() + }, + onError: (error: ErrorType) => { + toast(error.response?.data?.error?.message[0] || t('setting.2fa_disabled_failed'), 'error') + } + }) + } + + return ( +