Skip to content

Commit 69cb7dc

Browse files
fix-expiration-datepicker
Updated DatePicker product logic -> Updated the expiration date selector while creating or updating a products to avoid using past dates. Added necessary logic to the BS as well. More info below
2 parents f1bb32c + 417407e commit 69cb7dc

File tree

1 file changed

+14
-1
lines changed
  • inventory-manager/src/components/page-content/segment2-new_product

1 file changed

+14
-1
lines changed

inventory-manager/src/components/page-content/segment2-new_product/ProductForm.tsx

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,20 @@ const ProductForm: React.FC<ProductFormProps> = ({initialValues, mode = "create"
278278
name="expirationDate"
279279
label="Expiration Date"
280280
tooltip="Not necessary. Expiration date of the product"
281-
rules={[{required: false, message: "Please select expiration date"}]}
281+
rules={[
282+
{required: false},
283+
{
284+
validator: (_, value) => {
285+
if (!value) {
286+
return Promise.resolve();
287+
}
288+
if (value < new Date()) {
289+
return Promise.reject(new Error("The date can't be in the past"));
290+
}
291+
return Promise.resolve();
292+
},
293+
},
294+
]}
282295
initialValue={
283296
initialValues?.expirationDate
284297
? dayjs(initialValues.expirationDate)

0 commit comments

Comments
 (0)