diff --git a/__tests__/ui-features.test.ts b/__tests__/ui-features.test.ts
index 1136681..274d80e 100644
--- a/__tests__/ui-features.test.ts
+++ b/__tests__/ui-features.test.ts
@@ -21,14 +21,17 @@ describe('UI Features Tests', () => {
expect(tableContent).toContain('color.hex');
});
- it('should have checkboxes for boolean fields', () => {
+ it('should have number inputs for quantity fields', () => {
const adminDashboardPath = join(process.cwd(), 'app', 'upadaj', 'dashboard', 'page.tsx');
const adminContent = readFileSync(adminDashboardPath, 'utf-8');
- // Check for checkbox inputs
- expect(adminContent).toMatch(/type="checkbox"[\s\S]*?name="refill"/);
- expect(adminContent).toMatch(/type="checkbox"[\s\S]*?name="vakum"/);
- expect(adminContent).toMatch(/type="checkbox"[\s\S]*?name="otvoreno"/);
+ // Check for number inputs for quantities
+ expect(adminContent).toMatch(/type="number"[\s\S]*?name="refill"/);
+ expect(adminContent).toMatch(/type="number"[\s\S]*?name="vakum"/);
+ expect(adminContent).toMatch(/type="number"[\s\S]*?name="otvoreno"/);
+ expect(adminContent).toContain('Refill količina');
+ expect(adminContent).toContain('Vakuum količina');
+ expect(adminContent).toContain('Otvoreno količina');
});
it('should have number input for quantity', () => {
diff --git a/app/upadaj/dashboard/page.tsx b/app/upadaj/dashboard/page.tsx
index ed4e553..12059a4 100644
--- a/app/upadaj/dashboard/page.tsx
+++ b/app/upadaj/dashboard/page.tsx
@@ -265,25 +265,33 @@ export default function AdminDashboard() {
- {filament.refill?.toLowerCase() === 'da' ? (
- ✓
- ) : (
- ✗
- )}
+ {(() => {
+ const refillCount = parseInt(filament.refill) || 0;
+ if (refillCount > 0) {
+ return {refillCount};
+ }
+ return 0;
+ })()}
|
- {filament.vakum?.toLowerCase().includes('vakuum') ? (
- ✓
- ) : (
- ✗
- )}
+ {(() => {
+ const match = filament.vakum?.match(/^(\d+)\s*vakuum/);
+ const vakuumCount = match ? parseInt(match[1]) : 0;
+ if (vakuumCount > 0) {
+ return {vakuumCount};
+ }
+ return 0;
+ })()}
|
- {filament.otvoreno?.toLowerCase().includes('otvorena') ? (
- ✓
- ) : (
- ✗
- )}
+ {(() => {
+ const match = filament.otvoreno?.match(/^(\d+)\s*otvorena/);
+ const otvorenCount = match ? parseInt(match[1]) : 0;
+ if (otvorenCount > 0) {
+ return {otvorenCount};
+ }
+ return 0;
+ })()}
|
{filament.kolicina} |
{filament.cena} |
@@ -392,28 +400,17 @@ function FilamentForm({
}, [filament]);
const handleChange = (e: React.ChangeEvent) => {
- const { name, value, type } = e.target;
+ const { name, value } = e.target;
- if (type === 'checkbox') {
- const checked = (e.target as HTMLInputElement).checked;
- if (name === 'vakum') {
- setFormData({
- ...formData,
- [name]: checked ? 'vakuum' : ''
- });
- } else if (name === 'otvoreno') {
- setFormData({
- ...formData,
- [name]: checked ? 'otvorena' : ''
- });
- } else if (name === 'refill') {
- setFormData({
- ...formData,
- [name]: checked ? 'Da' : '',
- // Auto-fill price based on refill status if this is a new filament
- ...(filament.id ? {} : { cena: checked ? '3499' : '3999' })
- });
- }
+ if (name === 'refill') {
+ // Auto-set price based on refill quantity
+ const refillCount = parseInt(value) || 0;
+ setFormData({
+ ...formData,
+ [name]: value,
+ // Auto-fill price based on refill status if this is a new filament
+ ...(filament.id ? {} : { cena: refillCount > 0 ? '3499' : '3999' })
+ });
} else {
setFormData({
...formData,
@@ -593,40 +590,85 @@ function FilamentForm({
/>
- {/* Checkboxes grouped together horizontally */}
-