Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add filter hooks #7

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions app/hooks/useFilter.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { useState } from "react"
import { Filter } from "~/types"

export const useFilter = () => {
const [filters, setFilters] = useState<Filter>({})

const updateFilter = <K extends keyof Filter>(key: K, value: Filter[K]) => {
setFilters((prev) => ({ ...prev, [key]: value }))
}

return { filters, updateFilter }
}
6 changes: 4 additions & 2 deletions app/root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
Scripts,
ScrollRestoration,
} from "@remix-run/react"
import { ColorSchemeScript, MantineProvider } from "@mantine/core"
import { ColorSchemeScript, Container, MantineProvider } from "@mantine/core"

export function Layout({ children }: { children: React.ReactNode }) {
return (
Expand All @@ -20,7 +20,9 @@ export function Layout({ children }: { children: React.ReactNode }) {
<ColorSchemeScript />
</head>
<body>
<MantineProvider>{children}</MantineProvider>
<MantineProvider>
<Container>{children}</Container>
</MantineProvider>
<ScrollRestoration />
<Scripts />
</body>
Expand Down
8 changes: 4 additions & 4 deletions app/routes/_index.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { Box } from "@mantine/core"
import type { MetaFunction } from "@remix-run/node"
import { useFilter } from "~/hooks/useFilter"

export const meta: MetaFunction = () => {
return [
{ title: "New Remix App" },
{ name: "description", content: "Welcome to Remix!" },
]
return [{ title: "BirdXplorer Viewer" }, { name: "description", content: "" }]
}

export default function Index() {
const { filters, updateFilter } = useFilter()

return <Box>Hello World</Box>
}
50 changes: 50 additions & 0 deletions app/types/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
export type Language =
| "en"
| "es"
| "ja"
| "pt"
| "de"
| "fr"
| "fi"
| "tr"
| "nl"
| "he"
| "it"
| "fa"
| "ca"
| "ar"
| "el"
| "sv"
| "da"
| "ru"
| "pl"
| "other"

export type NoteStatus =
| "NEEDS_MORE_RATINGS"
| "CURRENTLY_RATED_HELPFUL"
| " CURRENTLY_RATED_NOT_HELPFUL"

export type MediaType = "IMAGE" | "VIDEO" | "ALL"

export interface Filter {
noteIncludeKeywords?: string
noteExcludeKeywords?: string
language?: Language
topic_ids?: number[]
note_current_status?: NoteStatus
note_created_at_from?: number
note_created_at_to?: number

postIncludeKeywords?: string
postExcludeKeywords?: string
user_id?: string
user_follower_count?: number
user_following_count?: number
post_like_count?: number
post_repost_count?: number
post_impression_count?: number
post_created_at_from?: number
post_created_at_to?: number
media_type?: MediaType
}