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

Set the user's registration year to the earliest year available in the calendar #1611

Open
wants to merge 1 commit into
base: stable
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 6 additions & 1 deletion src/components/calendar/calendar-header-nav.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Link } from 'react-router';
import parse from 'date-fns/parse';
import format from 'date-fns/format';

import { MIN_DATE, MAX_DATE } from '../../utils/calendar-utils';
import { MAX_DATE } from '../../utils/calendar-utils';

import styles from './calendar.module.scss';

Expand All @@ -25,8 +25,13 @@ function CalendarHeaderNav(props) {
currentDate: currentDateString,
nextDate: nextDateString,
previousDate: previousDateString,
createdAt,
} = props;

const createdAtDate = new Date(Number(createdAt));
const minYear = createdAtDate.getFullYear();
const MIN_DATE = new Date(minYear, 0, 1);

const currentDate = parseDateString(currentDateString);
const nextDate = nextDateString ? parseDateString(nextDateString) : null;
const previousDate = previousDateString ? parseDateString(previousDateString) : null;
Expand Down
1 change: 1 addition & 0 deletions src/components/calendar/calendar-year.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ function CalendarYear(props) {
currentDate={`${yearAsInt}-01-01`}
previousDate={`${yearAsInt - 1}-01-01`}
nextDate={`${yearAsInt + 1}-01-01`}
createdAt={user.createdAt}
/>

{calendarDaysMap ? (
Expand Down
3 changes: 1 addition & 2 deletions src/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import CalendarMonth from './components/calendar/calendar-month';
import CalendarDate from './components/calendar/calendar-date';
import SignupByInvitation from './components/signup-by-invitation';
import { settingsRoute } from './components/settings/routes';
import { CALENDAR_START_YEAR } from './utils/calendar-utils';

Sentry.init({
dsn: CONFIG.sentry.publicDSN,
Expand Down Expand Up @@ -428,7 +427,7 @@ function isMemoriesPath({ params: { userName, from } }) {

const isValidCalendarYear = (year) => {
const yearAsInt = parseInt(year, 10);
return yearAsInt >= CALENDAR_START_YEAR && yearAsInt <= thisYear;
return yearAsInt <= thisYear;
};

const isValidMonth = (month) => {
Expand Down
2 changes: 0 additions & 2 deletions src/utils/calendar-utils.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
const now = new Date();
export const CALENDAR_START_YEAR = 2000;
export const MIN_DATE = new Date(CALENDAR_START_YEAR, 0, 1);
export const MAX_DATE = new Date(now.getFullYear(), 11, 31);

export const monthNames = [
Expand Down