Skip to content

Commit

Permalink
fix: migrated sidelist to tsx (#13)
Browse files Browse the repository at this point in the history
* fix: migrated sidelist to tsx

* fix: circle-ci error

* fix: sidelist types
  • Loading branch information
aizad-deriv committed Jan 11, 2023
1 parent 42ff987 commit 7e5b83c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { localize } from '@deriv/translations';
import { daysFromTodayTo, epochToMoment, toMoment } from '@deriv/shared';
import { connect } from 'Stores/connect';
import CompositeCalendarMobile from './composite-calendar-mobile.jsx';
import SideList from './side-list.jsx';
import SideList from './side-list';
import CalendarIcon from './calendar-icon';

const TwoMonthPicker = Loadable({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,28 @@
import PropTypes from 'prop-types';
import React from 'react';
import { toMoment } from '@deriv/shared';
import ListItem from './list-item.tsx';

const isActive = (from, to, flag) => {
type TItem = {
value: string;
label: string;
onClick: () => void;
duration: number;
};

type TSideList = {
from: number;
items: Array<TItem>;
to: number;
};

const isActive = (from: number, to: number, flag: number) => {
if (flag === 0) {
return toMoment().endOf('day').unix() === to && from === null;
}
return Math.ceil(to / 86400) - Math.ceil(from / 86400) === flag;
};

const SideList = ({ items, from, to }) => (
const SideList = ({ items, from, to }: TSideList) => (
<ul className='composite-calendar__prepopulated-list'>
{items.map(item => {
const { duration, ...rest_of_props } = item;
Expand All @@ -20,10 +32,4 @@ const SideList = ({ items, from, to }) => (
</ul>
);

SideList.propTypes = {
from: PropTypes.number,
items: PropTypes.array,
to: PropTypes.number,
};

export default SideList;

0 comments on commit 7e5b83c

Please sign in to comment.