From b2c1e1b74254294e69edc2494bc514c609fa357d Mon Sep 17 00:00:00 2001 From: Kush Choudhary Date: Mon, 21 Oct 2024 05:41:58 +0530 Subject: [PATCH] [Added]: Custom label functionality. --- src/containers/Filter.tsx | 23 ++++++++++++++++++++++- src/models/Label.ts | 4 ++-- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/src/containers/Filter.tsx b/src/containers/Filter.tsx index 0b7937a..7ffc890 100644 --- a/src/containers/Filter.tsx +++ b/src/containers/Filter.tsx @@ -5,8 +5,20 @@ import { Label, sortedLabels } from '@/models/Label'; import { Language, sortedLanguages } from '@/models/Language'; import { SortingTag, sortedSortingTags } from '@/models/SortingTag'; import { useUrlValues } from '@/providers/urlProvider'; +import { FormEvent, useState } from 'react'; const Filter = () => { + const [customLabel, setCustomLabel] = useState(""); + + const [labels, setLabels] = useState(sortedLabels); + + const customLabelHandler = (e: FormEvent) => { + e.preventDefault(); + setLabels([...labels, customLabel]); + onLabelChange(customLabel); + setCustomLabel(""); + } + const { dispatch, language, ordering, sortingTag, label } = useUrlValues(); const onLanguageChange = (payload: Language) => { @@ -40,7 +52,7 @@ const Filter = () => {