/** * @format */ import React, {ReactNode, useMemo, useState} from 'react' import {Box, Heading, Button, Text, Divider, HStack} from '@chakra-ui/react' import MOCK_DATA from '../MOCK_DATA.json' import { ButtonWithIcon, FormComponent } from '../components/UIcomponents' import logo from '../assets/mocks/images/pg_logo.png' import VantageDatePicker from '../components/VantageDatePicker/VantageDatePicker' import {SelectDropdown} from '../components/SelectDropDown/SelectDropdown' import VantageModal from '../components/VantageModal/VantageModal' const initialDropDownOptions = [ {value: '1', name: 'One'}, {value: '2', name: 'Two'}, {value: '3', name: 'Three'}, {value: '4', name: 'Four'} ] import {ModalWindow} from '../components/Modal/Modal' import {unifiedSearchFilterData} from '../assets/mocks/formData' // import { // MedianChartPSF, // MedianChartTransactionPrice // } from '../components/ChartsComponents' import {CheckBoxDrowpdown} from '../components/CheckBoxDropDown/CheckBoxDropDown' import {buildingTypesInitial, TimePeriods} from '../types/types' import {ActionsDropDown} from '../components/ActionDropDown/ActionDropDown' import { ChartWrapper, TimeFilterButtons } from '../components/Charts/ChartElemets' import {ScatterChartComponent} from '../components/Charts/ScatterChart' import { chartData_monthly, chartData_quarterly, chartDate_yearly } from '../assets/mocks/chartData' import {LineChartComponent} from '../components/Charts/LineChart' import {VantageDataTable} from '../components/VantageDataTable' import {VantagePieChart} from '../components/ChartsComponents' const Block = ({heading, children}: {heading: string; children: ReactNode}) => ( <> {heading} {children} ) const KitchenSink = () => { const data = useMemo(() => MOCK_DATA, []) const endDate: Date = new Date() const newStartDate: Date = new Date() newStartDate.setDate(newStartDate.getDate() + 5) const startDate: Date = new Date(newStartDate) const [selectedOption, setSelectedOption] = useState( initialDropDownOptions[0] ) const [isModalOpen1, setIsModalOpen1] = useState(false) const [isModalOpen2, setIsModalOpen2] = useState(false) const [isModalOpen3, setIsModalOpen3] = useState(false) const [isModalOpen4, setIsModalOpen4] = useState(false) const [searchInputValue, setSearchInputValue] = useState('') const [selectedOptions, setSelectedOptions] = useState(buildingTypesInitial) const [optionList, setOptionList] = useState(buildingTypesInitial) const [selectAll, setSelectAll] = useState(true) const handleSelectAll = (e: any) => { setSelectAll(e) if (!selectAll) { setSelectedOptions(buildingTypesInitial) } else { setSelectedOptions([]) } } const search = (e: any) => { const value = e.target.value.toLowerCase() setSearchInputValue(value) if (searchInputValue === '') { setOptionList(buildingTypesInitial) } else { const results = buildingTypesInitial.filter(item => item.name.toLowerCase().includes(value) ) setOptionList(results) } } const handleCheckBox = (e: any) => { const selections = [...selectedOptions] const value = e.target.value const index = selections.findIndex((item: {value: any}) => { if (item.value === value) { return true } return false }) if (index > -1) { selections.splice(index, 1) } else { selections.push(buildingTypesInitial.find(item => item.value === value)) } if (selections.length === buildingTypesInitial.length) { setSelectAll(true) } else { setSelectAll(false) } setSelectedOptions(selections) } // More filters functions const moreFiltersOnSubmit = ( e: React.FormEvent, formData: any ) => { console.log('submitted', e, formData) } const dateChangedFunc = (val: any) => { console.log(val) } const itemAction = (_e: any, index: any) => { const newState = buttonsState.map((item, i) => { if (index === i) { return { ...item, isActive: true } } return { ...item, isActive: false } }) setButtonsState(newState) setCurrentTimePeriod(newState[index].children) if (newState[index].children === TimePeriods.Montly) { setCurrrentChartData(chartData_monthly) } else if (newState[index].children === TimePeriods.Quarterly) { setCurrrentChartData(chartData_quarterly) } else if (newState[index].children === TimePeriods.Yearly) { setCurrrentChartData(chartDate_yearly) } } const logItemAction = () => console.log('menu item action called') const timeFilterButtonProps = [ {children: 'Montly', clickHandler: itemAction, isActive: false}, {children: 'Quarterly', clickHandler: itemAction, isActive: false}, {children: 'Yearly', clickHandler: itemAction, isActive: false} ] const [buttonsState, setButtonsState] = useState(timeFilterButtonProps) const dropdownActions = [ {itemDesc: 'Action 1', itemAcion: logItemAction}, {itemDesc: 'Action 2', itemAcion: logItemAction} ] const [currentChartData, setCurrrentChartData] = useState(chartData_monthly) const [currentTimePeriod, setCurrentTimePeriod] = useState( TimePeriods.Montly ) // PGButton(props -> Chk) > ChakraButton(Chakra - props) > HTMLButton (CSS) return ( <> setIsModalOpen1(false)} isOpen={isModalOpen1} title={'Modal title text'} cancelButtonText={'Close'} cancelButtonVariant={'primary'} mainContentAlignment={'center'} > Some long lorem ipsum yellow sun setIsModalOpen2(false)} isOpen={isModalOpen2} cancelButtonText={'Close without applying'} mainContentAlignment={'flex-start'} footerContentAlignment={'center'} hasPrimarybutton primaryButtonText={'Appply'} bgColor={'grey.50'} > Your changes will be lost. Apply changes before closing? setIsModalOpen3(false)} isOpen={isModalOpen3} title={'Modal title text'} cancelButtonText={'Clear all'} mainContentAlignment={'center'} hasPrimarybutton primaryButtonText={'Apply'} spreadButtons > Sonar sad - duplicate text smash setIsModalOpen4(false)} isOpen={isModalOpen4} title={'Modal title text'} mainContentAlignment={'center'} > Removing duplicate text since Sonar isn't happy setSelectedOption(initialDropDownOptions[index]) } /> Heading 18 Heading 16 Heading 12 This is a Bold text component. This is a plain text component. } iconPosition="left" clickHandler={() => { console.log('button with Left Icon clicked') }} > Button Text } iconPosition="right" clickHandler={() => { console.log('button with Left Icon clicked') }} > Button Text } iconPosition="left" clickHandler={() => { console.log('button with Left Icon clicked') }} > Right Icon Button With loading Date Picker with Drop Down (Start Date) Date Picker with Button (End Date) Simple Date Picker {/* Unified Search - Search Result - FEATURE - More Filter */} <> {[0, 1].map((obj: number) => ( {obj === 0 ? 'Transaction Price' : 'Price PSF'} {/* {obj === 0 && } {obj === 1 && } */} ))} ) } export default KitchenSink