refactor(services): Simplify deposit to single amount field

- Remove deposit_percent field (doesn't work for variable pricing)
- Make deposit_amount default to 0 (no deposit)
- Deposit now applies to both variable and fixed pricing services
- Add requires_deposit and requires_saved_payment_method as computed properties
- Simplify frontend form with single deposit amount input
- Show deposit badge in service list when deposit > 0

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
poduck
2025-12-04 13:42:46 -05:00
parent 7da5d55831
commit c7308ad167
6 changed files with 92 additions and 188 deletions

View File

@@ -24,10 +24,10 @@ export const useServices = () => {
description: s.description || '',
displayOrder: s.display_order ?? 0,
photos: s.photos || [],
// Variable pricing fields
// Pricing fields
variable_pricing: s.variable_pricing ?? false,
deposit_amount: s.deposit_amount ? parseFloat(s.deposit_amount) : null,
deposit_percent: s.deposit_percent ? parseFloat(s.deposit_percent) : null,
deposit_amount: s.deposit_amount ? parseFloat(s.deposit_amount) : 0,
requires_deposit: s.requires_deposit ?? false,
requires_saved_payment_method: s.requires_saved_payment_method ?? false,
deposit_display: s.deposit_display || null,
}));
@@ -68,8 +68,7 @@ interface ServiceInput {
description?: string;
photos?: string[];
variable_pricing?: boolean;
deposit_amount?: number | null;
deposit_percent?: number | null;
deposit_amount?: number; // 0 = no deposit
}
/**
@@ -88,16 +87,13 @@ export const useCreateService = () => {
photos: serviceData.photos || [],
};
// Add variable pricing fields if enabled
// Add pricing fields
if (serviceData.variable_pricing !== undefined) {
backendData.variable_pricing = serviceData.variable_pricing;
}
if (serviceData.deposit_amount !== undefined) {
backendData.deposit_amount = serviceData.deposit_amount;
}
if (serviceData.deposit_percent !== undefined) {
backendData.deposit_percent = serviceData.deposit_percent;
}
const { data } = await apiClient.post('/services/', backendData);
return data;
@@ -122,10 +118,9 @@ export const useUpdateService = () => {
if (updates.price !== undefined) backendData.price = updates.price.toString();
if (updates.description !== undefined) backendData.description = updates.description;
if (updates.photos !== undefined) backendData.photos = updates.photos;
// Variable pricing fields
// Pricing fields
if (updates.variable_pricing !== undefined) backendData.variable_pricing = updates.variable_pricing;
if (updates.deposit_amount !== undefined) backendData.deposit_amount = updates.deposit_amount;
if (updates.deposit_percent !== undefined) backendData.deposit_percent = updates.deposit_percent;
const { data } = await apiClient.patch(`/services/${id}/`, backendData);
return data;