add input mask for phone in user settings page
This commit is contained in:
@@ -3,6 +3,8 @@
|
|||||||
import { useTranslations } from 'next-intl';
|
import { useTranslations } from 'next-intl';
|
||||||
import { useActionState, useState, useEffect } from 'react';
|
import { useActionState, useState, useEffect } from 'react';
|
||||||
import { useUserProfile } from '@/app/hooks/react-query/useUserDataInfo';
|
import { useUserProfile } from '@/app/hooks/react-query/useUserDataInfo';
|
||||||
|
import { InputMask, format } from '@react-input/mask';
|
||||||
|
import styles from '@/app/styles/module/login.module.scss';
|
||||||
|
|
||||||
export default function PersonalDataSettings() {
|
export default function PersonalDataSettings() {
|
||||||
const [errorMessage, formAction, isPending] = useActionState(
|
const [errorMessage, formAction, isPending] = useActionState(
|
||||||
@@ -70,12 +72,23 @@ export default function PersonalDataSettings() {
|
|||||||
<label className="form-label">
|
<label className="form-label">
|
||||||
{t('phone')}:
|
{t('phone')}:
|
||||||
</label>
|
</label>
|
||||||
<input
|
<InputMask
|
||||||
type="phone"
|
type="phone"
|
||||||
|
id="phone"
|
||||||
name="phone"
|
name="phone"
|
||||||
className="form-input"
|
className={`${styles['form-input']}`}
|
||||||
defaultValue={userData?.phone}
|
mask="+7 (___) ___-__-__"
|
||||||
|
replacement={{ _: /\d/ }}
|
||||||
|
value={(format(userData?.phone ? userData?.phone : '', {
|
||||||
|
mask: "+7 (___) ___-__-__",
|
||||||
|
replacement: { _: /\d/ }
|
||||||
|
}))}
|
||||||
|
disabled={true}
|
||||||
|
onChange={(e) => {
|
||||||
|
}}
|
||||||
|
placeholder="+7 (999) 123-45-67"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<button type="submit" className="btn btn-primary">
|
<button type="submit" className="btn btn-primary">
|
||||||
{t('save-changes')}
|
{t('save-changes')}
|
||||||
|
|||||||
Reference in New Issue
Block a user