{noEvents ? (
@@ -327,83 +178,247 @@ export const ModEventList = (
)
}
-// This is component which renders a list of checkboxes by iterating over MOD_EVENT_TITLES list for filtering by type
-// same as the TypeFilter component but instead of dropdown, use checkboxes
-// on each checkbox click, it will call the `setSelectedTypes` function and toggle the checkox's type
-const TypeFilterCheckbox = ({
- selectedTypes,
- setSelectedTypes,
-}: {
- selectedTypes: string[]
- setSelectedTypes: (type: string[]) => void
-}) => {
+const EventFilterPanel = ({
+ types,
+ commentFilter,
+ createdBy,
+ subject,
+ oldestFirst,
+ createdAfter,
+ createdBefore,
+ toggleCommentFilter,
+ setCommentFilterKeyword,
+ changeListFilter,
+}: Omit &
+ Pick<
+ ReturnType,
+ | 'changeListFilter'
+ | 'commentFilter'
+ | 'toggleCommentFilter'
+ | 'setCommentFilterKeyword'
+ >) => {
const allTypes = Object.entries(MOD_EVENT_TITLES)
const toggleType = (type) => {
if (type === 'all') {
- if (selectedTypes.length === allTypes.length) {
- setSelectedTypes([])
+ if (types.length === allTypes.length) {
+ changeListFilter({ field: 'types', value: [] })
} else {
- setSelectedTypes(allTypes.map(([type]) => type))
+ changeListFilter({
+ field: 'types',
+ value: allTypes.map(([type]) => type),
+ })
}
return
}
- const newTypes = selectedTypes.includes(type)
- ? selectedTypes.filter((t) => t !== type)
- : [...selectedTypes, type]
- setSelectedTypes(newTypes)
+ const newTypes = types.includes(type)
+ ? types.filter((t) => t !== type)
+ : [...types, type]
+ changeListFilter({ field: 'types', value: newTypes })
}
return (
-
-
Event Type
-
- toggleType('all')}
- className="h-4 w-4 rounded border-gray-300 text-indigo-600 focus:ring-indigo-600"
- onKeyDown={(e) => {
- if (e.key === 'Enter') {
- e.preventDefault() // make sure we don't submit the form
- e.currentTarget.click() // simulate a click on the input
- }
- }}
- />
-
-
- {allTypes.map(([type, title]) => (
-
- toggleType(type)}
- className="h-4 w-4 rounded border-gray-300 text-indigo-600 focus:ring-indigo-600"
- onKeyDown={(e) => {
- if (e.key === 'Enter') {
- e.preventDefault() // make sure we don't submit the form
- e.currentTarget.click() // simulate a click on the input
+
+
+
+
+
Event Type
+
+ toggleType('all')}
+ className="h-4 w-4 rounded border-gray-300 text-indigo-600 focus:ring-indigo-600"
+ onKeyDown={(e) => {
+ if (e.key === 'Enter') {
+ e.preventDefault() // make sure we don't submit the form
+ e.currentTarget.click() // simulate a click on the input
+ }
+ }}
+ />
+
+
+ {allTypes.map(([type, title]) => (
+
+ toggleType(type)}
+ className="h-4 w-4 rounded border-gray-300 text-indigo-600 focus:ring-indigo-600"
+ onKeyDown={(e) => {
+ if (e.key === 'Enter') {
+ e.preventDefault() // make sure we don't submit the form
+ e.currentTarget.click() // simulate a click on the input
+ }
+ }}
+ />
+
+
+ ))}
+
+
+
+
Comment/Note
+
+
+ toggleCommentFilter()}
+ className="h-4 w-4 rounded border-gray-300 text-indigo-600 focus:ring-indigo-600"
+ onKeyDown={(e) => {
+ if (e.key === 'Enter') {
+ e.preventDefault() // make sure we don't submit the form
+ e.currentTarget.click() // simulate a click on the input
+ }
+ }}
+ />
+
+
)
}
diff --git a/components/mod-event/useModEventList.tsx b/components/mod-event/useModEventList.tsx
index a086effd..9fe390ec 100644
--- a/components/mod-event/useModEventList.tsx
+++ b/components/mod-event/useModEventList.tsx
@@ -30,7 +30,7 @@ const initialListState = {
}
// The 2 fields need overriding because in the initialState, they are set as undefined so the alternative string type is not accepted without override
-type EventListState = Omit & {
+export type EventListState = Omit & {
subject?: string
createdBy?: string
}