Skip to content

Commit

Permalink
chore(facets): minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
cesconix committed Aug 28, 2024
1 parent 71573cb commit 87d62c0
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 19 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { FacetItem } from "./facet-item"

import type { IntrospectionFacet } from "pinorama-types"
import type { AnySchema } from "@orama/orama"
import type { IntrospectionFacet, PinoramaIntrospection } from "pinorama-types"
import type { FacetValue, SearchFilters } from "../types"

type FacetBodyProps = {
introspection: PinoramaIntrospection<AnySchema>
name: string
type: IntrospectionFacet
values: FacetValue[]
Expand All @@ -18,6 +20,7 @@ export function FacetBody(props: FacetBodyProps) {
return (
<FacetItem
key={value}
introspection={props.introspection}
name={props.name}
type={props.type}
value={value}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { Button } from "@/components/ui/button"
import { usePinoramaConnection } from "@/hooks"
import { createField } from "@/lib/introspection"
import type { AnySchema } from "@orama/orama"
import { ChevronDown, ChevronRight, CircleX, LoaderIcon } from "lucide-react"
import type { PinoramaIntrospection } from "pinorama-types"
import type React from "react"

type FacetHeaderProps = {
introspection: PinoramaIntrospection<AnySchema>
name: string
loading: boolean
count: number
Expand All @@ -14,13 +16,7 @@ type FacetHeaderProps = {
}

export function FacetHeader(props: FacetHeaderProps) {
const { introspection } = usePinoramaConnection()

if (!introspection) {
return null
}

const field = createField(props.name, introspection)
const field = createField(props.name, props.introspection)
const ChevronIcon = props.open ? ChevronDown : ChevronRight

return (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { Badge } from "@/components/ui/badge"
import { Label } from "@/components/ui/label"
import { usePinoramaConnection } from "@/hooks"
import { createField } from "@/lib/introspection"
import { FacetFactoryInput } from "./facet-factory-input"

import type { IntrospectionFacet } from "pinorama-types"
import type { AnySchema } from "@orama/orama"
import type { IntrospectionFacet, PinoramaIntrospection } from "pinorama-types"
import type { SearchFilters } from "../types"

type FacetItemProps = {
introspection: PinoramaIntrospection<AnySchema>
name: string
type: IntrospectionFacet
value: string | number
Expand All @@ -17,13 +18,7 @@ type FacetItemProps = {
}

export function FacetItem(props: FacetItemProps) {
const { introspection } = usePinoramaConnection()

if (!introspection) {
return null
}

const field = createField(props.name, introspection)
const field = createField(props.name, props.introspection)

return (
<div className="flex items-center space-x-3 h-[38px] px-3 border-b last:border-b-0 bg-muted/20">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ import { facetFilterOperationsFactory } from "../lib/operations"
import { FacetBody } from "./facet-body"
import { FacetHeader } from "./facet-header"

import type { IntrospectionFacet } from "pinorama-types"
import type { AnySchema } from "@orama/orama"
import type { IntrospectionFacet, PinoramaIntrospection } from "pinorama-types"
import type { FacetFilter, FacetValue, SearchFilters } from "../types"

type FacetProps = {
introspection: PinoramaIntrospection<AnySchema>
name: string
type: IntrospectionFacet
searchText: string
Expand Down Expand Up @@ -82,6 +84,7 @@ export function Facet(props: FacetProps) {
return (
<div>
<FacetHeader
introspection={props.introspection}
name={props.name}
loading={fetchStatus === "fetching"}
count={selelectedOptionCount}
Expand All @@ -99,6 +102,7 @@ export function Facet(props: FacetProps) {
/>
) : (
<FacetBody
introspection={props.introspection}
name={props.name}
type={props.type}
values={allValues}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export function LogFilters(props: PinoramaFacetsProps) {
return (
<Facet
key={facet.name}
introspection={props.introspection}
name={facet.name}
type={facet.type}
searchText={props.searchText}
Expand Down

0 comments on commit 87d62c0

Please sign in to comment.