diff --git a/.env b/.env index 9902bec..36eab8a 100644 --- a/.env +++ b/.env @@ -1,4 +1,4 @@ VITE_TOKEN_NAME = 'dsc_token' VITE_REFRESH_TOKEN_NAME = 'dsc_refresh_token' VITE_BASE_URL = 'https://api.danakcorp.com' -# VITE_BASE_URL = 'http://192.168.0.216:4000' \ No newline at end of file +# VITE_BASE_URL = 'http://192.168.1.124:4000' \ No newline at end of file diff --git a/src/App.tsx b/src/App.tsx index ec25db7..678c05d 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -15,6 +15,7 @@ import AuthRouter from './router/Auth' import { Pages } from './config/Pages' import useConvertNumbers from './hooks/useConvertNumbers'; import { Helmet, HelmetProvider } from 'react-helmet-async'; +import moment from 'moment-jalaali'; i18next.init({ interpolation: { escapeValue: false }, @@ -47,6 +48,7 @@ const App: FC = () => { // useNumberFont() useConvertNumbers() + moment.loadPersian({ usePersianDigits: true, dialect: "persian-modern" }); const [isLogin, setIsLogin] = useState<'checking' | 'isLogin' | 'isNotLogin'>('checking') useEffect(() => { diff --git a/src/components/Input.tsx b/src/components/Input.tsx index 87ebe55..e8a9f24 100644 --- a/src/components/Input.tsx +++ b/src/components/Input.tsx @@ -18,11 +18,57 @@ type Props = { onChangeSearchFinal?: (value: string) => void; } & InputHTMLAttributes +const formatNumber = (value: string | number): string => { + if (!value) return ''; + const inputValue = String(value).replace(/,/g, ''); + return inputValue.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ','); +}; + const Input: FC = (props: Props) => { + const [formattedValue, setFormattedValue] = useState( + props.value ? formatNumber(props.value as string) : '' + ); + const [showPassword, setShowPassword] = useState(false) const [search, setSearch] = useState('') + const inputClass = clx( + 'w-full h-10 text-black block px-4 text-xs rounded-xl border border-border', + props.readOnly && 'bg-gray-100 border-0 text-description', + props.variant === 'search' && 'bg-[#EEF0F7] border-0 ps-10', + props.className + ); + + const handleInputChange = (event: React.ChangeEvent) => { + if (props.seprator) { + const inputValue = event.target.value.replace(/,/g, ''); // حذف کاماها + const formatted = formatNumber(inputValue); + + // به‌روزرسانی مقدار قالب‌بندی‌شده + setFormattedValue(formatted); + + // ارسال مقدار خام به `onChange` والد + props.onChange?.({ + ...event, + target: { + ...event.target, + value: inputValue, + }, + }); + } else { + props.onChange?.(event); + } + }; + + useEffect(() => { + if (props.value) { + setFormattedValue(formatNumber(props.value as string)); + } else { + setFormattedValue(''); + } + }, [props.value]) + useEffect(() => { if (props.variant === 'search' && props.onChangeSearchFinal) { const timeout = setTimeout(() => { @@ -32,13 +78,6 @@ const Input: FC = (props: Props) => { } }, [search, props]) - const inputClass = clx( - 'w-full h-10 text-black block px-4 text-xs rounded-xl border border-border', - props.readOnly && 'bg-gray-100 border-0 text-description', - props.variant === 'search' && 'bg-[#EEF0F7] border-0 ps-10', - props.className - ); - return (
@@ -49,8 +88,8 @@ const Input: FC = (props: Props) => {
{ setSearch(e.target.value) - props.onChange?.(e) - }} type={props.type === 'password' && showPassword ? 'text' : props.type === 'password' ? 'password' : undefined} className={inputClass} /> + handleInputChange(e) + }} value={props.seprator ? formattedValue : props.value} type={props.type === 'password' && showPassword ? 'text' : props.type === 'password' ? 'password' : undefined} className={inputClass} /> { props.type === 'password' && @@ -62,15 +101,13 @@ const Input: FC = (props: Props) => { } - + { + props.error_text && + + }
- - { - props.error_text && - - }
) } diff --git a/src/langs/fa.json b/src/langs/fa.json index 874543f..1ebee29 100644 --- a/src/langs/fa.json +++ b/src/langs/fa.json @@ -443,7 +443,8 @@ "failed": "پرداخت ناموفق!", "desc_failed": "متأسفیم! پرداخت شما انجام نشد. لطفاً دوباره تلاش کنید یا روش پرداخت دیگری انتخاب کنید.", "pending": "وضعیت پرداخت نامشخص است!", - "desc_pending": "اگر مبلغی از حساب شما کسر شده ولی سفارش شما بعد از ۷۲ ساعت تأیید نشد، لطفاً با پشتیبانی تماس بگیرید." + "desc_pending": "اگر مبلغی از حساب شما کسر شده ولی سفارش شما بعد از ۷۲ ساعت تأیید نشد، لطفاً با پشتیبانی تماس بگیرید.", + "home": "صفحه اصلی" }, "discount": { "number": "شماره", diff --git a/src/pages/notification/Notification.tsx b/src/pages/notification/Notification.tsx index 47851a5..9ada20d 100644 --- a/src/pages/notification/Notification.tsx +++ b/src/pages/notification/Notification.tsx @@ -38,7 +38,7 @@ const Notifications: FC = () => {
setShowModal(!showModal)} className='relative cursor-pointer'> -
+
{getDashboard.data?.data?.notificationCount}
diff --git a/src/pages/payment/CallBack.tsx b/src/pages/payment/CallBack.tsx index 715f259..0406c22 100644 --- a/src/pages/payment/CallBack.tsx +++ b/src/pages/payment/CallBack.tsx @@ -93,11 +93,18 @@ const CallBack: FC = () => {
-