diff --git a/web/src/pages/flow/qweather-form/index.tsx b/web/src/pages/flow/qweather-form/index.tsx index b86b0fc4..fbbc51f9 100644 --- a/web/src/pages/flow/qweather-form/index.tsx +++ b/web/src/pages/flow/qweather-form/index.tsx @@ -1,6 +1,6 @@ import { useTranslate } from '@/hooks/common-hooks'; import { Form, Input, Select } from 'antd'; -import { useMemo } from 'react'; +import { useCallback, useMemo } from 'react'; import { QWeatherLangOptions, QWeatherTimePeriodOptions, @@ -32,12 +32,19 @@ const QWeatherForm = ({ onValuesChange, form }: IOperatorForm) => { })); }, [t]); - const qWeatherTimePeriodOptions = useMemo(() => { - return QWeatherTimePeriodOptions.map((x) => ({ - value: x, - label: t(`qWeatherTimePeriodOptions.${x}`), - })); - }, [t]); + const getQWeatherTimePeriodOptions = useCallback( + (userType: string) => { + let options = QWeatherTimePeriodOptions; + if (userType === 'free') { + options = options.slice(0, 3); + } + return options.map((x) => ({ + value: x, + label: t(`qWeatherTimePeriodOptions.${x}`), + })); + }, + [t], + ); return (