Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR adds cost tracking functionality and attachment support to interventions in the VesselVigil application. The changes enable users to track labor costs, supply costs, and total costs for interventions, while also allowing file attachments to be associated with interventions.
Key changes:
- Adds cost fields (total_cost, labor_cost, supply_cost) to the interventions table
- Creates a new intervention_attachments table with associated security policies
- Refactors attachment components to be reusable across different resource types
- Updates intervention forms to include cost input fields with breakdown functionality
Reviewed Changes
Copilot reviewed 19 out of 19 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| supabase/schemas/interventions.sql | Adds cost tracking fields to interventions table |
| supabase/schemas/intervention_attachments.sql | Creates new table and security policies for intervention attachments |
| supabase/schemas/equipment_attachments.sql | Updates constraint names for consistency |
| supabase/migrations/* | Database migration files implementing the schema changes |
| src/shared/types/models.ts | Adds TypeScript types for intervention entities |
| src/shared/components/resource-actions-menu.tsx | Generalizes actions menu to work with any resource type |
| src/shared/components/page-header.tsx | Adds back button functionality to page headers |
| src/shared/components/attachment-list.tsx | Refactors to be resource-agnostic for reusability |
| src/interventions/utils/cost.ts | Utility function for formatting cost breakdown strings |
| src/interventions/pages/* | Updates intervention pages with new cost display and attachment support |
| src/interventions/components/intervention-form.tsx | Enhanced form with cost input fields and breakdown functionality |
| public/locales/* | Translation updates for new intervention features |
Comments suppressed due to low confidence (1)
src/shared/components/resource-actions-menu.tsx:33
- The function name
deleteEquipmentis misleading since this component now handles multiple resource types. It should be renamed to something more generic likedeleteResourceor use a different variable name.
deleteEquipment({
| `${supplyCost} € (${translate('interventions.show.supply_cost')})`, | ||
| ); | ||
| } | ||
| if (supplyCost !== undefined && laborCost !== undefined) { |
There was a problem hiding this comment.
The condition for adding the '+' separator is incorrect. It should only add the '+' when both costs exist AND the supplyCost was actually added to parts. Currently, if supplyCost is 0 or undefined but laborCost exists, no '+' will be added even though laborCost will be displayed.
| if (supplyCost !== undefined && laborCost !== undefined) { | |
| if (supplyCost !== undefined && laborCost !== undefined && parts.length > 0) { |
| @@ -1,17 +1,23 @@ | |||
| import { Link, useList, useTranslate } from '@refinedev/core'; | |||
| import { Link, useInfiniteList, useTranslation } from '@refinedev/core'; | |||
There was a problem hiding this comment.
Mixing useTranslation from @refinedev/core with useTranslate would be inconsistent. The component uses useTranslation but other parts of the codebase use useTranslate. Should use useTranslate for consistency.
| import { Link, useInfiniteList, useTranslation } from '@refinedev/core'; | |
| import { Link, useInfiniteList, useTranslate } from '@refinedev/core'; |
| const supply = | ||
| Number(formProps.form.getFieldValue('supply_cost')) || | ||
| 0; | ||
| formProps.form.setFieldsValue({ | ||
| total_cost: labor + supply, | ||
| }); |
There was a problem hiding this comment.
The cost calculation logic is duplicated in both labor_cost and supply_cost onChange handlers. This should be extracted into a reusable function to reduce code duplication and improve maintainability.
| const supply = | |
| Number(formProps.form.getFieldValue('supply_cost')) || | |
| 0; | |
| formProps.form.setFieldsValue({ | |
| total_cost: labor + supply, | |
| }); | |
| const supply = Number(formProps.form.getFieldValue('supply_cost')) || 0; | |
| updateTotalCost(labor, supply); |
No description provided.