fix problem

This commit is contained in:
hamid zarghami
2026-06-21 15:04:52 +03:30
parent d34a3a92f1
commit c565c0957f
5 changed files with 307 additions and 455 deletions
+185 -247
View File
@@ -1,260 +1,198 @@
'use client';
"use client";
import Button from '@/components/button/PrimaryButton';
import PasswordField from '@/components/input/PasswordField';
import TabContainer from '@/components/tab/TabContainer'
import { TabHeader } from '@/components/tab/TabHeader'
import { Switch } from '@/components/ui/switch';
import Accordion from '@/components/utils/Accordion';
import Seperator from '@/components/utils/Seperator';
import { SmartIcon } from '@/components/utils/SmartIcon';
import { getI18nObject } from '@/lib/i18n';
import { SettingsData } from '@/types/i18n/settings';
import { Key, KeySquare, Notification1, ArrowLeft, TickCircle } from 'iconsax-react'
import { useRouter } from 'next/navigation';
import React, { Fragment, useState } from 'react'
import { useTranslation } from 'react-i18next';
import { glassSurfaceCard } from '@/lib/styles/glassSurface';
import Button from "@/components/button/PrimaryButton";
import PasswordField from "@/components/input/PasswordField";
import { Switch } from "@/components/ui/switch";
import Accordion from "@/components/utils/Accordion";
import Seperator from "@/components/utils/Seperator";
import { SmartIcon } from "@/components/utils/SmartIcon";
import { getI18nObject } from "@/lib/i18n";
import { glassSurfaceCard } from "@/lib/styles/glassSurface";
import { SettingsData } from "@/types/i18n/settings";
import { ArrowLeft, Key, TickCircle } from "iconsax-react";
import { useRouter } from "next/navigation";
import React, { Fragment, useState } from "react";
import { useTranslation } from "react-i18next";
function UserSettingsIndex() {
const router = useRouter();
const { t } = useTranslation('settings');
const data: SettingsData = getI18nObject(t, "data");
const [statisticalParticipation, setStatisticalParticipation] = useState(true);
const router = useRouter();
const { t } = useTranslation("settings");
const data: SettingsData = getI18nObject(t, "data");
const [statisticalParticipation, setStatisticalParticipation] = useState(true);
const onSwitched = (e: React.MouseEvent) => {
const target = e.target as HTMLElement;
console.log('Save changed setting?', target.id);
}
const onSwitched = (e: React.MouseEvent) => {
const target = e.target as HTMLElement;
console.log("Save changed setting?", target.id);
};
const handleStatisticalToggle = (checked: boolean) => {
setStatisticalParticipation(checked);
console.log('Statistical participation:', checked);
}
const notifsTab = () => {
return (
<section aria-labelledby="about-title" className='py-4 flex-1 h-full'>
<section
className={glassSurfaceCard('p-4')}>
<div className="flex justify-between items-center pb-[25px]">
<h2 className='text-sm leading-5'>{data.TabNotifications.Heading}</h2>
</div>
<div className='p-2 pt-0'>
{data.TabNotifications.Accordions.map((accordion, i) => {
return (
<Fragment key={i}>
<Accordion
title={accordion.Heading}
group={'accordions'}
icon={accordion.Icon}
>
<div className='grid gap-4 mb-3'>
{accordion.Items.map((item, j) => {
return (
<label
key={j}
htmlFor={item.HtmlName}
className="flex w-full h-11 items-center justify-between gap-2 px-3 py-4 relative bg-container/29 rounded-xl border border-solid border-neutral-200 dark:border-neutral-600 focus:outline-none focus:ring-2 focus:ring-black"
>
<span className="inline-flex items-center gap-2.5 text-sm2">
<SmartIcon icon={item.Icon} />
{item.Label}
</span>
<Switch
onClick={onSwitched}
id={item.HtmlName}
name={item.HtmlName}
className="w-12 h-6 scale-[0.9]"
/>
</label>
)
})}
</div>
</Accordion>
<Seperator className='last:hidden' />
</Fragment>
)
})}
</div>
</section>
</section>
)
}
const passwordTab = () => {
return (
<section aria-labelledby="reviews-title" className='py-4'>
<section
className={glassSurfaceCard('p-4')}>
<div className="flex justify-between items-center pb-[25px]">
<h2 className='text-sm leading-5'>{data.TabPassword.Heading}</h2>
</div>
<form
onSubmit={(e) => e.preventDefault()}
className='grid gap-6 p-2'
>
{data.TabPassword.Inputs.map((input, i) => {
return (
<PasswordField
labelText={input.Label}
className='bg-container'
key={i}
htmlFor={input.HtmlName ?? ''}
placeholder={input.Placeholder}
autoComplete={input.AutoComplete}
/>
)
})
}
{data.TabPassword.Rules.map((rule, i) => {
return (
<section
key={i}
className='bg-background rounded-normal p-4 text-xs flex flex-col gap-2 font-light'
>
<h6 className='text-sm mb-2'>{rule.Heading}</h6>
{rule.Items.map((item, i) => {
return (
<li key={i}>{item}</li>
)
})}
</section>
)
})}
<Button className='mt-4'>
<div className='flex items-center justify-center gap-1'>
<TickCircle className='stroke-white' size={20} />
<span className='mt-0.5'>
{data.TabPassword.ButtonSubmit}
</span>
</div>
</Button>
</form>
</section>
</section>
)
}
const authenticatorTab = () => {
return (
<section aria-labelledby="reviews-title" className='py-4'>
<div
className={glassSurfaceCard('p-4')}>
<div className="pb-4">
<h2 className='text-sm leading-5'>{data.TabAuthenticator.Heading}</h2>
<p className='text-xs mt-3 text-disabled-text font-light'>{data.TabAuthenticator.Description}</p>
</div>
<Seperator />
<div className='p-2'>
<div className='mt-14 bg-blue-100 p-4 place-self-center rounded-full'>
<Key size={32} className='stroke-blue-500' />
</div>
<p className='text-sm2 mt-4 font-light place-self-center'>
{data.TabAuthenticator.Tip}
</p>
<div className='place-self-center mt-2'>
<Button className='mt-4 px-14 py-2'>
<div className='flex items-center justify-center gap-1'>
<TickCircle className='stroke-white' size={20} />
<span className='mt-0.5'>
{data.TabAuthenticator.ButtonSubmit}
</span>
</div>
</Button>
</div>
{data.TabAuthenticator.Guides.map((guide, i) => {
return (
<section
key={i}
className='bg-background rounded-normal mt-14 p-4 text-xs flex flex-col gap-2 font-light'
>
<h6 className='text-sm'>{guide.Heading}</h6>
<p className='text-disabled-text'>{guide.Description}</p>
{guide.Items.map((item, i) => {
return (
<div key={i}>
<div className='ml-2 mt-2 bg-blue-100 inline-block size-6 text-center pt-[5px] pr-[1px] text-blue-500 rounded-full'>
{item.Mark}
</div>
<span>
{item.Label}
</span>
</div>
)
})}
{guide.Notes.map((note, i) => {
return (
<div
key={i}
className='mt-4 p-3 text-yellow-800 rounded-lg bg-yellow-50 border border-solid border-yellow-200'
>
{note}
</div>
)
})}
</section>
)
})}
</div>
</div>
</section>
)
}
const handleStatisticalToggle = (checked: boolean) => {
setStatisticalParticipation(checked);
console.log("Statistical participation:", checked);
};
const notifsTab = () => {
return (
<div className='overflow-y-auto h-full noscrollbar flex flex-col gap-6'>
<div className='grid grid-cols-3 items-center'>
<span></span>
<h1 className='text-sm2 place-self-center font-medium'>{data.Heading}</h1>
<ArrowLeft
className='cursor-pointer place-self-end'
size='24'
color='currentColor'
onClick={() => { router.back() }}
/>
<section aria-labelledby="about-title" className="py-4 flex-1 h-full">
<section className={glassSurfaceCard("p-4")}>
<div className="flex justify-between items-center pb-[25px]">
<h2 className="text-sm leading-5">{data.TabNotifications.Heading}</h2>
</div>
<div className="p-2 pt-0">
{data.TabNotifications.Accordions.map((accordion, i) => {
return (
<Fragment key={i}>
<Accordion title={accordion.Heading} group={"accordions"} icon={accordion.Icon}>
<div className="grid gap-4 mb-3">
{accordion.Items.map((item, j) => {
return (
<label
key={j}
htmlFor={item.HtmlName}
className="flex w-full h-11 items-center justify-between gap-2 px-3 py-4 relative bg-container/29 rounded-xl border border-solid border-neutral-200 dark:border-neutral-600 focus:outline-none focus:ring-2 focus:ring-black"
>
<span className="inline-flex items-center gap-2.5 text-sm2">
<SmartIcon icon={item.Icon} />
{item.Label}
</span>
<Switch onClick={onSwitched} id={item.HtmlName} name={item.HtmlName} className="w-12 h-6 scale-[0.9]" />
</label>
);
})}
</div>
</Accordion>
<Seperator className="last:hidden" />
</Fragment>
);
})}
</div>
</section>
</section>
);
};
const passwordTab = () => {
return (
<section aria-labelledby="reviews-title" className="py-4">
<section className={glassSurfaceCard("p-4")}>
<div className="flex justify-between items-center pb-[25px]">
<h2 className="text-sm leading-5">{data.TabPassword.Heading}</h2>
</div>
<form onSubmit={(e) => e.preventDefault()} className="grid gap-6 p-2">
{data.TabPassword.Inputs.map((input, i) => {
return <PasswordField labelText={input.Label} className="bg-container" key={i} htmlFor={input.HtmlName ?? ""} placeholder={input.Placeholder} autoComplete={input.AutoComplete} />;
})}
{data.TabPassword.Rules.map((rule, i) => {
return (
<section key={i} className="bg-background rounded-normal p-4 text-xs flex flex-col gap-2 font-light">
<h6 className="text-sm mb-2">{rule.Heading}</h6>
{rule.Items.map((item, i) => {
return <li key={i}>{item}</li>;
})}
</section>
);
})}
<Button className="mt-4">
<div className="flex items-center justify-center gap-1">
<TickCircle className="stroke-white" size={20} />
<span className="mt-0.5">{data.TabPassword.ButtonSubmit}</span>
</div>
</Button>
</form>
</section>
</section>
);
};
const authenticatorTab = () => {
return (
<section aria-labelledby="reviews-title" className="py-4">
<div className={glassSurfaceCard("p-4")}>
<div className="pb-4">
<h2 className="text-sm leading-5">{data.TabAuthenticator.Heading}</h2>
<p className="text-xs mt-3 text-disabled-text font-light">{data.TabAuthenticator.Description}</p>
</div>
<Seperator />
<div className="p-2">
<div className="mt-14 bg-blue-100 p-4 place-self-center rounded-full">
<Key size={32} className="stroke-blue-500" />
</div>
<p className="text-sm2 mt-4 font-light place-self-center">{data.TabAuthenticator.Tip}</p>
<div className="place-self-center mt-2">
<Button className="mt-4 px-14 py-2">
<div className="flex items-center justify-center gap-1">
<TickCircle className="stroke-white" size={20} />
<span className="mt-0.5">{data.TabAuthenticator.ButtonSubmit}</span>
</div>
</Button>
</div>
<section className={glassSurfaceCard('p-4')}>
<div className='flex justify-between items-center pb-4'>
<h2 className='text-sm leading-5'>{data.StatisticalParticipation.Heading}</h2>
<Switch
checked={statisticalParticipation}
onCheckedChange={handleStatisticalToggle}
id={data.StatisticalParticipation.HtmlName}
name={data.StatisticalParticipation.HtmlName}
className="w-12 h-6 scale-[0.9]"
/>
</div>
<p className='text-xs text-disabled-text font-light'>
{data.StatisticalParticipation.Description}
</p>
</section>
{data.TabAuthenticator.Guides.map((guide, i) => {
return (
<section key={i} className="bg-background rounded-normal mt-14 p-4 text-xs flex flex-col gap-2 font-light">
<h6 className="text-sm">{guide.Heading}</h6>
<p className="text-disabled-text">{guide.Description}</p>
{guide.Items.map((item, i) => {
return (
<div key={i}>
<div className="ml-2 mt-2 bg-blue-100 inline-block size-6 text-center pt-[5px] pr-px text-blue-500 rounded-full">{item.Mark}</div>
<span>{item.Label}</span>
</div>
);
})}
{guide.Notes.map((note, i) => {
return (
<div key={i} className="mt-4 p-3 text-yellow-800 rounded-lg bg-yellow-50 border border-solid border-yellow-200">
{note}
</div>
);
})}
</section>
);
})}
</div>
</div>
)
</section>
);
};
return (
<div className="overflow-y-auto h-full noscrollbar flex flex-col gap-6">
<div className="grid grid-cols-3 items-center">
<span></span>
<h1 className="text-sm2 place-self-center font-medium">{data.Heading}</h1>
<ArrowLeft
className="cursor-pointer place-self-end"
size="24"
color="currentColor"
onClick={() => {
router.back();
}}
/>
</div>
<section className={glassSurfaceCard("p-4")}>
<div className="flex justify-between items-center pb-4">
<h2 className="text-sm leading-5">{data.StatisticalParticipation.Heading}</h2>
<Switch
checked={statisticalParticipation}
onCheckedChange={handleStatisticalToggle}
id={data.StatisticalParticipation.HtmlName}
name={data.StatisticalParticipation.HtmlName}
className="w-12 h-6 scale-[0.9]"
/>
</div>
<p className="text-xs text-disabled-text font-light">{data.StatisticalParticipation.Description}</p>
</section>
</div>
);
}
export default UserSettingsIndex
export default UserSettingsIndex;
+75 -102
View File
@@ -1,112 +1,85 @@
"use client";
import Button from '@/components/button/PrimaryButton';
import InputField from '@/components/input/InputField';
import { ef, ue } from '@/lib/helpers/utfNumbers';
import { ArrowLeft, ArrowRight, WalletMinus } from 'iconsax-react';
import { useRouter } from 'next/navigation';
import React, { useState } from 'react'
import { glassSurfaceCard } from '@/lib/styles/glassSurface';
import Button from "@/components/button/PrimaryButton";
import InputField from "@/components/input/InputField";
import { ef, ue } from "@/lib/helpers/utfNumbers";
import { glassSurfaceCard } from "@/lib/styles/glassSurface";
import { ArrowLeft, ArrowRight, WalletMinus } from "iconsax-react";
import { useRouter } from "next/navigation";
import React, { useState } from "react";
type Props = object
type Props = object;
function UserWalletIndex({ }: Props) {
const router = useRouter();
const [chargeValue, setChargeValue] = useState<string>('0');
const chargeAction = (e: React.FormEvent<HTMLFormElement>) => {
e.preventDefault();
const data = new FormData(e.currentTarget)
const value = Number(ue(String(data.get('chargeValue') ?? 0))) + 0;
console.log("Charge for: ", value);
}
function UserWalletIndex({}: Props) {
const router = useRouter();
const [chargeValue, setChargeValue] = useState<string>("0");
const chargeAction = (e: React.FormEvent<HTMLFormElement>) => {
e.preventDefault();
const data = new FormData(e.currentTarget);
const value = Number(ue(String(data.get("chargeValue") ?? 0))) + 0;
console.log("Charge for: ", value);
};
return (
<div className='overflow-y-auto h-full noscrollbar flex flex-col'>
<div className='grid grid-cols-3 items-center'>
<span></span>
<h1 className='text-sm2 place-self-center font-medium'>پروفایل کاربری</h1>
<ArrowLeft
className='cursor-pointer place-self-end'
size='24'
color='currentColor'
onClick={() => { router.back() }}
/>
return (
<div className="overflow-y-auto h-full noscrollbar flex flex-col">
<div className="grid grid-cols-3 items-center">
<span></span>
<h1 className="text-sm2 place-self-center font-medium">پروفایل کاربری</h1>
<ArrowLeft
className="cursor-pointer place-self-end"
size="24"
color="currentColor"
onClick={() => {
router.back();
}}
/>
</div>
<form onSubmit={chargeAction} className={glassSurfaceCard("mt-8 flex-1 h-full w-full py-6 px-4 flex flex-col justify-between")}>
<div className="">
<div className="flex items-center justify-center text-center gap-4 pb-6 border-b-[1.5px] border-border">
<div className="block">
<div className="font-medium text-sm flex items-center gap-2">
<WalletMinus className="size-5 stroke-foreground mb-0.5" />
موجودی کیف پول
</div>
<div className="text-sm text-primary mt-3 inline-flex dark:text-neutral-200 items-center gap-2">{ef("250.000 تومان")}</div>
</div>
</div>
<form
onSubmit={chargeAction}
className={glassSurfaceCard('mt-8 flex-1 h-full w-full py-6 px-4 flex flex-col justify-between')}>
<div className="">
<div className="flex items-center justify-center text-center gap-4 pb-6 border-b-[1.5px] border-border">
<div className='block'>
<div className='font-medium text-sm flex items-center gap-2'>
<WalletMinus className='size-5 stroke-foreground mb-0.5' />
موجودی کیف پول
</div>
<div className='text-sm text-primary mt-3 inline-flex dark:text-neutral-200 items-center gap-2'>
{ef('250.000 تومان')}
</div>
</div>
</div>
<div className="grid gap-3 mt-6">
<div className='inline-flex items-center mb-3 gap-2.5 text-sm2'>
برای شارژ کیف پول خود میتوانید بر روی یکی از مبالغ زیر کلیک کنید و یا مبلغ دلخواه خود را وارد کنید
</div>
<Button
type='button'
onClick={() => setChargeValue('50000')}
className='!bg-disabled text-sm2 !text-foreground flex justify-between items-center'
>
<ArrowRight className='stroke-foreground size-5' />
<span className='mt-0.5'>
{ef('50,000 تومان')}
</span>
</Button>
<Button
type='button'
onClick={() => setChargeValue('150000')}
className='!bg-disabled text-sm2 !text-foreground flex justify-between items-center'
>
<ArrowRight className='stroke-foreground size-5' />
<span className='mt-0.5'>
{ef('150,000 تومان')}
</span>
</Button>
<Button
type='button'
onClick={() => setChargeValue('300000')}
className='!bg-disabled text-sm2 !text-foreground flex justify-between items-center'
>
<ArrowRight className='stroke-foreground size-5' />
<span className='mt-0.5'>
{ef('300,000 تومان')}
</span>
</Button>
<InputField
className='bg-container mt-7'
labelText='مبلغ دلخواه (تومان)'
dir='ltr'
inputMode='decimal'
htmlFor='chargeValue'
placeholder=''
value={ef(chargeValue)}
onChange={(e) => setChargeValue(e.target.value)}
/>
</div>
</div>
<div className='w-full text-center mt-6'>
<Button
type='submit'
>
شارژ کیف پول
</Button>
</div>
</form>
<div className="grid gap-3 mt-6">
<div className="inline-flex items-center mb-3 gap-2.5 text-sm2">برای شارژ کیف پول خود میتوانید بر روی یکی از مبالغ زیر کلیک کنید و یا مبلغ دلخواه خود را وارد کنید</div>
<Button type="button" onClick={() => setChargeValue("50000")} className="bg-disabled! text-sm2 text-foreground! flex justify-between items-center">
<ArrowRight className="stroke-foreground size-5" />
<span className="mt-0.5">{ef("50,000 تومان")}</span>
</Button>
<Button type="button" onClick={() => setChargeValue("150000")} className="bg-disabled! text-sm2 text-foreground! flex justify-between items-center">
<ArrowRight className="stroke-foreground size-5" />
<span className="mt-0.5">{ef("150,000 تومان")}</span>
</Button>
<Button type="button" onClick={() => setChargeValue("300000")} className="bg-disabled! text-sm2 text-foreground! flex justify-between items-center">
<ArrowRight className="stroke-foreground size-5" />
<span className="mt-0.5">{ef("300,000 تومان")}</span>
</Button>
<InputField
className="bg-container mt-7"
labelText="مبلغ دلخواه (تومان)"
dir="ltr"
inputMode="decimal"
htmlFor="chargeValue"
placeholder=""
value={ef(chargeValue)}
onChange={(e) => setChargeValue(e.target.value)}
/>
</div>
</div>
)
<div className="w-full text-center mt-6">
<Button type="submit">شارژ کیف پول</Button>
</div>
</form>
</div>
);
}
export default UserWalletIndex
export default UserWalletIndex;