Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 44 additions & 13 deletions public/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@
}
},
"equipments": {
"single": "equipment",
"list": {
"title": "Equipment List",
"subtitle": "Manage your boat's equipment",
Expand All @@ -179,11 +180,8 @@
},
"show": {
"title": "Equipment Details",
"edit": "Edit Equipment"
},
"delete": {
"confirmTitle": "Confirm delete",
"confirmContent": "Do you really want to delete this equipment?"
"edit": "Edit Equipment",
"back": "Back to equipments"
},
"form": {
"labels": {
Expand All @@ -201,22 +199,25 @@
"name_required": "Equipment name is required.",
"system_required": "System is required."
}
},
"attachments": {
"title": "Attachments",
"add": "Add an attachment"
}
},
"interventions": {
"single": "intervention",
"list": {
"title": "Intervention List",
"add": "Add an intervention"
"title": "Interventions",
"add": "Add intervention",
"subtitle": "Done on {{date}}"
},
"add": {
"title": "Add an intervention"
},
"show": {
"edit": "Edit Intervention"
"title": "Intervention Details",
"edit": "Edit Intervention",
"back": "Back to interventions",
"total_cost": "Total cost",
"labor_cost": "Labor",
"supply_cost": "Supplies"
},
"edit": {
"title": "Edit Intervention"
Expand All @@ -225,7 +226,21 @@
"labels": {
"title": "Title",
"date": "Date",
"description": "Description"
"description": "Notes",
"cost_group": {
"title": "Costs",
"labor": "Labor",
"supply": "Supplies",
"total": "Total"
}
},
"validation": {
"title_required": "Title is required.",
"date_required": "Date is required."
},
"actions": {
"breakdown_costs": "Break down costs",
"simplify_costs": "Simplify costs"
}
}
},
Expand Down Expand Up @@ -264,5 +279,21 @@
"action": "Add people"
}
}
},
"shared": {
"attachments": {
"title": "Attachments",
"add": "Add an attachment",
"download": "Download",
"delete": "Delete"
},
"actions_menu": {
"delete": {
"confirm": {
"title": "Confirm delete",
"content": "Do you really want to delete this {{resource}}?"
}
}
}
}
}
57 changes: 44 additions & 13 deletions public/locales/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@
}
},
"equipments": {
"single": "équipement",
"list": {
"title": "Liste des équipements",
"subtitle": "Gérez les équipements de votre bateau",
Expand All @@ -179,11 +180,8 @@
},
"show": {
"title": "Détails de l'équipement",
"edit": "Modifier l'équipement"
},
"delete": {
"confirmTitle": "Confirmer la suppression",
"confirmContent": "Voulez-vous vraiment supprimer cet équipement ?"
"edit": "Modifier l'équipement",
"back": "Retour aux équipements"
},
"form": {
"labels": {
Expand All @@ -201,22 +199,25 @@
"name_required": "Le nom de l'équipement est requis.",
"system_required": "Le système est requis."
}
},
"attachments": {
"title": "Pièces jointes",
"add": "Ajouter une pièce jointe"
}
},
"interventions": {
"single": "intervention",
"list": {
"title": "Liste des interventions",
"add": "Ajouter une intervention"
"title": "Interventions",
"add": "Ajouter une intervention",
"subtitle": "Réalisée le {{date}}"
},
"add": {
"title": "Ajouter une intervention"
},
"show": {
"edit": "Modifier l'intervention"
"title": "Détails de l'intervention",
"edit": "Modifier l'intervention",
"back": "Retour aux interventions",
"total_cost": "Coût total",
"labor_cost": "Main d'œuvre",
"supply_cost": "Fournitures"
},
"edit": {
"title": "Editer l'intervention"
Expand All @@ -225,7 +226,21 @@
"labels": {
"title": "Titre",
"date": "Date",
"description": "Description"
"description": "Notes",
"cost_group": {
"title": "Coûts",
"labor": "Main d'œuvre",
"supply": "Fournitures",
"total": "Total"
}
},
"validation": {
"title_required": "Le titre est requis.",
"date_required": "La date est requise."
},
"actions": {
"breakdown_costs": "Détailler les coûts",
"simplify_costs": "Simplifier les coûts"
}
}
},
Expand Down Expand Up @@ -264,5 +279,21 @@
"action": "Ajouter des personnes"
}
}
},
"shared": {
"attachments": {
"title": "Pièces jointes",
"add": "Ajouter une pièce jointe",
"download": "Télécharger",
"delete": "Supprimer"
},
"actions_menu": {
"delete": {
"confirm": {
"title": "Confirmer la suppression",
"content": "Voulez-vous vraiment supprimer cet {{resource}} ?"
}
}
}
}
}
7 changes: 5 additions & 2 deletions src/equipments/pages/list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import { Button, Card, Empty, List } from 'antd';

import { useCurrentBoat } from '@/boats/hooks/use-current-boat';
import { boatSystemList } from '@/boats/utils/boat-system';
import { EquipmentActionsMenu } from '@/equipments/components/equipment-actions-menu';
import { PageContent } from '@/shared/components/page-content';
import { PageHeader } from '@/shared/components/page-header';
import { ResourceActionsMenu } from '@/shared/components/resource-actions-menu';
import { SectionHeader } from '@/shared/components/section-header';
import type { Equipment } from '@/shared/types/models';

