Skip to content
This repository has been archived by the owner on Feb 22, 2023. It is now read-only.

Commit

Permalink
Merge pull request #1426 from UniverseXYZ/ivostoynovski/sc-2316
Browse files Browse the repository at this point in the history
display datepickers in one column on mobile
  • Loading branch information
taskudis authored Mar 16, 2022
2 parents 5ab1d6a + f6b8653 commit c4d6709
Showing 1 changed file with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
import { useState, useEffect } from 'react';
import { FormikProps } from 'formik';
import { default as dayjs } from 'dayjs';
import { default as isSameOrAfter } from 'dayjs/plugin/isSameOrAfter'
import { default as isSameOrAfter } from 'dayjs/plugin/isSameOrAfter';

import { useMarketplaceSellData } from '../../../../hooks';
import { SellAmountType, SellMethod } from '../../../../enums';
Expand All @@ -32,28 +32,32 @@ export const SettingsTabFixedListing = () => {
const [minEndDate, setMinEndDate] = useState(dayjs().add(1, 'day').toDate());
const { form, sellMethod, amountType } = useMarketplaceSellData() as IMarketplaceSellContextDataOverride;

const {values: { startDate, endDate }} = form;
const {
values: { startDate, endDate },
} = form;

useEffect(() => {
// set the end date + 1 day and set the minimum end date
const _endDate = dayjs(startDate || dayjs()).add(1, 'day').toDate();
const _endDate = dayjs(startDate || dayjs())
.add(1, 'day')
.toDate();
setMinEndDate(_endDate);

const isStartAfterEnd = dayjs(startDate).isSameOrAfter(dayjs(endDate));

if(isStartAfterEnd) {
if (isStartAfterEnd) {
// if the user sets the start date to be after the end date - set the end date + 1 day
form.setFieldValue('endDate', _endDate)
form.setFieldValue('endDate', _endDate);
}
}, [startDate, endDate])
}, [startDate, endDate]);

if (sellMethod !== SellMethod.FIXED) {
return null;
}

return (
<>
{ amountType === SellAmountType.BUNDLE && (<BundleForm />) }
{amountType === SellAmountType.BUNDLE && <BundleForm />}
<Flex sx={styles.settingsItem}>
<Box>
<Heading as={'h5'}>Price*</Heading>
Expand Down Expand Up @@ -84,7 +88,7 @@ export const SettingsTabFixedListing = () => {
<Text>Your listing will be active during the time period you set.</Text>
</Box>
<Flex mt={'20px'} w={'100% !important'}>
<SimpleGrid columns={2} spacingX={'20px'}>
<SimpleGrid columns={{ sm: 1, md: 2 }} spacingX={'20px'}>
<FormControl>
<FormLabel>Start date</FormLabel>
<DateTimePicker
Expand Down

0 comments on commit c4d6709

Please sign in to comment.