fixed some statuses and filters
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { useState, useRef, useEffect } from "react";
|
||||
import { useState, useRef, useEffect, useMemo } from "react";
|
||||
import * as CollapsiblePrimitive from "@radix-ui/react-collapsible";
|
||||
import { Check, ChevronsUpDown, Search, X, Eye, EyeOff, Upload, Hash, CreditCard } from "lucide-react";
|
||||
|
||||
@@ -257,7 +257,7 @@ function PhoneInput({
|
||||
|
||||
<div
|
||||
className={cn(
|
||||
"flex h-8 w-full rounded-md border bg-background overflow-hidden",
|
||||
"flex h-8 w-full rounded-md border border-input bg-transparent dark:bg-input/30 overflow-hidden",
|
||||
"ring-offset-background transition-colors duration-150",
|
||||
"focus-within:outline-none focus-within:ring-1 focus-within:ring-ring focus-within:ring-offset-0",
|
||||
error ? "border-destructive focus-within:ring-destructive/30" : "border-input",
|
||||
@@ -273,7 +273,7 @@ function PhoneInput({
|
||||
onChange={handleChange}
|
||||
placeholder={placeholder}
|
||||
disabled={disabled}
|
||||
className="flex-1 h-full px-3 bg-transparent text-sm text-foreground placeholder:text-muted-foreground/50 focus:outline-none disabled:cursor-not-allowed"
|
||||
className="flex-1 h-full px-3 bg-transparent text-sm text-foreground placeholder:text-muted-foreground focus:outline-none disabled:cursor-not-allowed"
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -491,12 +491,12 @@ function DateInput({ value = "", onChange, error, disabled, required, label, cla
|
||||
type="button"
|
||||
disabled={disabled}
|
||||
className={cn(
|
||||
"flex h-8 w-full items-center justify-between rounded-md border bg-background px-3 py-2",
|
||||
"flex h-8 w-full items-center justify-between rounded-md border border-input bg-transparent dark:bg-input/30 px-3 py-2",
|
||||
"text-sm ring-offset-background transition-colors duration-150",
|
||||
"focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-0",
|
||||
"disabled:cursor-not-allowed disabled:opacity-50",
|
||||
error ? "border-destructive" : "border-input",
|
||||
!selected && "text-muted-foreground/60",
|
||||
!selected && "text-muted-foreground",
|
||||
)}
|
||||
>
|
||||
<span>{selected ? format(selected, "dd.MM.yyyy") : placeholder}</span>
|
||||
@@ -539,7 +539,16 @@ function SelectInput({
|
||||
}: FormInputProps) {
|
||||
const [open, setOpen] = useState(false);
|
||||
|
||||
const selected = options.find((o) => o.value === value);
|
||||
const uniqueOptions = useMemo(() => {
|
||||
const seen = new Set<string>();
|
||||
return options.filter((opt) => {
|
||||
if (seen.has(opt.value)) return false;
|
||||
seen.add(opt.value);
|
||||
return true;
|
||||
});
|
||||
}, [options]);
|
||||
|
||||
const selected = uniqueOptions.find((o) => o.value === value);
|
||||
|
||||
const handleSelect = (val: string) => {
|
||||
onChange?.(val);
|
||||
@@ -561,7 +570,7 @@ function SelectInput({
|
||||
type="button"
|
||||
disabled={disabled}
|
||||
className={cn(
|
||||
"flex h-8 w-full items-center justify-between rounded-md border bg-background px-3 py-2",
|
||||
"flex h-8 w-full items-center justify-between rounded-md border border-input bg-transparent dark:bg-input/30 px-3 py-2",
|
||||
"text-sm ring-offset-background transition-colors duration-150",
|
||||
"focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-0",
|
||||
"disabled:cursor-not-allowed disabled:opacity-50",
|
||||
@@ -569,7 +578,7 @@ function SelectInput({
|
||||
open && !error && "ring-2 ring-ring ring-offset-0 border-transparent",
|
||||
)}
|
||||
>
|
||||
<span className={cn("truncate text-left", !selected && "text-muted-foreground/60")}>
|
||||
<span className={cn("truncate text-left", !selected && "text-muted-foreground")}>
|
||||
{selected ? selected.label : placeholder}
|
||||
</span>
|
||||
<ChevronsUpDown
|
||||
@@ -583,7 +592,7 @@ function SelectInput({
|
||||
className={cn("absolute z-50 top-full left-0 right-0 mt-1", "rounded-md border border-border bg-card shadow-lg overflow-hidden")}
|
||||
>
|
||||
<div className="max-h-52 overflow-y-auto scrollbar-thin py-1">
|
||||
{options.map((opt) => {
|
||||
{uniqueOptions.map((opt) => {
|
||||
const isSelected = opt.value === value;
|
||||
return (
|
||||
<button
|
||||
@@ -633,8 +642,17 @@ function SearchableSelect({
|
||||
const [query, setQuery] = useState("");
|
||||
const searchRef = useRef<HTMLInputElement>(null);
|
||||
|
||||
const selected = options.find((o) => o.value === value);
|
||||
const filtered = query.trim() ? options.filter((o) => o.label.toLowerCase().includes(query.toLowerCase())) : options;
|
||||
const uniqueOptions = useMemo(() => {
|
||||
const seen = new Set<string>();
|
||||
return options.filter((opt) => {
|
||||
if (seen.has(opt.value)) return false;
|
||||
seen.add(opt.value);
|
||||
return true;
|
||||
});
|
||||
}, [options]);
|
||||
|
||||
const selected = uniqueOptions.find((o) => o.value === value);
|
||||
const filtered = query.trim() ? uniqueOptions.filter((o) => o.label.toLowerCase().includes(query.toLowerCase())) : uniqueOptions;
|
||||
|
||||
const openDropdown = () => {
|
||||
setOpen(true);
|
||||
@@ -680,7 +698,7 @@ function SearchableSelect({
|
||||
type="button"
|
||||
disabled={disabled}
|
||||
className={cn(
|
||||
"flex h-8 w-full items-center justify-between rounded-md border bg-background px-3 py-2",
|
||||
"flex h-8 w-full items-center justify-between rounded-md border border-input bg-transparent dark:bg-input/30 px-3 py-2",
|
||||
"text-sm ring-offset-background transition-colors duration-150",
|
||||
"focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-0",
|
||||
"disabled:cursor-not-allowed disabled:opacity-50",
|
||||
@@ -688,7 +706,7 @@ function SearchableSelect({
|
||||
open && !error && "ring-2 ring-ring ring-offset-0 border-transparent",
|
||||
)}
|
||||
>
|
||||
<span className={cn("truncate text-left", !selected && "text-muted-foreground/60")}>
|
||||
<span className={cn("truncate text-left", !selected && "text-muted-foreground")}>
|
||||
{selected ? selected.label : placeholder}
|
||||
</span>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user