This commit is contained in:
hamid zarghami
2025-12-22 16:33:01 +03:30
parent 9e9caca2ec
commit e3bfe65d9c
3 changed files with 38 additions and 18 deletions
@@ -12,19 +12,27 @@ import { getI18nObject } from '@/lib/i18n';
import { SettingsData } from '@/types/i18n/settings'; import { SettingsData } from '@/types/i18n/settings';
import { Key, KeySquare, Notification1, ArrowLeft, TickCircle } from 'iconsax-react' import { Key, KeySquare, Notification1, ArrowLeft, TickCircle } from 'iconsax-react'
import { useRouter } from 'next/navigation'; import { useRouter } from 'next/navigation';
import React, { Fragment } from 'react' import React, { Fragment, useState } from 'react'
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
function UserSettingsIndex() { function UserSettingsIndex() {
const router = useRouter(); const router = useRouter();
const { t } = useTranslation('settings'); const { t } = useTranslation('settings');
const data: SettingsData = getI18nObject(t, "data"); const data: SettingsData = getI18nObject(t, "data");
const [statisticalParticipation, setStatisticalParticipation] = useState(true);
const onSwitched = (e: React.MouseEvent) => { const onSwitched = (e: React.MouseEvent) => {
const target = e.target as HTMLElement; const target = e.target as HTMLElement;
console.log('Save changed setting?', target.id); console.log('Save changed setting?', target.id);
} }
const handleStatisticalToggle = (checked: boolean) => {
setStatisticalParticipation(checked);
console.log('Statistical participation:', checked);
}
const notifsTab = () => { const notifsTab = () => {
return ( return (
@@ -227,23 +235,23 @@ function UserSettingsIndex() {
onClick={() => { router.back() }} onClick={() => { router.back() }}
/> />
</div> </div>
<TabContainer>
<TabHeader <section className='bg-container rounded-container shadow-container p-4'>
viewRenderer={notifsTab()} <div className='flex justify-between items-center pb-4'>
title={data.TabNotifications.Title} <h2 className='text-sm leading-5'>{data.StatisticalParticipation.Heading}</h2>
icon={<Notification1 size={24} />} <Switch
checked={statisticalParticipation}
onCheckedChange={handleStatisticalToggle}
id={data.StatisticalParticipation.HtmlName}
name={data.StatisticalParticipation.HtmlName}
className="w-12 h-6 scale-[0.9]"
/> />
<TabHeader </div>
viewRenderer={passwordTab()} <p className='text-xs text-disabled-text font-light'>
title={data.TabPassword.Title} {data.StatisticalParticipation.Description}
icon={<KeySquare size={24} />} </p>
/> </section>
<TabHeader
viewRenderer={authenticatorTab()}
title={data.TabAuthenticator.Title}
icon={<Key size={24} />}
/>
</TabContainer>
</div> </div>
) )
} }
+5
View File
@@ -121,6 +121,11 @@
} }
], ],
"ButtonSubmit": "راه‌اندازی کد دو مرحله‌ای" "ButtonSubmit": "راه‌اندازی کد دو مرحله‌ای"
},
"StatisticalParticipation": {
"Heading": "مشارکت در اطلاعات آماری",
"Description": "اطلاعات آماری در تحقیقات بازاریابی و برای بهبود تجربه استفاده از خدمات به کار میرود.",
"HtmlName": "statistical-participation"
} }
} }
} }
+7
View File
@@ -61,9 +61,16 @@ export interface TabAuthenticator {
ButtonSubmit: string; ButtonSubmit: string;
} }
export interface StatisticalParticipation {
Heading: string;
Description: string;
HtmlName: string;
}
export interface SettingsData { export interface SettingsData {
Heading: string; Heading: string;
TabNotifications: TabNotifications; TabNotifications: TabNotifications;
TabPassword: TabPassword; TabPassword: TabPassword;
TabAuthenticator: TabAuthenticator; TabAuthenticator: TabAuthenticator;
StatisticalParticipation: StatisticalParticipation;
} }