Skip to content

Commit

Permalink
fix(config-ui): missed default value in sync frequency (#6449)
Browse files Browse the repository at this point in the history
  • Loading branch information
mintsweet committed Nov 13, 2023
1 parent 5057cef commit ba51389
Showing 1 changed file with 14 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*
*/

import { useState, useMemo } from 'react';
import { useState, useEffect, useMemo } from 'react';
import dayjs from 'dayjs';
import { Tag, Checkbox, FormGroup, InputGroup, Radio, RadioGroup } from '@blueprintjs/core';
import { TimePrecision } from '@blueprintjs/datetime';
Expand Down Expand Up @@ -53,18 +53,26 @@ export const SyncPolicy = ({
}: Props) => {
const [selectedValue, setSelectedValue] = useState('Daily');

const [timezone, quickTimeOpts, cronOpts] = useMemo(() => {
const cronOpts = getCronOptions();

useEffect(() => {
if (isManual) {
setSelectedValue('Manual');
} else {
const opt = cronOpts.find((it) => it.value === cronConfig);
setSelectedValue(opt ? opt.label : 'Custom');
}
}, []);

const [timezone, quickTimeOpts] = useMemo(() => {
const timezone = dayjs().format('ZZ').replace('00', '');
const quickTimeOpts = [
{ label: 'Last 6 months', date: dayjs().subtract(6, 'month').toDate() },
{ label: 'Last 90 days', date: dayjs().subtract(90, 'day').toDate() },
{ label: 'Last 30 days', date: dayjs().subtract(30, 'day').toDate() },
{ label: 'Last Year', date: dayjs().subtract(1, 'year').toDate() },
];

const cronOpts = getCronOptions();

return [timezone, quickTimeOpts, cronOpts];
return [timezone, quickTimeOpts];
}, []);

const cron = useMemo(() => getCron(isManual, cronConfig), [isManual, cronConfig]);
Expand Down

0 comments on commit ba51389

Please sign in to comment.