diff --git a/dashboard/public/locales/en.json b/dashboard/public/locales/en.json index 1aa66a9..0424063 100644 --- a/dashboard/public/locales/en.json +++ b/dashboard/public/locales/en.json @@ -106,6 +106,8 @@ "online_at": "Online At", "expire_date": "Expire Date", "unlimited": "Unlimited", + "limited": "Limited", + "data_limit_method": "Data limit type", "determined_expire": "Determined", "expire_method": "Expiration method", "onhold_expire": "On Hold", diff --git a/dashboard/public/locales/kur.json b/dashboard/public/locales/kur.json index 2883e83..2b7d071 100644 --- a/dashboard/public/locales/kur.json +++ b/dashboard/public/locales/kur.json @@ -98,7 +98,6 @@ "data_limit_reset_strategy": "Data Limit Reset Strategy", "online_at": "Online At", "expire_date": "Expire Date", - "unlimited": "Unlimited", "determined_expire": "Determined", "expire_method": "Expiration method", "onhold_expire": "On Hold", @@ -106,6 +105,9 @@ "revoke_subscription": "Revoke Subscription", "on_hold_expire_duration": "On Hold", "on_hold_timeout": "On Hold Timeout", + "unlimited": "Bêsinûr", + "limited": "Sinûrdar", + "data_limit_method": "Çonêtî Sinûrî Data", "settings": { "subscription_link": { "copied": "Subscription Link Copied", diff --git a/dashboard/src/features/users/dialogs/mutation/index.tsx b/dashboard/src/features/users/dialogs/mutation/index.tsx index 3cc5bc0..ed4337a 100644 --- a/dashboard/src/features/users/dialogs/mutation/index.tsx +++ b/dashboard/src/features/users/dialogs/mutation/index.tsx @@ -45,7 +45,7 @@ export const UsersMutationDialog: FC = ({ const { t } = useTranslation(); const getDefaultValues = useCallback((): UserMutationType => ({ services: [], - data_limit: 0, + data_limit: 1, expire: null, username: '', data_limit_reset_strategy: 'no_reset', @@ -65,14 +65,32 @@ export const UsersMutationDialog: FC = ({ getDefaultValue: getDefaultValues, }) - const [selectedTab, setSelectedTab] = useState<'determined' | 'onhold' | 'unlimited' | string>('determined'); + const [ + selectedDataLimitTab, + setSelectedDataLimitTab + ] = useState<'limited' | 'unlimited' | string>('limited'); + useEffect(() => { + if (selectedDataLimitTab === 'limited') { + form.setValue("data_limit", 1) + form.setValue("data_limit_reset_strategy", "no_reset"); + } else { + form.setValue("data_limit", 0) + form.setValue("data_limit_reset_strategy", "no_reset"); + } + }, [selectedDataLimitTab, form]); + + + const [ + selectedExpirationMethodTab, + setSelectedExpirationMethodTab + ] = useState<'determined' | 'onhold' | 'unlimited' | string>('determined'); useEffect(() => { form.setValue("status", "active") - if (selectedTab === 'onhold') { + if (selectedExpirationMethodTab === 'onhold') { form.setValue("status", "on_hold") form.setValue("expire", null); form.clearErrors("expire"); - } else if (selectedTab === "unlimited") { + } else if (selectedExpirationMethodTab === "unlimited") { form.setValue("expire", 0); form.setValue("on_hold_expire_duration", 0); form.setValue("on_hold_timeout", undefined); @@ -85,7 +103,7 @@ export const UsersMutationDialog: FC = ({ form.clearErrors("on_hold_expire_duration"); form.clearErrors("on_hold_timeout"); } - }, [selectedTab, form]); + }, [selectedExpirationMethodTab, form]); return ( @@ -102,14 +120,33 @@ export const UsersMutationDialog: FC = ({
+ + {t('page.users.data_limit_method')} +
- - {form.watch().data_limit !== 0 && } + + + + {t('page.users.limited')} + + + {t('page.users.unlimited')} + + + + + {form.watch().data_limit !== 0 && } + +
{t('page.users.expire_method')} - +