@apptimate/ui 4.3.0 → 4.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -179,7 +179,7 @@ export function DashboardLayout({
|
|
|
179
179
|
return (
|
|
180
180
|
<div
|
|
181
181
|
key={menu.id}
|
|
182
|
-
onClick={() =>
|
|
182
|
+
onClick={() => setActiveMenuId(menu.id)}
|
|
183
183
|
className={`flex flex-col items-center justify-center gap-1.5 cursor-pointer transition-colors w-full px-1 ${isActive ? "text-[#2D3142]" : "text-gray-400 hover:text-[#2D3142]"
|
|
184
184
|
}`}
|
|
185
185
|
>
|
|
@@ -19,6 +19,7 @@ interface PartyPickerProps {
|
|
|
19
19
|
placeholder?: string;
|
|
20
20
|
isRequired?: boolean;
|
|
21
21
|
partyType?: "customer" | "supplier" | "all";
|
|
22
|
+
customTrigger?: (onClick: () => void) => React.ReactNode;
|
|
22
23
|
}
|
|
23
24
|
|
|
24
25
|
export function PartyPicker({
|
|
@@ -29,6 +30,7 @@ export function PartyPicker({
|
|
|
29
30
|
placeholder = "Select party…",
|
|
30
31
|
isRequired = false,
|
|
31
32
|
partyType = "all",
|
|
33
|
+
customTrigger,
|
|
32
34
|
}: PartyPickerProps) {
|
|
33
35
|
const [isOpen, setIsOpen] = useState(false);
|
|
34
36
|
const [search, setSearch] = useState("");
|
|
@@ -43,11 +45,11 @@ export function PartyPicker({
|
|
|
43
45
|
const [quickAddPhone, setQuickAddPhone] = useState("");
|
|
44
46
|
const [isCreating, setIsCreating] = useState(false);
|
|
45
47
|
|
|
46
|
-
const fetchData = useCallback(async () => {
|
|
48
|
+
const fetchData = useCallback(async (query: string = "") => {
|
|
47
49
|
setIsLoading(true);
|
|
48
50
|
try {
|
|
49
51
|
const typeParam = partyType === "all" ? undefined : partyType;
|
|
50
|
-
const res = await lookupParties(typeParam);
|
|
52
|
+
const res = await lookupParties({ type: typeParam, search: query, limit: 100 });
|
|
51
53
|
if (res.is_success) {
|
|
52
54
|
const data = res.result?.data || res.result || [];
|
|
53
55
|
setParties(data.map((p: any) => ({ ...p, name: p.name || p.full_name || [p.first_name, p.last_name].filter(Boolean).join(" ") })));
|
|
@@ -56,10 +58,18 @@ export function PartyPicker({
|
|
|
56
58
|
setIsLoading(false);
|
|
57
59
|
}, [partyType]);
|
|
58
60
|
|
|
61
|
+
useEffect(() => {
|
|
62
|
+
if (isOpen) {
|
|
63
|
+
const delayFn = setTimeout(() => {
|
|
64
|
+
fetchData(search);
|
|
65
|
+
}, 300);
|
|
66
|
+
return () => clearTimeout(delayFn);
|
|
67
|
+
}
|
|
68
|
+
}, [search, isOpen, fetchData]);
|
|
69
|
+
|
|
59
70
|
const handleOpen = () => {
|
|
60
71
|
setSearch("");
|
|
61
72
|
setIsOpen(true);
|
|
62
|
-
fetchData();
|
|
63
73
|
};
|
|
64
74
|
|
|
65
75
|
const handleSelect = (party: any) => {
|
|
@@ -104,21 +114,22 @@ export function PartyPicker({
|
|
|
104
114
|
setIsCreating(false);
|
|
105
115
|
};
|
|
106
116
|
|
|
107
|
-
|
|
108
|
-
const filtered = parties.filter((p) =>
|
|
109
|
-
(p.name || "").toLowerCase().includes(searchLower) || (p.code || "").toLowerCase().includes(searchLower)
|
|
110
|
-
);
|
|
117
|
+
// Server-side filtering used
|
|
111
118
|
|
|
112
119
|
return (
|
|
113
120
|
<>
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
121
|
+
{customTrigger ? (
|
|
122
|
+
customTrigger(handleOpen)
|
|
123
|
+
) : (
|
|
124
|
+
<PickerTrigger
|
|
125
|
+
label={label}
|
|
126
|
+
value={displayValue || null}
|
|
127
|
+
placeholder={placeholder}
|
|
128
|
+
isRequired={isRequired}
|
|
129
|
+
onClick={handleOpen}
|
|
130
|
+
onClear={value ? handleClear : undefined}
|
|
131
|
+
/>
|
|
132
|
+
)}
|
|
122
133
|
|
|
123
134
|
<EntityPickerModal
|
|
124
135
|
isOpen={isOpen}
|
|
@@ -152,14 +163,14 @@ export function PartyPicker({
|
|
|
152
163
|
<div className="inline-block h-6 w-6 rounded-full border-2 border-gray-200 border-t-primary-500 animate-spin" />
|
|
153
164
|
<p className="mt-3 text-sm text-gray-400">Loading {label.toLowerCase()}s…</p>
|
|
154
165
|
</div>
|
|
155
|
-
) :
|
|
166
|
+
) : parties.length === 0 ? (
|
|
156
167
|
<div className="py-12 text-center">
|
|
157
168
|
<User size={32} className="mx-auto text-gray-300 mb-2" />
|
|
158
169
|
<p className="text-sm text-gray-400">No {label.toLowerCase()}s found</p>
|
|
159
170
|
</div>
|
|
160
171
|
) : (
|
|
161
172
|
<div className="space-y-0.5 py-1">
|
|
162
|
-
{
|
|
173
|
+
{parties.map((party) => (
|
|
163
174
|
<PickerItem
|
|
164
175
|
key={party.id}
|
|
165
176
|
label={party.name}
|