Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Farzin/70813/Fix date picker month issue for non english languages #6027

Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
8408f06
fix(components): :bug: fix date picker month issue for non english la…
Jul 24, 2022
ca19820
refactor(components): :recycle: refactor `calendar-months` component …
Jul 25, 2022
8fc7312
Merge branch 'master' into farzin/70813/fix_date_picker_month_issue_f…
Jul 25, 2022
01b1a7f
Merge branch 'master' into farzin/70813/fix_date_picker_month_issue_f…
Jul 25, 2022
44d314c
fix(components): :globe_with_meridians: add localization support for …
Jul 26, 2022
27b0452
Merge branch 'master' into farzin/70813/fix_date_picker_month_issue_f…
Jul 26, 2022
6355f7f
Merge branch 'master' into farzin/70813/fix_date_picker_month_issue_f…
Jul 27, 2022
cdd7c33
Merge branch 'master' into farzin/70813/fix_date_picker_month_issue_f…
Jul 28, 2022
f71133c
refactor(components): :fire: remove redundant `month_headers`
Jul 28, 2022
7561aac
chore(components): :heavy_minus_sign: remove redundant `@deriv/transl…
Jul 28, 2022
7ad16df
Merge branch 'master' into farzin/70813/fix_date_picker_month_issue_f…
Jul 28, 2022
e795ce3
Merge branch 'master' into farzin/70813/fix_date_picker_month_issue_f…
Aug 2, 2022
4d80663
Merge branch 'master' into farzin/70813/fix_date_picker_month_issue_f…
Aug 3, 2022
6961298
Merge branch 'master' into farzin/70813/fix_date_picker_month_issue_f…
Aug 4, 2022
6542f35
Merge branch 'master' into farzin/70813/fix_date_picker_month_issue_f…
Aug 5, 2022
f4cf145
Merge branch 'master' into farzin/70813/fix_date_picker_month_issue_f…
Aug 8, 2022
11c85af
Trigger Build
Aug 9, 2022
972d189
Merge branch 'master' into farzin/70813/fix_date_picker_month_issue_f…
Aug 10, 2022
b5958bb
fix(cashier): :memo: resolve PR comments
Aug 10, 2022
08bb64d
Merge branch 'master' into farzin/70813/fix_date_picker_month_issue_f…
Aug 10, 2022
caf9067
Merge branch 'master' into farzin/70813/fix_date_picker_month_issue_f…
Aug 11, 2022
d46910b
Merge branch 'master' into farzin/70813/fix_date_picker_month_issue_f…
Aug 11, 2022
1fc7e89
Merge branch 'master' into farzin/70813/fix_date_picker_month_issue_f…
Aug 15, 2022
7af2506
Merge branch 'master' into farzin/70813/fix_date_picker_month_issue_f…
Aug 17, 2022
2d750b5
Merge branch 'master' into farzin/70813/fix_date_picker_month_issue_f…
Aug 18, 2022
993a240
Merge branch 'master' into farzin/70813/fix_date_picker_month_issue_f…
Aug 18, 2022
aec4260
Merge branch 'master' into farzin/70813/fix_date_picker_month_issue_f…
Aug 21, 2022
c946900
Merge branch 'master' into farzin/70813/fix_date_picker_month_issue_f…
Aug 23, 2022
b52edca
Merge branch 'master' into farzin/70813/fix_date_picker_month_issue_f…
Aug 25, 2022
b6cedca
Merge branch 'master' into farzin/70813/fix_date_picker_month_issue_f…
Aug 29, 2022
2cdd5ef
Merge branch 'master' into farzin/70813/fix_date_picker_month_issue_f…
Aug 29, 2022
56e8807
Merge branch 'master' into farzin/70813/fix_date_picker_month_issue_f…
Aug 29, 2022
457912c
Merge branch 'master' into farzin/70813/fix_date_picker_month_issue_f…
Aug 30, 2022
50f2777
Merge branch 'master' into farzin/70813/fix_date_picker_month_issue_f…
Sep 6, 2022
59180d2
Merge branch 'master' into farzin/70813/fix_date_picker_month_issue_f…
Sep 6, 2022
52a91a7
Merge branch 'master' into farzin/70813/fix_date_picker_month_issue_f…
Sep 6, 2022
b68e6a7
Merge branch 'master' into farzin/70813/fix_date_picker_month_issue_f…
Sep 8, 2022
0553e5d
Merge branch 'master' into farzin/70813/fix_date_picker_month_issue_f…
Sep 11, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import PropTypes from 'prop-types';
import React from 'react';
import { addMonths, addYears, subMonths, subYears, toMoment } from '@deriv/shared';
import Button from './calendar-button.jsx';
import { month_headers, getCentury, getDecade } from './helpers';
import { getCentury, getDecade } from './helpers';

const Header = ({
calendar_date,
Expand Down Expand Up @@ -77,7 +77,7 @@ const Header = ({
<Button
className='dc-calendar__btn--select'
is_hidden={!is_date_view}
label={month_headers[moment_date.format('MMM')]}
label={moment_date.format('MMM')}
onClick={() => (disable_month_selector ? undefined : switchView('month'))}
/>
)}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,5 @@
import { toMoment } from '@deriv/shared';

// TODO: localize
export const month_headers = {
Jan: 'Jan',
Feb: 'Feb',
Mar: 'Mar',
Apr: 'Apr',
May: 'May',
Jun: 'Jun',
Jul: 'Jul',
Aug: 'Aug',
Sep: 'Sep',
Oct: 'Oct',
Nov: 'Nov',
Dec: 'Dec',
};

export const week_headers = {
Monday: 'Monday',
Tuesday: 'Tuesday',
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export { month_headers, week_headers, week_headers_abbr, getDaysOfTheWeek, getDecade, getCentury } from './constants';
export { week_headers, week_headers_abbr, getDaysOfTheWeek, getDecade, getCentury } from './constants';
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,32 @@ import classNames from 'classnames';
import React from 'react';
import { toMoment } from '@deriv/shared';
import { CommonPropTypes } from './types';
import { month_headers } from '../helpers';

const Months = ({ calendar_date, isPeriodDisabled, selected_date, updateSelected }) => {
const moment_date = toMoment(calendar_date);
const moment_selected_date = toMoment(selected_date);
const is_same_year = moment_selected_date.isSame(moment_date, 'year');
const selected_month_number = Number(moment_selected_date.clone().format('M'));
const months_numbers = [...Array(12).keys()];

return (
<div className='dc-calendar__body dc-calendar__body--month'>
{Object.keys(month_headers).map((month, idx) => {
const is_active =
month === moment_selected_date.clone().format('MMM') &&
moment_selected_date.isSame(moment_date, 'year');
const is_disabled = isPeriodDisabled(moment_date.clone().month(month), 'month');
{months_numbers.map(month_number => {
const month = moment_date.clone().month(month_number);
const is_active = is_same_year && selected_month_number === month_number + 1;
const is_disabled = isPeriodDisabled(month, 'month');

return (
<span
key={idx}
key={month_number}
className={classNames('dc-calendar__cell', {
'dc-calendar__cell--active': is_active,
'dc-calendar__cell--disabled': is_disabled,
})}
onClick={is_disabled ? undefined : e => updateSelected(e, 'month')}
data-month={month}
data-month={month_number}
>
{month_headers[month]}
{month.format('MMM')}
</span>
);
})}
Expand Down