40 lines
1.6 KiB
Python
40 lines
1.6 KiB
Python
import re
|
|
|
|
with open('kifi-app/lib/features/projects/presentation/widgets/add_project_sheet.dart', 'r') as f:
|
|
content = f.read()
|
|
|
|
# Add import
|
|
content = content.replace(
|
|
'import \'../../../sales/providers/customers_provider.dart\';',
|
|
'import \'../../../sales/providers/customers_provider.dart\';\nimport \'../../../sales/domain/customer.dart\';'
|
|
)
|
|
|
|
# Fix SmartSearchDropdown
|
|
old_dropdown = """ SmartSearchDropdown(
|
|
label: 'Client (Optional)',
|
|
items: customersState.value!.map((c) => DropdownMenuItem(value: c.id.toString(), child: Text(c.name))).toList(),
|
|
value: _selectedCustomerId?.toString(),
|
|
onChanged: (val) {
|
|
setState(() {
|
|
_selectedCustomerId = val != null ? int.parse(val) : null;
|
|
});
|
|
},
|
|
),"""
|
|
|
|
new_dropdown = """ SmartSearchDropdown<Customer>(
|
|
labelText: 'Client (Optional)',
|
|
items: customersState.value!,
|
|
itemAsString: (c) => c.name,
|
|
value: customersState.value!.where((c) => c.id == _selectedCustomerId).firstOrNull,
|
|
onChanged: (val) {
|
|
setState(() {
|
|
_selectedCustomerId = val?.id;
|
|
});
|
|
},
|
|
),"""
|
|
|
|
content = content.replace(old_dropdown, new_dropdown)
|
|
|
|
with open('kifi-app/lib/features/projects/presentation/widgets/add_project_sheet.dart', 'w') as f:
|
|
f.write(content)
|