From ff8be9edfe3ed589a10bcbf153e2e2b69b06b67d Mon Sep 17 00:00:00 2001 From: GunSik Choi Date: Tue, 6 Feb 2024 18:58:27 +0900 Subject: [PATCH] =?UTF-8?q?#6=20embed=20query=20option=20(=EB=85=84/?= =?UTF-8?q?=EC=9B=94/=EC=9D=BC=20=EC=A0=9C=ED=95=9C)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/DateRangeSwitchableInput.jsx | 40 ++++++++++++++++--- 1 file changed, 35 insertions(+), 5 deletions(-) diff --git a/client/app/components/DateRangeSwitchableInput.jsx b/client/app/components/DateRangeSwitchableInput.jsx index 97b9ff4a4b..265bd9338e 100644 --- a/client/app/components/DateRangeSwitchableInput.jsx +++ b/client/app/components/DateRangeSwitchableInput.jsx @@ -1,4 +1,4 @@ -import { isArray } from "lodash"; +import { has, isArray } from "lodash"; import React, { useState } from "react"; import PropTypes from "prop-types"; import { Moment } from "@/components/proptypes"; @@ -6,6 +6,8 @@ import DatePicker from "antd/lib/date-picker"; import Select from "antd/lib/select"; import "antd/lib/date-picker/style/css"; import "antd/lib/select/style/css"; +import location from "@/services/location"; +import qs from "query-string"; const { RangePicker } = DatePicker; const { Option } = Select; @@ -22,19 +24,47 @@ const DateRangeSwitchableInput = React.forwardRef( additionalAttributes.value = value; } - const [pickerType, setPickerType] = useState('day'); + + //const full_options = ["day", "week", "month", "quarter", "year"]; + const full_options = ["day", "week", "month", "year"]; + const optionLabels = { + day: "일", + week: "주", + month: "월", + quarter: "분기", + year: "년", + }; + + //const datetypeExist = has(location.search, "datetype"); + //console.log('********* datetype = ' + datetypeExist) + + const currentUrlParams = qs.parse(window.location.search.substring(1)); + //console.log('********* params = ' + qs.stringify(currentUrlParams)); + + const datetype = currentUrlParams['p_datetype']; + //console.log('********* datetype = ' + datetype) + + let options; + let default_option; + if (datetype && full_options.includes(datetype)) { + options = [datetype]; + default_option = datetype; + } else { + options = [...full_options]; + default_option = 'day' + } + + const [pickerType, setPickerType] = useState(default_option); const handlePickerTypeChange = (newPickerType) => { setPickerType(newPickerType); }; - const options = ["day", "week", "month", "quarter", "year"]; - return (