Skip to content

Commit

Permalink
feat: Ability to use a custom search in debug search page
Browse files Browse the repository at this point in the history
  • Loading branch information
ptbrowne committed Sep 13, 2022
1 parent ee0145c commit 52846ff
Showing 1 changed file with 132 additions and 100 deletions.
232 changes: 132 additions & 100 deletions app/components/debug-search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,14 @@ import CircularProgress from "@mui/material/CircularProgress";
import MenuItem from "@mui/material/MenuItem";
import Select from "@mui/material/Select";
import Switch from "@mui/material/Switch";
import TextField from "@mui/material/TextField";
import Typography from "@mui/material/Typography";
import React, { useRef, useState } from "react";
import { useEffect } from "react";
import React, {
useRef,
useState,
useEffect,
KeyboardEventHandler,
} from "react";

import { DataCubeSearchFilter, useDataCubesQuery } from "@/graphql/query-hooks";

Expand Down Expand Up @@ -181,6 +186,17 @@ const DebugSearch = () => {
const [sourceUrl, setSourceUrl] = useState(
"https://int.lindas.admin.ch/query"
);

const [customSearch, setCustomSearch] = useState("");
const handleKeyUp: KeyboardEventHandler<HTMLDivElement> = (ev) => {
if (ev.key === "Enter") {
if (!ev.target) {
return;
}
setCustomSearch((ev.target as HTMLInputElement).value);
}
};

return (
<Box
sx={{
Expand All @@ -206,105 +222,121 @@ const DebugSearch = () => {
<MenuItem value="https://int.lindas.admin.ch/query">int</MenuItem>
<MenuItem value="https://lindas.admin.ch/query">prod</MenuItem>
</Select>
<Search
sourceUrl={sourceUrl}
includeDrafts={includeDrafts}
query="bruit"
filters={[]}
locale="fr"
/>
<Search
sourceUrl={sourceUrl}
includeDrafts={includeDrafts}
query="Bathing"
filters={[territoryTheme]}
locale="en"
/>
<Search
sourceUrl={sourceUrl}
includeDrafts={includeDrafts}
query="bath"
filters={[territoryTheme]}
locale="en"
/>
<Search
sourceUrl={sourceUrl}
includeDrafts={includeDrafts}
query="Ausgaben"
filters={[]}
locale="de"
/>

<Search
sourceUrl={sourceUrl}
includeDrafts={includeDrafts}
query=""
filters={[territoryTheme]}
locale="en"
/>
<Search
sourceUrl={sourceUrl}
includeDrafts={includeDrafts}
query="SFOE"
filters={[geographyTheme]}
locale="en"
/>
<Search
sourceUrl={sourceUrl}
includeDrafts={includeDrafts}
query="National economy"
filters={[]}
locale="en"
/>
<Search
sourceUrl={sourceUrl}
includeDrafts={includeDrafts}
query="Einmalvergütung"
filters={[]}
locale="de"
/>
<Search
sourceUrl={sourceUrl}
includeDrafts={includeDrafts}
query="zeitverzögert"
filters={[]}
locale="de"
/>
<Search
sourceUrl={sourceUrl}
includeDrafts={includeDrafts}
query="öffentlich"
filters={[]}
locale="de"
/>
<Search
sourceUrl={sourceUrl}
includeDrafts={includeDrafts}
query="WASTA"
filters={[]}
locale="en"
/>
<Search
sourceUrl={sourceUrl}
includeDrafts={includeDrafts}
query="tari"
filters={[]}
locale="en"
/>
<Search
sourceUrl={sourceUrl}
includeDrafts={includeDrafts}
query="SFA"
filters={[]}
locale="en"
/>
<Search
sourceUrl={sourceUrl}
includeDrafts={includeDrafts}
query="émissions de gaz à effet de serre"
filters={[]}
locale="fr"
<TextField
defaultValue=""
placeholder="Search..."
onKeyUp={handleKeyUp}
/>
{customSearch !== "" ? (
<Search
sourceUrl={sourceUrl}
includeDrafts={includeDrafts}
query={customSearch}
filters={[]}
locale="fr"
/>
) : (
<>
<Search
sourceUrl={sourceUrl}
includeDrafts={includeDrafts}
query="bruit"
filters={[]}
locale="fr"
/>
<Search
sourceUrl={sourceUrl}
includeDrafts={includeDrafts}
query="Bathing"
filters={[territoryTheme]}
locale="en"
/>
<Search
sourceUrl={sourceUrl}
includeDrafts={includeDrafts}
query="bath"
filters={[territoryTheme]}
locale="en"
/>
<Search
sourceUrl={sourceUrl}
includeDrafts={includeDrafts}
query="Ausgaben"
filters={[]}
locale="de"
/>
<Search
sourceUrl={sourceUrl}
includeDrafts={includeDrafts}
query=""
filters={[territoryTheme]}
locale="en"
/>
<Search
sourceUrl={sourceUrl}
includeDrafts={includeDrafts}
query="SFOE"
filters={[geographyTheme]}
locale="en"
/>
<Search
sourceUrl={sourceUrl}
includeDrafts={includeDrafts}
query="National economy"
filters={[]}
locale="en"
/>
<Search
sourceUrl={sourceUrl}
includeDrafts={includeDrafts}
query="Einmalvergütung"
filters={[]}
locale="de"
/>
<Search
sourceUrl={sourceUrl}
includeDrafts={includeDrafts}
query="zeitverzögert"
filters={[]}
locale="de"
/>
<Search
sourceUrl={sourceUrl}
includeDrafts={includeDrafts}
query="öffentlich"
filters={[]}
locale="de"
/>
<Search
sourceUrl={sourceUrl}
includeDrafts={includeDrafts}
query="WASTA"
filters={[]}
locale="en"
/>
<Search
sourceUrl={sourceUrl}
includeDrafts={includeDrafts}
query="tari"
filters={[]}
locale="en"
/>
<Search
sourceUrl={sourceUrl}
includeDrafts={includeDrafts}
query="SFA"
filters={[]}
locale="en"
/>
<Search
sourceUrl={sourceUrl}
includeDrafts={includeDrafts}
query="émissions de gaz à effet de serre"
filters={[]}
locale="fr"
/>
</>
)}
</Box>
);
};
Expand Down

0 comments on commit 52846ff

Please sign in to comment.