barcha apilar ulandi

This commit is contained in:
Samandar Turgunboyev
2025-10-31 18:42:21 +05:00
parent 39f5b8ca3c
commit 77bce24399
19 changed files with 1306 additions and 656 deletions

View File

@@ -40,10 +40,7 @@ const Login = () => {
const { mutate, isPending } = useMutation({
mutationFn: ({ password, phone }: { password: string; phone: string }) =>
authLogin({
password,
phone,
}),
authLogin({ password, phone }),
onSuccess: (res) => {
setAuthToken(res.data.access);
setAuthRefToken(res.data.refresh);
@@ -83,9 +80,17 @@ const Login = () => {
});
function onSubmit(values: z.infer<typeof formSchema>) {
const cleanPhone = onlyNumber(values.phone);
// allow both 998 and 888 prefixes
if (!cleanPhone.startsWith("998") && !cleanPhone.startsWith("888")) {
toast.error(t("Telefon raqami +998 yoki +888 bilan boshlanishi kerak"));
return;
}
mutate({
password: values.password,
phone: onlyNumber(values.phone),
phone: cleanPhone,
});
}
@@ -110,12 +115,20 @@ const Login = () => {
</FormLabel>
<FormControl>
<Input
placeholder="+998 __ ___-__-__"
placeholder="+998 yoki +888 bilan boshlang"
{...field}
value={field.value || "+998"}
onChange={(e) =>
field.onChange(formatPhone(e.target.value))
}
value={field.value}
onChange={(e) => {
const inputValue = e.target.value;
if (inputValue.trim() === "") {
field.onChange("");
return;
}
// Formatlash
field.onChange(formatPhone(inputValue));
}}
maxLength={19}
className="h-[56px] text-lg rounded-xl bg-gray-700 border-gray-600 text-white placeholder-gray-400"
/>