Update product expiry date handling and display logic

Refactor client/src/pages/DlcPage.tsx to rename `dlcDate` to `expiryDate` in the `InsertDlcProduct` type and update its usage throughout the component for consistency and clarity.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: a3de0820-9397-41b2-b000-7931ee9c29de
Replit-Commit-Checkpoint-Type: full_checkpoint
Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/1957c339-2757-4d1f-8e92-e9f71a1ce58e/a3de0820-9397-41b2-b000-7931ee9c29de/vqNg9rh
This commit is contained in:
michaelschal committed 2025-08-15 21:13:36 +00:00
1 parent ff414a16c7
commit 6b2c5af4f1
3 files changed
+207 -5

No files matched your search

+5 -5
View File
@@ -229,7 +229,7 @@ export default function DlcPage() {
const dlcData: InsertDlcProduct = {
...data,
dlcDate,
expiryDate: dlcDate,
quantity: 1, // Valeur par défaut
unit: "unité", // Valeur par défaut
location: "Magasin", // Valeur par défaut
@@ -249,7 +249,7 @@ export default function DlcPage() {
form.reset({
productName: product.productName,
gencode: product.gencode || "",
dlcDate: product.dlcDate ? format(new Date(product.dlcDate), "yyyy-MM-dd") : "",
dlcDate: product.expiryDate ? format(new Date(product.expiryDate), "yyyy-MM-dd") : "",
dateType: product.dateType as "dlc" | "ddm" | "dluo",
supplierId: product.supplierId,
status: product.status as "en_cours" | "expires_soon" | "expires" | "valides",
@@ -278,7 +278,7 @@ export default function DlcPage() {
// Fonction pour déterminer si un produit doit afficher le bouton de validation
const shouldShowValidateButton = (product: DlcProductWithRelations) => {
const today = new Date();
const expiry = new Date(product.dlcDate || new Date());
const expiry = new Date(product.expiryDate || new Date());
const daysUntilExpiry = Math.ceil((expiry.getTime() - today.getTime()) / (1000 * 60 * 60 * 24));
// Afficher le bouton si le produit expire dans 15 jours ou moins, ou est déjà expiré
@@ -779,10 +779,10 @@ export default function DlcPage() {
</Badge>
</TableCell>
<TableCell>
{product.dlcDate ? format(new Date(product.dlcDate), "dd/MM/yyyy", { locale: fr }) : 'Date non définie'}
{product.expiryDate ? format(new Date(product.expiryDate), "dd/MM/yyyy", { locale: fr }) : 'Date non définie'}
</TableCell>
<TableCell>{product.supplier?.name || 'Non défini'}</TableCell>
<TableCell>{getStatusBadge(product.status, product.dlcDate)}</TableCell>
<TableCell>{getStatusBadge(product.status, product.expiryDate)}</TableCell>
<TableCell>
<div className="flex space-x-2">
<Button