Skip to content

feat: Add extra fields to intervention#29

Merged
cballevre merged 9 commits intomainfrom
feat/add-extra-fields-intervention
Jul 31, 2025
Merged

feat: Add extra fields to intervention#29
cballevre merged 9 commits intomainfrom
feat/add-extra-fields-intervention

Conversation

@cballevre
Copy link
Copy Markdown
Owner

No description provided.

@cballevre cballevre requested a review from Copilot July 31, 2025 13:23
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 deleteEquipment is misleading since this component now handles multiple resource types. It should be renamed to something more generic like deleteResource or use a different variable name.
        deleteEquipment({

`${supplyCost} € (${translate('interventions.show.supply_cost')})`,
);
}
if (supplyCost !== undefined && laborCost !== undefined) {
Copy link

Copilot AI Jul 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
if (supplyCost !== undefined && laborCost !== undefined) {
if (supplyCost !== undefined && laborCost !== undefined && parts.length > 0) {

Copilot uses AI. Check for mistakes.
@@ -1,17 +1,23 @@
import { Link, useList, useTranslate } from '@refinedev/core';
import { Link, useInfiniteList, useTranslation } from '@refinedev/core';
Copy link

Copilot AI Jul 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
import { Link, useInfiniteList, useTranslation } from '@refinedev/core';
import { Link, useInfiniteList, useTranslate } from '@refinedev/core';

Copilot uses AI. Check for mistakes.
Comment on lines +108 to +113
const supply =
Number(formProps.form.getFieldValue('supply_cost')) ||
0;
formProps.form.setFieldsValue({
total_cost: labor + supply,
});
Copy link

Copilot AI Jul 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
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);

Copilot uses AI. Check for mistakes.
@cballevre cballevre merged commit 5604f89 into main Jul 31, 2025
1 check passed
@cballevre cballevre deleted the feat/add-extra-fields-intervention branch July 31, 2025 13:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants