2023-07-15 15:37:25 -04:00
|
|
|
import React from 'react';
|
2022-02-12 13:02:31 -05:00
|
|
|
import {Calendar} from './Calendar';
|
2023-07-15 15:37:25 -04:00
|
|
|
import {FrenchMonth, frEndJD, frStartJD, frSupportedYear, jdnFrench} from '@common/french';
|
2023-07-15 16:10:46 -04:00
|
|
|
import {JulianMonth} from '@common/gregorian';
|
2022-02-27 03:13:42 -05:00
|
|
|
import {TimeOfDay} from './TimeOfDay';
|
2023-07-15 15:37:25 -04:00
|
|
|
import {GregorianJumper} from '@common/dateJump';
|
2023-07-15 16:10:46 -04:00
|
|
|
import MonthBasedApp from '@common/ui/MonthBasedApp';
|
2023-07-15 23:09:42 -04:00
|
|
|
import Export from './Export';
|
2022-02-12 09:44:58 -05:00
|
|
|
|
2023-07-15 16:10:46 -04:00
|
|
|
export default class App extends MonthBasedApp<number, FrenchMonth> {
|
|
|
|
override parseYearMonth(year: string, month: string) {
|
|
|
|
if (!frSupportedYear(+year) || +month < 1 || +month > 13)
|
|
|
|
return null;
|
|
|
|
return {year: +year, month: +month as JulianMonth};
|
2022-02-12 16:25:44 -05:00
|
|
|
}
|
|
|
|
|
2023-07-15 16:10:46 -04:00
|
|
|
override defaultSelector(todayJDN: number) {
|
|
|
|
const {year, month} = jdnFrench(todayJDN);
|
|
|
|
return {year, month};
|
2022-02-12 16:25:44 -05:00
|
|
|
}
|
|
|
|
|
2023-07-15 15:37:25 -04:00
|
|
|
goToJDN = (jdn: number) => {
|
|
|
|
const {year, month} = jdnFrench(Math.min(Math.max(frStartJD, jdn), frEndJD));
|
2023-07-15 16:10:46 -04:00
|
|
|
this.setState({selector: {year, month}});
|
2023-07-15 15:37:25 -04:00
|
|
|
};
|
|
|
|
|
2022-02-12 16:25:44 -05:00
|
|
|
render() {
|
2023-07-15 16:10:46 -04:00
|
|
|
const {selector: {year, month}, todayJDN} = this.state;
|
2022-02-14 01:48:09 -05:00
|
|
|
return <>
|
|
|
|
<Calendar
|
2023-07-15 16:10:46 -04:00
|
|
|
year={year} month={month} todayJDN={todayJDN}
|
|
|
|
onSwitch={(year, month) => this.setState({selector: {year, month}})}/>
|
2022-02-14 01:48:09 -05:00
|
|
|
|
2022-02-27 03:13:42 -05:00
|
|
|
<TimeOfDay onDateChange={this.onDateChange}/>
|
|
|
|
|
2022-02-14 01:48:09 -05:00
|
|
|
<div className="navigate">
|
|
|
|
<h4>Go to a date</h4>
|
2023-07-15 23:09:42 -04:00
|
|
|
<GregorianJumper minJDN={frStartJD} maxJDN={frEndJD} initialJDN={todayJDN}
|
2023-07-15 15:37:25 -04:00
|
|
|
onJump={this.goToJDN}/>
|
2022-02-14 01:48:09 -05:00
|
|
|
</div>
|
2023-07-15 23:09:42 -04:00
|
|
|
|
|
|
|
<div className="download">
|
|
|
|
<h4>Export calendar</h4>
|
|
|
|
<Export minJDN={frStartJD} maxJDN={frEndJD} initialJDN={todayJDN}/>
|
|
|
|
</div>
|
2022-02-14 01:48:09 -05:00
|
|
|
</>;
|
2022-02-12 16:25:44 -05:00
|
|
|
}
|
2022-02-12 09:44:58 -05:00
|
|
|
}
|