Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Forms refactor
Browse files Browse the repository at this point in the history
- Use dayjs for cleaner code
SchrodingersGat committed Jan 11, 2025

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 0004192 commit c512e20
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions src/frontend/src/forms/StockForms.tsx
Original file line number Diff line number Diff line change
@@ -13,6 +13,7 @@ import {
import { useQuery, useSuspenseQuery } from '@tanstack/react-query';
import { Suspense, useEffect, useMemo, useState } from 'react';

import dayjs from 'dayjs';
import { api } from '../App';
import { ActionButton } from '../components/buttons/ActionButton';
import RemoveRowButton from '../components/buttons/RemoveRowButton';
@@ -114,11 +115,7 @@ export function useStockFields({

if (expiry_days && expiry_days > 0) {
// Adjust the expiry date based on the part default expiry
setExpiryDate(
new Date(
new Date().getTime() + expiry_days * 24 * 60 * 60 * 1000
).toISOString()
);
setExpiryDate(dayjs().add(expiry_days, 'days').toISOString());
}
}
},

0 comments on commit c512e20

Please sign in to comment.