-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
463 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { useQuery } from '@tanstack/react-query'; | ||
import { useAtom } from 'jotai'; | ||
|
||
import { ProjectTagType } from 'web-components/src/components/molecules/ProjectTag/ProjectTag.types'; | ||
|
||
import { selectedLanguageAtom } from 'lib/atoms/languageSwitcher.atoms'; | ||
import { client as sanityClient } from 'lib/clients/sanity'; | ||
import { getAllEcosystemQuery } from 'lib/queries/react-query/sanity/getAllEcosystemQuery/getAllEcosystemQuery'; | ||
|
||
import { getIconsMapping } from 'components/organisms/ProjectTopSection/ProjectTopSection.utils'; | ||
|
||
export const useEcosystemTags = (ecosystemTypes: string[]) => { | ||
const [selectedLanguage] = useAtom(selectedLanguageAtom); | ||
const { data: allProjectEcosystemData } = useQuery( | ||
getAllEcosystemQuery({ | ||
sanityClient, | ||
languageCode: selectedLanguage, | ||
}), | ||
); | ||
const projectEcosystemIconsMapping = getIconsMapping({ | ||
data: allProjectEcosystemData?.allProjectEcosystem, | ||
}); | ||
|
||
const ecosystemTags = Object.fromEntries( | ||
ecosystemTypes?.map(ecosystem => [ | ||
ecosystem, | ||
projectEcosystemIconsMapping?.[ecosystem.toLowerCase()] ?? '', | ||
]) ?? [], | ||
); | ||
|
||
return ecosystemTags; | ||
}; |
112 changes: 112 additions & 0 deletions
112
web-marketplace/src/pages/Projects/AllProjects/AllProjects.ProjectFilter.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
import { useState } from 'react'; | ||
import { Trans } from '@lingui/macro'; | ||
import { useLingui } from '@lingui/react'; | ||
import { | ||
Box, | ||
FormControlLabel, | ||
Grid, | ||
SwipeableDrawer, | ||
SxProps, | ||
Theme, | ||
} from '@mui/material'; | ||
import { useAtom } from 'jotai'; | ||
import { sxToArray } from 'utils/mui/sxToArray'; | ||
|
||
import OutlinedButton from 'web-components/src/components/buttons/OutlinedButton'; | ||
import FilterIcon from 'web-components/src/components/icons/FilterIcon'; | ||
import Checkbox from 'web-components/src/components/inputs/new/CheckBox/Checkbox'; | ||
import { CollapseList } from 'web-components/src/components/organisms/CollapseList/CollapseList'; | ||
import { Subtitle } from 'web-components/src/components/typography'; | ||
import { cn } from 'web-components/src/utils/styles/cn'; | ||
|
||
import { | ||
creditClassSelectedFiltersAtom, | ||
useCommunityProjectsAtom, | ||
} from 'lib/atoms/projects.atoms'; | ||
import { SEE_LESS, SEE_MORE } from 'lib/constants/shared.constants'; | ||
import { COLOR_SCHEME, IS_TERRASOS } from 'lib/env'; | ||
import { useTracker } from 'lib/tracker/useTracker'; | ||
|
||
import { CommunityFilter } from './AllProjects.CommunityFilter'; | ||
import { | ||
COMMUNITY_FILTER_LABEL, | ||
CREDIT_CLASS_FILTER_LABEL, | ||
FILTERS_LABEL, | ||
RESET_FILTERS_LABEL, | ||
SIDE_FILTERS_BUTTON, | ||
UNREGISTERED_PATH, | ||
} from './AllProjects.constants'; | ||
import { CreditClassFilter, FilterCreditClassEvent } from './AllProjects.types'; | ||
import { | ||
getCreditClassSelectedFilters, | ||
getFilterSelected, | ||
} from './AllProjects.utils'; | ||
|
||
type Props = { | ||
// creditClassFilters?: CreditClassFilter[]; | ||
// hasCommunityProjects: boolean; | ||
// showFiltersReset: boolean; | ||
// resetFilter: () => void; | ||
// sx?: SxProps<Theme>; | ||
}; | ||
|
||
const ProjectFilter = ({ | ||
// creditClassFilters = [], | ||
// hasCommunityProjects, | ||
// showFiltersReset, | ||
// resetFilter, | ||
sx = [], | ||
}: Props) => { | ||
const { _ } = useLingui(); | ||
const [isOpen, setIsOpen] = useState(false); | ||
// const [creditClassSelectedFilters, setCreditClassSelectedFilters] = useAtom( | ||
// creditClassSelectedFiltersAtom, | ||
// ); | ||
// const [useCommunityProjects] = useAtom(useCommunityProjectsAtom); | ||
// const filteredCreditClassFilters = creditClassFilters.filter( | ||
// ({ isCommunity, path }) => | ||
// path === UNREGISTERED_PATH || | ||
// useCommunityProjects || | ||
// (!useCommunityProjects && !isCommunity), | ||
// ); | ||
// const { track } = useTracker(); | ||
|
||
// const values = Object.values(creditClassSelectedFilters); | ||
// const selectAllEnabled = values.includes(false); | ||
// const clearAllEnabled = values.includes(true); | ||
|
||
return ( | ||
<> | ||
<OutlinedButton | ||
size="small" | ||
onClick={() => setIsOpen(true)} | ||
startIcon={ | ||
<FilterIcon | ||
sx={{ | ||
with: 25, | ||
height: 24, | ||
}} | ||
/> | ||
} | ||
sx={[ | ||
{ | ||
mr: 4, | ||
}, | ||
...sxToArray(sx), | ||
]} | ||
> | ||
{_(SIDE_FILTERS_BUTTON)} | ||
</OutlinedButton> | ||
<SwipeableDrawer | ||
anchor="left" | ||
open={isOpen} | ||
onClose={() => setIsOpen(false)} | ||
onOpen={() => setIsOpen(true)} | ||
> | ||
hello | ||
</SwipeableDrawer> | ||
</> | ||
); | ||
}; | ||
|
||
export default ProjectFilter; |
Oops, something went wrong.