diff --git a/src/features/error-boundary/pages/BlokedPage.tsx b/src/features/error-boundary/pages/BlokedPage.tsx index 595ea0910..acae3bab5 100644 --- a/src/features/error-boundary/pages/BlokedPage.tsx +++ b/src/features/error-boundary/pages/BlokedPage.tsx @@ -14,7 +14,7 @@ export const BlokedPage = () => { diff --git a/src/features/error-boundary/pages/NoConectionPage.tsx b/src/features/error-boundary/pages/NoConectionPage.tsx index fcf500527..777ef007f 100644 --- a/src/features/error-boundary/pages/NoConectionPage.tsx +++ b/src/features/error-boundary/pages/NoConectionPage.tsx @@ -14,7 +14,7 @@ export const NoConectionPage = () => { diff --git a/src/features/filter/components/filter-cover/filter-cover.tsx b/src/features/filter/components/filter-cover/filter-cover.tsx index 02ca1f0ca..3055e2f72 100644 --- a/src/features/filter/components/filter-cover/filter-cover.tsx +++ b/src/features/filter/components/filter-cover/filter-cover.tsx @@ -1,35 +1,68 @@ -import { useEffect, ReactElement, FormEvent } from 'react'; +import { FormEvent, ReactElement, useEffect } from 'react'; import { Tooltip } from 'shared/ui/tooltip'; import { Button } from 'shared/ui/button'; +import { SortByBlock } from 'features/filter/ui/sortBy-block'; +import { RadiusBlock } from 'features/filter/ui/radius-block'; +import { CalenderBlock } from 'features/filter/ui/calender-block'; +import { UserCategoriesBlock } from 'features/filter/ui/userCategories-block'; +import { TimeBlock } from 'features/filter/ui/time-block'; +import { CategoriesBlock } from 'features/filter/ui/categories-block'; + import type { IFilterValues } from 'features/filter/types'; import styles from './filter-cover.module.css'; import { CloseCrossIcon } from 'shared/ui/icons/close-cross-icon'; import { defaultObjFilteres } from 'features/filter/consts'; import { useSearchParams } from 'react-router-dom'; +import { Controller, useForm } from 'react-hook-form'; interface FilterCoverProps { closeFilterMenu: () => void; position: { top: number; right: number }; - filterMenu: ReactElement; - filterValues: IFilterValues; + // filterMenu: ReactElement; + filterMenu: { [key in keyof IFilterValues]?: boolean } | undefined; + // filterValues: IFilterValues; setFilteres?: (item: IFilterValues) => void; - onReset: () => void; + // onReset: () => void; } export const FilterCover = ({ closeFilterMenu, position, filterMenu, - filterValues, - onReset, setFilteres, -}: FilterCoverProps) => { +}: // filterValues, +// onReset, +FilterCoverProps) => { const [_, setSearchParams] = useSearchParams(); const newSearchParams = new URLSearchParams(); + const defaultValues: IFilterValues = { + categories: [], + searchRadius: '', + sortBy: '', + date: '', + time: [], + userCategories: [], + }; + + // const { control, handleSubmit, reset, watch } = useForm({ + const { control, reset, watch } = useForm({ + defaultValues, + }); + + const onSubmit = (data: IFilterValues) => { + if (setFilteres) { + setFilteres(data); + } + }; + + const filterValues = watch(); + + // filterValues={formValues} + useEffect(() => { if (window.innerWidth > 768) { setFilteres?.({ @@ -65,7 +98,8 @@ export const FilterCover = ({ }; const resetFilter = () => { - onReset(); + // onReset(); + reset(defaultValues); setSearchParams(defaultObjFilteres); setFilteres?.(defaultObjFilteres); closeFilterMenu(); @@ -81,6 +115,78 @@ export const FilterCover = ({ applyFilter(); }; + const items = filterMenu; + + const element: ReactElement = ( + <> + {items?.sortBy && ( + ( + + )} + /> + )} + {items?.categories && ( + ( + + )} + /> + )} + {items?.userCategories && ( + ( + + )} + /> + )} + {items?.searchRadius && ( + ( + + )} + /> + )} +
+ {items?.time && ( + ( + + )} + /> + )} + {items?.date && ( + ( + + )} + /> + )} +
+ + ); + const isFilterSelected = () => { return ( filterValues.categories.length > 0 || @@ -99,13 +205,9 @@ export const FilterCover = ({ extClassName={styles.tooltip} visible > -
+
- {filterMenu} + {element}
diff --git a/src/features/filter/components/filter-wrapper/filter-wrapper.tsx b/src/features/filter/components/filter-wrapper/filter-wrapper.tsx index aa65b5ac8..a23cc3467 100644 --- a/src/features/filter/components/filter-wrapper/filter-wrapper.tsx +++ b/src/features/filter/components/filter-wrapper/filter-wrapper.tsx @@ -1,22 +1,23 @@ -import { useState, useRef, ReactElement, useCallback, useEffect } from 'react'; +import { ReactElement, useCallback, useEffect, useRef, useState } from 'react'; import { FilterButton } from 'features/filter/components/filter-button'; import { FilterCover } from 'features/filter/components/filter-cover'; import { IFilterValues } from 'features/filter/types'; interface FilterWrapperProps { - filterMenu: ReactElement; - filterValues: IFilterValues; + // filterMenu: ReactElement; + filterMenu: { [key in keyof IFilterValues]?: boolean } | undefined; + // filterValues: IFilterValues; setFilteres?: (data: IFilterValues) => void; - onReset: () => void; + // onReset: () => void; } export const FilterWrapper = ({ filterMenu, - filterValues, setFilteres, - onReset, -}: FilterWrapperProps) => { +}: // filterValues, +// onReset, +FilterWrapperProps) => { const [isFilterMenuVisible, setFilterMenuVisible] = useState(false); const [filterPosition, setFilterPosition] = useState({ top: 10, right: 0 }); @@ -58,9 +59,9 @@ export const FilterWrapper = ({ closeFilterMenu={toggleFilterMenu} position={filterPosition} filterMenu={filterMenu} - filterValues={filterValues} + // filterValues={filterValues} setFilteres={setFilteres} - onReset={onReset} + // onReset={onReset} /> )} diff --git a/src/features/filter/filter.stories.tsx b/src/features/filter/filter.stories.tsx index aa99e64ee..bc7b6d842 100644 --- a/src/features/filter/filter.stories.tsx +++ b/src/features/filter/filter.stories.tsx @@ -57,9 +57,9 @@ type Story = StoryObj; export const DefaultFilter: Story & any = { args: { items: { - sort: false, + sortBy: false, categories: true, - radius: true, + searchRadius: true, time: true, date: true, }, diff --git a/src/features/filter/filter.tsx b/src/features/filter/filter.tsx index 4e11ee1ae..db0c7d94d 100644 --- a/src/features/filter/filter.tsx +++ b/src/features/filter/filter.tsx @@ -1,4 +1,4 @@ -import { useForm, Controller } from 'react-hook-form'; +import { Controller, useForm } from 'react-hook-form'; import { FilterWrapper } from 'features/filter/components/filter-wrapper'; import { FilterProps, IFilterValues } from 'features/filter/types'; import { SortByBlock } from 'features/filter/ui/sortBy-block'; @@ -14,117 +14,114 @@ export const Filter = ({ notFoundFilter = false, setFilteres, }: FilterProps) => { - const defaultValues: IFilterValues = { - categories: [], - searchRadius: '', - sortBy: '', - date: '', - time: [], - userCategories: [], - }; - - const { control, handleSubmit, reset, watch } = useForm({ - defaultValues, - }); - - const onSubmit = (data: IFilterValues) => { - if (setFilteres) { - setFilteres(data); - } - }; + // const defaultValues: IFilterValues = { + // categories: [], + // searchRadius: '', + // sortBy: '', + // date: '', + // time: [], + // userCategories: [], + // }; + // + // const { control, handleSubmit, reset, watch } = useForm({ + // defaultValues, + // }); + // + // const onSubmit = (data: IFilterValues) => { + // if (setFilteres) { + // setFilteres(data); + // } + // }; + // + // const formValues = watch(); if (notFoundFilter) { return null; } - - const formValues = watch(); return ( -
- - - {items?.sort && ( - ( - - )} - /> - )} - {items?.categories && ( - ( - - )} - /> - )} - {items?.userCategories && ( - ( - - )} - /> - )} - {items?.radius && ( - ( - - )} - /> - )} -
- {items?.time && ( - ( - - )} - /> - )} - {items?.date && ( - ( - - )} - /> - )} -
- - } - filterValues={formValues} - onReset={() => reset(defaultValues)} - setFilteres={setFilteres} - /> - -
+ <> + {/*
*/} + {/*
*/} + + // {items?.sortBy && ( + // ( + // + // )} + // /> + // )} + // {items?.categories && ( + // ( + // + // )} + // /> + // )} + // {items?.userCategories && ( + // ( + // + // )} + // /> + // )} + // {items?.searchRadius && ( + // ( + // + // )} + // /> + // )} + //
+ // {items?.time && ( + // ( + // + // )} + // /> + // )} + // {items?.date && ( + // ( + // + // )} + // /> + // )} + //
+ // + } + // filterValues={formValues} + // onReset={() => reset(defaultValues)} + setFilteres={setFilteres} + /> + {/* */} + {/*
*/} + ); }; diff --git a/src/features/filter/types.ts b/src/features/filter/types.ts index 44d6dc00d..fd8e4bc03 100644 --- a/src/features/filter/types.ts +++ b/src/features/filter/types.ts @@ -9,12 +9,7 @@ export interface IFilterValues { export interface FilteringProps { items: { - categories?: boolean; - radius?: boolean; - sort?: boolean; - date?: boolean; - time?: boolean; - userCategories?: boolean; + [key in keyof IFilterValues]?: boolean; }; setFilteres?: (date: IFilterValues) => void; notFoundFilter?: never; diff --git a/src/pages/profile-active/index.tsx b/src/pages/profile-active/index.tsx index b0a82ab54..940891c21 100644 --- a/src/pages/profile-active/index.tsx +++ b/src/pages/profile-active/index.tsx @@ -1,7 +1,7 @@ import { useEffect, useState } from 'react'; import { useAppDispatch, useAppSelector } from 'app/hooks'; -import { SmartHeader, Icon, Loader } from 'shared/ui'; +import { Icon, Loader, SmartHeader } from 'shared/ui'; import { useMediaQuery } from 'shared/hooks'; import { isUnConfirmedSelector, TaskList } from 'entities'; import { Breakpoints } from 'shared/config'; @@ -56,9 +56,9 @@ export function ProfileActivePage() { !isUnConfirmed ? ( { tasks && handleFilterTasks(tasks, setFilterTasks, infoFilterTasks); @@ -44,9 +44,9 @@ export function ProfileCompletedPage() { !isUnConfirmed ? (