Expand Down Expand Up @@ -81,7 +81,10 @@ const EquipmentList = () => {
}
description={getEquipmentSubtitle(equipment)}
/>
<EquipmentActionsMenu equipment={equipment} />
<ResourceActionsMenu
resource="equipments"
resourceId={equipment.id}
/>
</List.Item>
)}
/>
Expand Down
5 changes: 3 additions & 2 deletions src/equipments/pages/show.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import dayjs from 'dayjs';
import { useParams } from 'react-router';

import { useCurrentBoat } from '@/boats/hooks/use-current-boat';
import { EquipmentAttachmentList } from '@/equipments/components/equipment-attachment-list';
import { AttachmentList } from '@/shared/components/attachment-list';
import { PageHeader } from '@/shared/components/page-header';

const ShowEquipment = () => {
Expand All @@ -26,6 +26,7 @@ const ShowEquipment = () => {
<Button type="primary">{translate('equipments.show.edit')}</Button>
</Link>
}
back={translate('equipments.show.back')}
/>
<Card>
<Typography.Paragraph>
Expand Down Expand Up @@ -88,7 +89,7 @@ const ShowEquipment = () => {
</Typography.Paragraph>
) : null}
</Card>
<EquipmentAttachmentList equipmentId={equipmentId} />
<AttachmentList resource="equipment" resourceId={equipmentId} />
</>
);
};
Expand Down
117 changes: 111 additions & 6 deletions src/interventions/components/intervention-form.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { ArrowDownOutlined, ArrowUpOutlined } from '@ant-design/icons';
import { useTranslate } from '@refinedev/core';
import { DatePicker, Form, Input } from 'antd';
import { Button, DatePicker, Form, Input, Space } from 'antd';
import dayjs from 'dayjs';
import type { FC } from 'react';
import { useState } from 'react';

interface InterventionFormProps {
formProps: any;
Expand All @@ -13,27 +15,130 @@ const InterventionForm: FC<InterventionFormProps> = ({
handleOnFinish,
}) => {
const translate = useTranslate();
const [isDetailedCost, setDetailedCost] = useState(false);

return (
<Form {...formProps} onFinish={handleOnFinish} layout="vertical">
<Form.Item
label={translate('interventions.form.labels.title')}
name="title"
rules={[
{
required: true,
message: translate('interventions.form.validation.title_required'),
},
]}
>
<Input />
</Form.Item>
<Form.Item
label={translate('interventions.form.labels.date')}
name="date"
getValueProps={(value) => ({ value: value ? dayjs(value) : null })}
rules={[
{
required: true,
message: translate('interventions.form.validation.date_required'),
},
]}
>
<DatePicker />
</Form.Item>
<Form.Item
label={translate('interventions.form.labels.description')}
name="description"
>
<Input />
<Input.TextArea />
</Form.Item>

<Form.Item
label={translate('interventions.form.labels.date')}
name="date"
getValueProps={(value) => ({ value: value ? dayjs(value) : null })}
label={translate('interventions.form.labels.cost_group.title')}
style={{ marginBottom: 0 }}
>
<DatePicker />
<div
style={{
border: '1px dashed #d9d9d9',
padding: '16px',
borderRadius: '8px',
}}
>
<Space
style={{ marginBottom: isDetailedCost ? 16 : 0 }}
size="middle"
align="end"
>
<Form.Item
label={translate('interventions.form.labels.cost_group.total')}
name="total_cost"
style={{ marginBottom: 0 }}
>
<Input
type="number"
step="0.01"
min={0}
disabled={isDetailedCost}
/>
</Form.Item>
<Button
icon={
isDetailedCost ? <ArrowUpOutlined /> : <ArrowDownOutlined />
}
title={translate(
`interventions.form.actions.${isDetailedCost ? 'simplify' : 'breakdown'}_costs`,
)}
onClick={() => setDetailedCost(!isDetailedCost)}
/>
</Space>
{isDetailedCost ? (
<div>
<Space size="middle">
<Form.Item
label={translate(
'interventions.form.labels.cost_group.labor',
)}
name="labor_cost"
style={{ marginBottom: 0 }}
>
<Input
type="number"
step="0.01"
min={0}
onChange={(e) => {
const labor = Number(e.target.value) || 0;
const supply =
Number(formProps.form.getFieldValue('supply_cost')) ||
0;
formProps.form.setFieldsValue({
total_cost: labor + supply,
});
Comment on lines +108 to +113
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.
}}
/>
</Form.Item>
<Form.Item
label={translate(
'interventions.form.labels.cost_group.supply',
)}
name="supply_cost"
style={{ marginBottom: 0 }}
>
<Input
type="number"
step="0.01"
min={0}
onChange={(e) => {
const labor =
Number(formProps.form.getFieldValue('labor_cost')) || 0;
const supply = Number(e.target.value) || 0;
formProps.form.setFieldsValue({
total_cost: labor + supply,
});
}}
/>
</Form.Item>
</Space>
</div>
) : null}
</div>
</Form.Item>
</Form>
);
Expand Down
Loading