e.stopPropagation()}
+ >
+
+
Izmeni boju
+
+
-
Izmeni boju
{
@@ -477,7 +491,7 @@ function ColorForm({
readOnly={isBambuLabColor}
pattern="^#[0-9A-Fa-f]{6}$"
placeholder="#000000"
- className={`flex-1 px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 focus:outline-none focus:ring-2 focus:ring-blue-500 ${isBambuLabColor ? 'bg-gray-100 dark:bg-gray-900 cursor-not-allowed' : ''}`}
+ className={`flex-1 px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md text-gray-900 dark:text-gray-100 focus:outline-none focus:ring-2 focus:ring-blue-500 ${isBambuLabColor ? 'bg-gray-100 dark:bg-gray-900 cursor-not-allowed' : 'bg-white dark:bg-gray-700'}`}
/>
{isBambuLabColor && (
diff --git a/app/upadaj/customers/page.tsx b/app/upadaj/customers/page.tsx
index 7e34341..601f823 100644
--- a/app/upadaj/customers/page.tsx
+++ b/app/upadaj/customers/page.tsx
@@ -25,6 +25,10 @@ export default function CustomersManagement() {
const [saving, setSaving] = useState(false);
const [darkMode, setDarkMode] = useState(false);
const [mounted, setMounted] = useState(false);
+ const [showAddModal, setShowAddModal] = useState(false);
+ const [addForm, setAddForm] = useState({ name: '', phone: '', city: '', notes: '' });
+ const [addError, setAddError] = useState('');
+ const [addSaving, setAddSaving] = useState(false);
// Initialize dark mode
useEffect(() => {
@@ -139,6 +143,35 @@ export default function CustomersManagement() {
}
};
+ const handleAddCustomer = async () => {
+ if (!addForm.name.trim()) {
+ setAddError('Ime je obavezno');
+ return;
+ }
+ setAddSaving(true);
+ setAddError('');
+ try {
+ await customerService.create({
+ name: addForm.name.trim(),
+ phone: addForm.phone.trim() || undefined,
+ city: addForm.city.trim() || undefined,
+ notes: addForm.notes.trim() || undefined,
+ });
+ setShowAddModal(false);
+ setAddForm({ name: '', phone: '', city: '', notes: '' });
+ await fetchCustomers();
+ } catch (err: unknown) {
+ const error = err as { response?: { data?: { code?: string } } };
+ if (error.response?.data?.code === '23505') {
+ setAddError('Kupac sa ovim brojem telefona vec postoji');
+ } else {
+ setAddError('Greska pri dodavanju kupca');
+ }
+ } finally {
+ setAddSaving(false);
+ }
+ };
+
const handleLogout = () => {
localStorage.removeItem('authToken');
localStorage.removeItem('tokenExpiry');
@@ -230,8 +263,8 @@ export default function CustomersManagement() {
+ {/* Search bar + Add button */}
+
setSearchTerm(e.target.value)}
className="w-full max-w-md px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-white placeholder-gray-400 dark:placeholder-gray-500 focus:ring-2 focus:ring-blue-500 focus:border-transparent"
/>
+
{/* Customer count */}
@@ -488,6 +527,108 @@ export default function CustomersManagement() {