34 lines
1.8 KiB
Python
34 lines
1.8 KiB
Python
import re
|
|
|
|
with open('kifi-app/lib/features/sales/presentation/invoice_builder_screen.dart', 'r') as f:
|
|
content = f.read()
|
|
|
|
# Read projectModeProvider to check if in Project Mode
|
|
if "project_mode_provider.dart" not in content:
|
|
content = content.replace("import '../../inventory/providers/products_provider.dart';", "import '../../inventory/providers/products_provider.dart';\nimport '../../projects/providers/project_mode_provider.dart';")
|
|
|
|
# In _buildAddLineItemDialog (inside showDialog builder)
|
|
# Oh wait, we need to read it inside the dialog, which has `Consumer(builder: (context, dialogRef, _))`
|
|
old_consumer = r""" Consumer\(
|
|
builder: \(context, dialogRef, _\) \{
|
|
final productsState = dialogRef\.watch\(productsProvider\);
|
|
return productsState\.when\("""
|
|
new_consumer = """ Consumer(
|
|
builder: (context, dialogRef, _) {
|
|
final isProjectMode = dialogRef.watch(projectModeProvider);
|
|
final productsState = dialogRef.watch(productsProvider);
|
|
|
|
// In project mode, skip product selector
|
|
if (isProjectMode) {
|
|
return const SizedBox.shrink();
|
|
}
|
|
|
|
return productsState.when("""
|
|
|
|
content = re.sub(old_consumer, new_consumer, content)
|
|
|
|
# Remove Making Chg and Other Chg fields if in project mode
|
|
# They are hardcoded as text fields. I can just wrap them in `if (!isProjectMode)` ... but `isProjectMode` isn't accessible directly unless we refactor the whole dialog.
|
|
# Since it's inside Consumer, the whole column is NOT inside the Consumer. The text fields are outside.
|
|
|