Skip to content

Commit

Permalink
fix(STK-233): update the logic on order creation flow for submitted d…
Browse files Browse the repository at this point in the history
…ates
  • Loading branch information
ElRodrigote committed Apr 5, 2024
1 parent 43eae1c commit f87f539
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions packages/app/components/stackbox/Stackbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,11 @@ interface SelectTokenButtonProps {
onAnimationEnd: AnimationEventHandler<HTMLElement>;
}

const START_TIME_MINUTES_OFFSET = 10;
const getDateNowPlus10Mins = () =>
new Date().setMinutes(new Date().getMinutes() + START_TIME_MINUTES_OFFSET);
const PAST_TIME_MINUTES_OFFSET = 10;
const getDatePlus10Mins = (oldDate: Date) =>
new Date(oldDate).setMinutes(
new Date(oldDate).getMinutes() + PAST_TIME_MINUTES_OFFSET
);

const frequencyOptions = [
{ option: FREQUENCY_OPTIONS.hour, name: "Hour" },
Expand Down Expand Up @@ -199,7 +201,9 @@ export const Stackbox = () => {
const startDate = startDateTime.getTime();
const endDate = endDateTime.getTime();
const isEndTimeBeforeStartTime = endDate <= startDate;
const isStartTimeInThePast = startDate <= Date.now();
const isStartTimeInThePast =
startDate <= Date.now() &&
new Date(startDate).getMinutes() <= new Date().getMinutes();
const isTokenAmountZero = tokenAmount === "0";

setShowPastEndDateError(isEndTimeBeforeStartTime);
Expand Down Expand Up @@ -585,9 +589,15 @@ export const Stackbox = () => {
amount={tokenAmount}
frequency={frequency}
startTime={
isPastStartDate ? new Date(getDateNowPlus10Mins()) : startDateTime
isPastStartDate
? new Date(getDatePlus10Mins(startDateTime))
: startDateTime
}
endTime={
isPastStartDate
? new Date(getDatePlus10Mins(endDateTime))
: endDateTime
}
endTime={endDateTime}
isOpen={isModalOpen(ModalId.CONFIRM_STACK)}
closeAction={() => {
closeModal(ModalId.CONFIRM_STACK);
Expand Down

0 comments on commit f87f539

Please sign in to comment.