fix: show appropriate filters based on searching item
All checks were successful
Release to Staging / build_and_release (push) Successful in 44s
All checks were successful
Release to Staging / build_and_release (push) Successful in 44s
This commit is contained in:
parent
d11ad60ede
commit
6a087e659c
@ -51,6 +51,7 @@ interface FilterOptions {
|
|||||||
sort: SortByEnum
|
sort: SortByEnum
|
||||||
moderated: ModeratedFilterEnum
|
moderated: ModeratedFilterEnum
|
||||||
searching: SearchingFilterEnum
|
searching: SearchingFilterEnum
|
||||||
|
source: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export const SearchPage = () => {
|
export const SearchPage = () => {
|
||||||
@ -61,6 +62,7 @@ export const SearchPage = () => {
|
|||||||
const [filterOptions, setFilterOptions] = useState<FilterOptions>({
|
const [filterOptions, setFilterOptions] = useState<FilterOptions>({
|
||||||
sort: SortByEnum.Latest,
|
sort: SortByEnum.Latest,
|
||||||
moderated: ModeratedFilterEnum.Moderated,
|
moderated: ModeratedFilterEnum.Moderated,
|
||||||
|
source: window.location.host,
|
||||||
searching:
|
searching:
|
||||||
(searchParams.get('searching') as SearchingFilterEnum) ||
|
(searchParams.get('searching') as SearchingFilterEnum) ||
|
||||||
SearchingFilterEnum.Mods
|
SearchingFilterEnum.Mods
|
||||||
@ -164,6 +166,7 @@ const Filters = React.memo(
|
|||||||
return (
|
return (
|
||||||
<div className='IBMSecMain'>
|
<div className='IBMSecMain'>
|
||||||
<div className='FiltersMain'>
|
<div className='FiltersMain'>
|
||||||
|
{filterOptions.searching === SearchingFilterEnum.Mods && (
|
||||||
<div className='FiltersMainElement'>
|
<div className='FiltersMainElement'>
|
||||||
<div className='dropdown dropdownMain'>
|
<div className='dropdown dropdownMain'>
|
||||||
<button
|
<button
|
||||||
@ -193,6 +196,10 @@ const Filters = React.memo(
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{(filterOptions.searching === SearchingFilterEnum.Mods ||
|
||||||
|
filterOptions.searching === SearchingFilterEnum.Users) && (
|
||||||
<div className='FiltersMainElement'>
|
<div className='FiltersMainElement'>
|
||||||
<div className='dropdown dropdownMain'>
|
<div className='dropdown dropdownMain'>
|
||||||
<button
|
<button
|
||||||
@ -231,6 +238,49 @@ const Filters = React.memo(
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{filterOptions.searching === SearchingFilterEnum.Mods && (
|
||||||
|
<div className='FiltersMainElement'>
|
||||||
|
<div className='dropdown dropdownMain'>
|
||||||
|
<button
|
||||||
|
className='btn dropdown-toggle btnMain btnMainDropdown'
|
||||||
|
aria-expanded='false'
|
||||||
|
data-bs-toggle='dropdown'
|
||||||
|
type='button'
|
||||||
|
>
|
||||||
|
{filterOptions.source === window.location.host
|
||||||
|
? `Show From: ${filterOptions.source}`
|
||||||
|
: 'Show All'}
|
||||||
|
</button>
|
||||||
|
<div className='dropdown-menu dropdownMainMenu'>
|
||||||
|
<div
|
||||||
|
className='dropdown-item dropdownMainMenuItem'
|
||||||
|
onClick={() =>
|
||||||
|
setFilterOptions((prev) => ({
|
||||||
|
...prev,
|
||||||
|
source: window.location.host
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
>
|
||||||
|
Show From: {window.location.host}
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
className='dropdown-item dropdownMainMenuItem'
|
||||||
|
onClick={() =>
|
||||||
|
setFilterOptions((prev) => ({
|
||||||
|
...prev,
|
||||||
|
source: 'Show All'
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
>
|
||||||
|
Show All
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
<div className='FiltersMainElement'>
|
<div className='FiltersMainElement'>
|
||||||
<div className='dropdown dropdownMain'>
|
<div className='dropdown dropdownMain'>
|
||||||
<button
|
<button
|
||||||
@ -353,6 +403,11 @@ const ModsResult = ({
|
|||||||
|
|
||||||
const filteredModList = useMemo(() => {
|
const filteredModList = useMemo(() => {
|
||||||
let filtered: ModDetails[] = [...filteredMods]
|
let filtered: ModDetails[] = [...filteredMods]
|
||||||
|
|
||||||
|
if (filterOptions.source === window.location.host) {
|
||||||
|
filtered = filtered.filter((mod) => mod.rTag === window.location.host)
|
||||||
|
}
|
||||||
|
|
||||||
const isAdmin = userState.user?.npub === import.meta.env.VITE_REPORTING_NPUB
|
const isAdmin = userState.user?.npub === import.meta.env.VITE_REPORTING_NPUB
|
||||||
const isUnmoderatedFully =
|
const isUnmoderatedFully =
|
||||||
filterOptions.moderated === ModeratedFilterEnum.Unmoderated_Fully
|
filterOptions.moderated === ModeratedFilterEnum.Unmoderated_Fully
|
||||||
@ -386,6 +441,7 @@ const ModsResult = ({
|
|||||||
userState.user?.npub,
|
userState.user?.npub,
|
||||||
filterOptions.sort,
|
filterOptions.sort,
|
||||||
filterOptions.moderated,
|
filterOptions.moderated,
|
||||||
|
filterOptions.source,
|
||||||
muteLists
|
muteLists
|
||||||
])
|
])
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user