started connect with api
This commit is contained in:
@@ -2,7 +2,7 @@ import { useState, useRef, useEffect } from "react";
|
||||
import * as CollapsiblePrimitive from "@radix-ui/react-collapsible";
|
||||
import { Check, ChevronsUpDown, Search, X, Eye, EyeOff, Upload, Hash } from "lucide-react";
|
||||
|
||||
import { cn } from "@/lib/utils";
|
||||
import { cn, cleanPhoneNumber, formatFromApiDate } from "@/lib/utils";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Textarea } from "@/components/ui/textarea";
|
||||
import { Button } from "@/components/ui/button";
|
||||
@@ -175,6 +175,9 @@ function PhoneInput({
|
||||
className,
|
||||
phonePrefix = "+993",
|
||||
}: FormInputProps) {
|
||||
// Gelen veride ülke kodu (+993) veya boşluklar olsa bile temiz 8 haneyi elde et
|
||||
const cleanedDigits = cleanPhoneNumber(value);
|
||||
|
||||
const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||
const digits = e.target.value.replace(/\D/g, "").slice(0, 8);
|
||||
|
||||
@@ -185,6 +188,8 @@ function PhoneInput({
|
||||
}
|
||||
};
|
||||
|
||||
const formattedDisplayValue = cleanedDigits.length <= 2 ? cleanedDigits : `${cleanedDigits.slice(0, 2)} ${cleanedDigits.slice(2)}`;
|
||||
|
||||
return (
|
||||
<div className={className}>
|
||||
<FieldLabel label={label} required={required} />
|
||||
@@ -203,7 +208,7 @@ function PhoneInput({
|
||||
</div>
|
||||
<input
|
||||
type="tel"
|
||||
value={value}
|
||||
value={formattedDisplayValue}
|
||||
onChange={handleChange}
|
||||
placeholder={placeholder}
|
||||
disabled={disabled}
|
||||
@@ -221,8 +226,9 @@ function PhoneInput({
|
||||
function DateInput({ value = "", onChange, error, disabled, required, label, className, placeholder = "Sene saýlaň" }: FormInputProps) {
|
||||
const [open, setOpen] = useState(false);
|
||||
|
||||
// value is stored as 'yyyy-MM-dd' string
|
||||
const parsed = value ? parse(value, "yyyy-MM-dd", new Date()) : undefined;
|
||||
// value backend'den 'yyyy-MM-dd' veya 'yyyy-MM-ddTHH:mm:ssZ' gelebilir
|
||||
const dateStr = formatFromApiDate(value);
|
||||
const parsed = dateStr ? parse(dateStr, "yyyy-MM-dd", new Date()) : undefined;
|
||||
const selected = parsed && isValid(parsed) ? parsed : undefined;
|
||||
|
||||
const handleSelect = (day: Date | undefined) => {
|
||||
|
||||
Reference in New Issue
Block a user