Skip to content

Commit

Permalink
fixed period selector based on #1
Browse files Browse the repository at this point in the history
  • Loading branch information
jahidem committed Dec 26, 2022
1 parent f545d07 commit b173886
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 38 deletions.
16 changes: 8 additions & 8 deletions core/homeWindow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ export default class HomeWindow {
},
});
if (HomeWindow.thisWindow != null) {
HomeWindow.thisWindow.loadURL(
'file://' + __dirname + '/../index.html#/home'
);
// HomeWindow.thisWindow.loadURL("http://localhost:3000/#/home");
// HomeWindow.thisWindow.loadURL(
// 'file://' + __dirname + '/../index.html#/home'
// );
HomeWindow.thisWindow.loadURL("http://localhost:3000/#/home");

HomeWindow.thisWindow.on("closed", HomeWindow.onClose);
}
Expand Down Expand Up @@ -86,8 +86,8 @@ export default class HomeWindow {
});

if (HomeWindow.logWindow != null) {
HomeWindow.logWindow.loadURL('file://' + __dirname + '/../index.html#/log');
// HomeWindow.logWindow.loadURL("http://localhost:3000/#/log");
// HomeWindow.logWindow.loadURL('file://' + __dirname + '/../index.html#/log');
HomeWindow.logWindow.loadURL("http://localhost:3000/#/log");
}
}

Expand Down Expand Up @@ -137,8 +137,8 @@ export default class HomeWindow {
];
const menu = Menu.buildFromTemplate(template);
Menu.setApplicationMenu(menu);
HomeWindow.potmWindow.loadURL('file://' + __dirname + '/../index.html#/potm');
// HomeWindow.potmWindow.loadURL("http://localhost:3000/#/potm");
// HomeWindow.potmWindow.loadURL('file://' + __dirname + '/../index.html#/potm');
HomeWindow.potmWindow.loadURL("http://localhost:3000/#/potm");
// HomeWindow.potmWindow.on("closed", HomeWindow.closePotmWindow);
}
}
Expand Down
Binary file modified core/prisma/sqlite.db
Binary file not shown.
69 changes: 39 additions & 30 deletions src/screen/components/Setting.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@ import {
Checkbox,
CheckboxGroup,
Stack,
} from '@chakra-ui/react';
import { ChevronDownIcon } from '@chakra-ui/icons';
import { useEffect, useState } from 'react';
import { useAppSelector, useAppDispatch } from '../../redux/hook';
import { fetchAllContest } from '../../redux/slice/cfapi-slice';
import { Loading } from '../../common/types';
} from "@chakra-ui/react";
import { ChevronDownIcon } from "@chakra-ui/icons";
import { useEffect, useState } from "react";
import { useAppSelector, useAppDispatch } from "../../redux/hook";
import { fetchAllContest } from "../../redux/slice/cfapi-slice";
import { Loading } from "../../common/types";
import {
setEpochStart,
setEpochEnd,
updateAllowDiv,
} from '../../redux/slice/contest-slice';
} from "../../redux/slice/contest-slice";

interface ChooserState {
month: number;
Expand All @@ -39,8 +39,8 @@ const Setting = () => {
const [start, setStart] = useState<ChooserState>(initials);
const [end, setEnd] = useState<ChooserState>({ ...initials, month: 12 });
const [checkedDiv, setCheckedDiv] = useState<(string | number)[]>([
'Div. 2',
'Div. 3',
"Div. 2",
"Div. 3",
]);
const [updateList, setUpdateList] = useState(0);

Expand All @@ -51,28 +51,37 @@ const Setting = () => {
update();
}, [updateList]);

const getEpo = (date: ChooserState) => {
if (date.month && date.year) {
let dateString = '';
dateString += date.year + '-';
if (date.month < 10) dateString += '0' + date.month;
else dateString += date.month;
dateString += '-01';
date.epoch = new Date(dateString).getTime();
return date;
}
return date;
const getEpo = (Nowdate: ChooserState, type: string): number => {
const date = {
...Nowdate,
month:
type != "ENDING"
? Nowdate.month
: Nowdate.month != 12
? Nowdate.month + 1
: 1,
year:
type != "ENDING" || Nowdate.month != 12
? Nowdate.year
: Nowdate.year + 1,
};

let dateString = "";
dateString += date.year + "-";
if (date.month < 10) dateString += "0" + date.month;
else dateString += date.month;
dateString += "-01";
date.epoch = new Date(dateString).getTime();
return date.epoch;
};
useEffect(() => {
const date = getEpo(start);
setStart(date);
dispatch(setEpochStart(date.epoch));
const epoch = getEpo(start, "STARTING");
dispatch(setEpochStart(epoch));
}, [start]);

useEffect(() => {
const date = getEpo(end);
setEnd(date);
dispatch(setEpochEnd(date.epoch));
const epoch = getEpo(end, "ENDING");
dispatch(setEpochEnd(epoch));
}, [end]);

useEffect(() => {
Expand All @@ -97,7 +106,7 @@ const Setting = () => {
alignItems="center"
>
<Text fontSize="1.4rem" fontWeight="semibold">
From:{' '}
From:
</Text>
<Select
width="6rem"
Expand Down Expand Up @@ -157,7 +166,7 @@ const Setting = () => {
alignItems="center"
>
<Text fontSize="1.4rem" fontWeight="semibold">
Till:{' '}
To:
</Text>
<Select
width="6rem"
Expand Down Expand Up @@ -223,13 +232,13 @@ const Setting = () => {

<Flex mt="0.8rem" ml="1rem">
<Text fontSize="1.3rem" mr="1.4rem" fontWeight="semibold">
Division:{' '}
Division:{" "}
</Text>
<CheckboxGroup
defaultValue={checkedDiv}
onChange={(value) => setCheckedDiv(value)}
>
<Stack spacing={[3]} direction={['row']}>
<Stack spacing={[3]} direction={["row"]}>
<Checkbox colorScheme="teal" size="lg" value="Div. 1">
Div. 1
</Checkbox>
Expand Down

0 comments on commit b173886

Please sign in to comment.