Fix bugs
This commit is contained in:
parent
165cab01ce
commit
4d5aa62ca2
@ -19,7 +19,7 @@ const ChangePassword: React.FC<IChangePasswordProps> = ({
|
|||||||
closeWindow,
|
closeWindow,
|
||||||
}: IChangePasswordProps) => {
|
}: IChangePasswordProps) => {
|
||||||
const session = useSession();
|
const session = useSession();
|
||||||
const [error, setError] = useState<string>("");
|
const [errorServer, setErrorServer] = useState<string>("");
|
||||||
const [loader, setLoader] = useState<boolean>(false);
|
const [loader, setLoader] = useState<boolean>(false);
|
||||||
const [success, setSuccess] = useState<boolean>(false);
|
const [success, setSuccess] = useState<boolean>(false);
|
||||||
|
|
||||||
@ -47,31 +47,34 @@ const ChangePassword: React.FC<IChangePasswordProps> = ({
|
|||||||
const onSubmit = async (data: FormFields) => {
|
const onSubmit = async (data: FormFields) => {
|
||||||
try {
|
try {
|
||||||
console.log(data);
|
console.log(data);
|
||||||
// console.log("cfvgbhnj");
|
setErrorServer("");
|
||||||
// setError("");
|
setLoader(true);
|
||||||
// setLoader(true);
|
|
||||||
|
|
||||||
// const Authorization = `Bearer ${session.data?.access_token}`;
|
const Authorization = `Bearer ${session.data?.access_token}`;
|
||||||
// const config = {
|
const config = {
|
||||||
// headers: {
|
headers: {
|
||||||
// Authorization,
|
Authorization,
|
||||||
// },
|
},
|
||||||
// };
|
};
|
||||||
// const res = await apiInstance.patch(
|
const res = await apiInstance.patch(
|
||||||
// "/auth/password_change/",
|
"/auth/password_change/",
|
||||||
// data,
|
data,
|
||||||
// config
|
config
|
||||||
// );
|
);
|
||||||
|
|
||||||
// if ([200, 201].includes(res.status)) return setSuccess(true);
|
if ([200, 201].includes(res.status)) return setSuccess(true);
|
||||||
} catch (error: unknown) {
|
} catch (error: unknown) {
|
||||||
// if (error instanceof AxiosError) {
|
if (error instanceof AxiosError) {
|
||||||
// if (error.response?.status === 400) {
|
if (error.response?.status === 400) {
|
||||||
// setError("Некорректный старый пароль или недопустимый новый пароль");
|
setErrorServer(
|
||||||
// }
|
"Некорректный старый пароль или недопустимый новый пароль"
|
||||||
// } else {
|
);
|
||||||
// setError("Произошла непредвиденная ошибка");
|
} else if (error.response?.status === 401) {
|
||||||
// }
|
setErrorServer("Вы не авторизованы");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
setErrorServer("Произошла непредвиденная ошибка");
|
||||||
|
}
|
||||||
} finally {
|
} finally {
|
||||||
setLoader(false);
|
setLoader(false);
|
||||||
}
|
}
|
||||||
@ -112,7 +115,7 @@ const ChangePassword: React.FC<IChangePasswordProps> = ({
|
|||||||
placeholder="Повторите новый пароль"
|
placeholder="Повторите новый пароль"
|
||||||
label="Потвердить новый пароль"
|
label="Потвердить новый пароль"
|
||||||
/>
|
/>
|
||||||
{error ? <p className="text-red-500">{error}</p> : null}
|
{errorServer && <p className="text-red-500">{errorServer}</p>}
|
||||||
{success ? (
|
{success ? (
|
||||||
<p className="text-light-blue">Вы успешно поменяли пароль!</p>
|
<p className="text-light-blue">Вы успешно поменяли пароль!</p>
|
||||||
) : null}
|
) : null}
|
||||||
|
@ -25,10 +25,7 @@ const ChangePasswordInput: React.FC<Props> = ({
|
|||||||
register,
|
register,
|
||||||
formState: { errors },
|
formState: { errors },
|
||||||
} = useFormContext();
|
} = useFormContext();
|
||||||
console.log(name);
|
|
||||||
|
|
||||||
const errorText = errors[name]?.message as string;
|
const errorText = errors[name]?.message as string;
|
||||||
|
|
||||||
const [isOpen, setIsOpen] = useState<boolean>(false);
|
const [isOpen, setIsOpen] = useState<boolean>(false);
|
||||||
return (
|
return (
|
||||||
<div className={cn("flex flex-col gap-2", className)}>
|
<div className={cn("flex flex-col gap-2", className)}>
|
||||||
@ -40,14 +37,14 @@ const ChangePasswordInput: React.FC<Props> = ({
|
|||||||
)}
|
)}
|
||||||
<div
|
<div
|
||||||
className={`py-[10px] px-[14px] flex items-center justify-between border border-gray-300 rounded-md shadow-sm bg-gray-200${
|
className={`py-[10px] px-[14px] flex items-center justify-between border border-gray-300 rounded-md shadow-sm bg-gray-200${
|
||||||
errorText ? "-with-error" : ""
|
errorText && "border-red-500"
|
||||||
}`}
|
}`}
|
||||||
>
|
>
|
||||||
<input
|
<input
|
||||||
{...register(name)}
|
{...register(name)}
|
||||||
{...props}
|
{...props}
|
||||||
type={isOpen ? "text" : "password"}
|
type={isOpen ? "text" : "password"}
|
||||||
className="w-full text-[14px] placeholder:leading-6 bg-gray-200"
|
className="w-full text-[14px] placeholder:leading-6 bg-gray-100"
|
||||||
/>
|
/>
|
||||||
<button onClick={() => setIsOpen((prev) => !prev)} type="button">
|
<button onClick={() => setIsOpen((prev) => !prev)} type="button">
|
||||||
<Image src={isOpen ? eye_on : eye_off} alt="Eye Icon" />
|
<Image src={isOpen ? eye_on : eye_off} alt="Eye Icon" />
|
||||||
|
@ -176,9 +176,6 @@ const ProfileForm: React.FC<IProfileFormProps> = ({
|
|||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{openPopup && <ChangePassword closeWindow={setOpenPopup} />}
|
|
||||||
|
|
||||||
{error ? <p>{error}</p> : null}
|
{error ? <p>{error}</p> : null}
|
||||||
|
|
||||||
<button
|
<button
|
||||||
@ -192,6 +189,7 @@ const ProfileForm: React.FC<IProfileFormProps> = ({
|
|||||||
</button>
|
</button>
|
||||||
<LogoutButton className="sm:block lg:flex-none" />
|
<LogoutButton className="sm:block lg:flex-none" />
|
||||||
</form>
|
</form>
|
||||||
|
{openPopup && <ChangePassword closeWindow={setOpenPopup} />}
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
15
src/widgets/forms/ProfileForm/icons/eye-off.svg
Normal file
15
src/widgets/forms/ProfileForm/icons/eye-off.svg
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
<svg width="24.000000" height="24.000000" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||||
|
<desc>
|
||||||
|
Created with Pixso.
|
||||||
|
</desc>
|
||||||
|
<defs>
|
||||||
|
<clipPath id="clip1668_50526">
|
||||||
|
<rect id="eye-off" width="24.000000" height="24.000000" fill="white" fill-opacity="0"/>
|
||||||
|
</clipPath>
|
||||||
|
</defs>
|
||||||
|
<rect id="eye-off" width="24.000000" height="24.000000" fill="#FFFFFF" fill-opacity="0"/>
|
||||||
|
<g clip-path="url(#clip1668_50526)">
|
||||||
|
<path id="Vector" d="M17.9404 17.9404C16.2305 19.2432 14.1494 19.9648 12 20C5 20 1 12 1 12C2.24414 9.68164 3.96875 7.65625 6.05957 6.05957M9.90039 4.24023C10.5879 4.0791 11.293 3.99805 12 4C19 4 23 12 23 12C22.3926 13.1357 21.6689 14.2051 20.8398 15.1904M14.1201 14.1201C13.8457 14.415 13.5137 14.6514 13.1465 14.8154C12.7783 14.9795 12.3809 15.0674 11.9785 15.0742C11.5752 15.0811 11.1748 15.0078 10.8018 14.8564C10.4277 14.7061 10.0889 14.4814 9.80371 14.1963C9.51855 13.9111 9.29395 13.5723 9.14355 13.1982C8.99219 12.8252 8.91895 12.4248 8.92578 12.0215C8.93262 11.6191 9.02051 11.2217 9.18457 10.8535C9.34863 10.4863 9.58496 10.1543 9.87988 9.87988" stroke="#979797" stroke-opacity="1.000000" stroke-width="2.000000" stroke-linejoin="round"/>
|
||||||
|
<path id="Vector" d="M1 1L23 23" stroke="#979797" stroke-opacity="1.000000" stroke-width="2.000000" stroke-linejoin="round" stroke-linecap="round"/>
|
||||||
|
</g>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 1.4 KiB |
15
src/widgets/forms/ProfileForm/icons/eye-on.svg
Normal file
15
src/widgets/forms/ProfileForm/icons/eye-on.svg
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
<svg width="24.000000" height="24.000000" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||||
|
<desc>
|
||||||
|
Created with Pixso.
|
||||||
|
</desc>
|
||||||
|
<defs>
|
||||||
|
<clipPath id="clip1668_50161">
|
||||||
|
<rect id="eye" width="24.000000" height="24.000000" fill="white" fill-opacity="0"/>
|
||||||
|
</clipPath>
|
||||||
|
</defs>
|
||||||
|
<rect id="eye" width="24.000000" height="24.000000" fill="#FFFFFF" fill-opacity="0"/>
|
||||||
|
<g clip-path="url(#clip1668_50161)">
|
||||||
|
<path id="Vector" d="M12 4C19 4 23 12 23 12C23 12 19 20 12 20C5 20 1 12 1 12C1 12 5 4 12 4Z" stroke="#979797" stroke-opacity="1.000000" stroke-width="2.000000" stroke-linejoin="round"/>
|
||||||
|
<path id="Vector" d="M12 15C10.3428 15 9 13.6572 9 12C9 10.3428 10.3428 9 12 9C13.6572 9 15 10.3428 15 12C15 13.6572 13.6572 15 12 15Z" stroke="#979797" stroke-opacity="1.000000" stroke-width="2.000000" stroke-linejoin="round"/>
|
||||||
|
</g>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 901 B |
Loading…
Reference in New Issue
Block a user