Skip to content

Commit

Permalink
removing redudant features from schemasearch
Browse files Browse the repository at this point in the history
  • Loading branch information
BANANAPEEL202 committed Oct 30, 2024
1 parent d3128bc commit 86eb4cd
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/components/SchemaSearch.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useState, useEffect } from "react";
import { Autocomplete, Button } from "@mantine/core";
import { Autocomplete } from "@mantine/core";
import "@/css/SchemaSearch.css";

interface SchemaSearch {
Expand All @@ -9,29 +9,32 @@ interface SchemaSearch {

const SchemaSearch: React.FC<SchemaSearch> = ({ schemas, clear }) => {
const [value, setValue] = useState<string>("");
const [selectedSchema, setSelected] = useState<string[]>([]);
//const [selectedSchema, setSelected] = useState<string[]>([]);

const filteredSchemas = schemas.filter((schema) =>
schema.toLowerCase().includes(value.toLowerCase()),
);

{
/*
const addSchema = (newSchema: string) => {
if (!selectedSchema.includes(newSchema)) {
setSelected([...selectedSchema, newSchema]);
} else {
alert("Schema already selected!");
}
};
*/
}

const clearSchema = () => {
setSelected([]);
//setSelected([]);
setValue("");
};

const handleKeyDown = (event: React.KeyboardEvent<HTMLInputElement>) => {
if (event.key === "Enter" && filteredSchemas.length > 0) {
setValue(filteredSchemas[0]);
addSchema(filteredSchemas[0]);
//addSchema(filteredSchemas[0]);
}
};

Expand All @@ -50,6 +53,7 @@ const SchemaSearch: React.FC<SchemaSearch> = ({ schemas, clear }) => {
onKeyDown={handleKeyDown}
/>
<br />
{/*
{selectedSchema.length > 0 && (
<div>
<label>Selected Schema</label>
Expand All @@ -58,11 +62,10 @@ const SchemaSearch: React.FC<SchemaSearch> = ({ schemas, clear }) => {
<li key={index}>{str}</li>
))}
</ul>
<Button className="cancel-button" onClick={clearSchema}>
Cancel
</Button>
</div>
)}
*/}
</div>
);
};
Expand Down

0 comments on commit 86eb4cd

Please sign in to comment.