edit company-user registration

This commit is contained in:
smanylov
2026-02-05 19:31:06 +07:00
parent 8890cfb067
commit 777555c187
4 changed files with 60 additions and 19 deletions
+10 -3
View File
@@ -1,16 +1,23 @@
'use client'
import { useState, ChangeEvent } from 'react';
import { useState, ChangeEvent, useEffect } from 'react';
import { InputMask } from '@react-input/mask';
import styles from '@/app/styles/module/login.module.scss';
interface PhoneInputProps {
phoneState: string | undefined;
validateHandler: (e: ChangeEvent<HTMLInputElement>) => void;
clearCondition?: string | undefined | null
}
export default function PhoneInput({ phoneState, validateHandler }: PhoneInputProps) {
const [phone, setPhone] = useState(phoneState ? phoneState : '');
export default function PhoneInput({ phoneState, validateHandler, clearCondition }: PhoneInputProps) {
const [phone, setPhone] = useState<string | undefined>(phoneState ? phoneState : '');
useEffect(() => {
if (clearCondition) {
setPhone('');
}
}, [clearCondition])
return (
<InputMask
@@ -11,6 +11,7 @@ import { SignupFormSchema } from '@/app/actions/definitions';
import * as z from 'zod';
import PhoneInput from '@/app/ui/inputs/phone-input';
import { IconEye } from '@/app/ui/icons/icons';
import { toast } from 'sonner';
export function CompanyUsersSettingPanel() {
const {
@@ -43,6 +44,9 @@ export function CompanyUsersSettingPanel() {
useEffect(() => {
if (state) {
setFormState(state);
if (state.createdUser) {
toast.success(`Создан пользователь - ${state.createdUser}`);
}
}
}, [state])
@@ -84,7 +88,6 @@ export function CompanyUsersSettingPanel() {
case 'agree':
const schema = SignupFormSchema.shape[fieldName];
if (fieldName === 'phone') {
console.log(schema.safeParse(value.replace(/[-\(\)\s]/g, '')));
return schema.safeParse(value.replace(/[-\(\)\s]/g, ''));
}
if (fieldName === 'companyName') {
@@ -204,6 +207,7 @@ export function CompanyUsersSettingPanel() {
<PhoneInput
phoneState={formState?.previousState?.phone}
validateHandler={onChangeHandler}
clearCondition={state?.createdUser}
/>
{formState?.error?.phone && (
<p className="text-sm text-red-500">
@@ -294,6 +298,12 @@ export function CompanyUsersSettingPanel() {
)}
</div>
{formState?.error?.server && (
<p className="text-sm text-red-500 mt-4">
{t(formState?.error?.server)}
</p>
)}
<button type="submit" className="btn btn-primary">
Добавить пользователя
</button>
@@ -25,6 +25,10 @@ export default function PersonalDataSettings() {
}
});
useEffect(() => {
console.log(userData)
}, [userData]);
const t = useTranslations('Global');
return (