fix tags
This commit is contained in:
parent
32f87910ea
commit
05d0a12527
|
|
@ -54,7 +54,14 @@ const SelectTag: React.FC = () => {
|
|||
formik?.values?.tags?.map((item: any) => item?.id ?? item) ?? [];
|
||||
|
||||
const AllOptions = [...options, ...additionalData,NewAdditionalData];
|
||||
|
||||
const uniqueOptions = Array.from(
|
||||
new Map(
|
||||
AllOptions
|
||||
.filter(item => Object.keys(item).length > 0) // Filter out empty objects
|
||||
.map(item => [item.id, item]) // Create [id, item] pairs to ensure uniqueness
|
||||
).values()
|
||||
);
|
||||
|
||||
return (
|
||||
<div className="SelectTag">
|
||||
<label htmlFor="">{t("models.tag")}</label>
|
||||
|
|
@ -65,7 +72,7 @@ const SelectTag: React.FC = () => {
|
|||
placeholder=""
|
||||
fieldNames={{ label: "name", value: "id" }}
|
||||
onChange={handleChange}
|
||||
options={AllOptions}
|
||||
options={uniqueOptions}
|
||||
filterOption={false}
|
||||
loading={isLoading}
|
||||
notFoundContent={isLoading ? <Spin /> : t("practical.not_found")}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,16 @@ const MaltySelectTag = ({ parent_index }: { parent_index: number }) => {
|
|||
const [fieldValue, setFieldValue] = useState<string>("");
|
||||
const formik = useFormikContext<any>();
|
||||
const values = formik?.values?.Questions?.[parent_index]?.tags;
|
||||
const handleChange = (value: string[]) => {
|
||||
const [NewAdditionalData, setNewAdditionalData] = useState({})
|
||||
|
||||
const handleChange = (value: string[],option:any) => {
|
||||
const newSelectedOption = option?.pop()
|
||||
const newObject = {
|
||||
id:newSelectedOption?.id,
|
||||
name:newSelectedOption?.name
|
||||
}
|
||||
setNewAdditionalData(newObject)
|
||||
|
||||
formik.setFieldValue(`Questions.[${parent_index}].tags`, value);
|
||||
setSearchValue("");
|
||||
setFieldValue("");
|
||||
|
|
@ -46,8 +55,16 @@ const MaltySelectTag = ({ parent_index }: { parent_index: number }) => {
|
|||
(item: any) => item?.id ?? item,
|
||||
) ?? [];
|
||||
|
||||
const AllOptions = [...options, ...additionalData];
|
||||
const AllOptions = [...options, ...additionalData,NewAdditionalData];
|
||||
|
||||
const uniqueOptions = Array.from(
|
||||
new Map(
|
||||
AllOptions
|
||||
.filter(item => Object.keys(item).length > 0) // Filter out empty objects
|
||||
.map(item => [item.id, item]) // Create [id, item] pairs to ensure uniqueness
|
||||
).values()
|
||||
);
|
||||
|
||||
return (
|
||||
<div className="SelectTag">
|
||||
<label htmlFor="">{t("models.tag")}</label>
|
||||
|
|
@ -58,7 +75,7 @@ const MaltySelectTag = ({ parent_index }: { parent_index: number }) => {
|
|||
placeholder=""
|
||||
fieldNames={{ label: "name", value: "id" }}
|
||||
onChange={handleChange}
|
||||
options={AllOptions}
|
||||
options={uniqueOptions}
|
||||
filterOption={false}
|
||||
loading={isLoading}
|
||||
notFoundContent={isLoading ? <Spin /> : t("practical.not_found")}
|
||||
|
|
|
|||
|
|
@ -7,14 +7,16 @@ import { handelImageState } from "../../../../utils/DataToSendImageState";
|
|||
import LayoutModel from "../../../../Layout/Dashboard/LayoutModel";
|
||||
import { QueryStatusEnum } from "../../../../enums/QueryStatus";
|
||||
import ModelForm from "./ModelForm";
|
||||
import { useParams } from "react-router-dom";
|
||||
import { ParamsEnum } from "../../../../enums/params";
|
||||
|
||||
const ModalForm: React.FC = () => {
|
||||
const { objectToEdit } = useObjectToEdit((state) => state);
|
||||
|
||||
const { mutate, status } = useUpdateSubject();
|
||||
|
||||
const {subject_id} = useParams<ParamsEnum>()
|
||||
const handleSubmit = (values: any) => {
|
||||
const Data_to_send = { ...values };
|
||||
const Data_to_send = { ...values,subject_id };
|
||||
const handelImage = handelImageState(Data_to_send, "icon");
|
||||
mutate(handelImage);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -9,14 +9,14 @@ const Dummy = () => {
|
|||
return (
|
||||
<div className="DummyHomePage">
|
||||
|
||||
<FilterButton/>
|
||||
{/* <FilterButton/>
|
||||
<FilterBody>
|
||||
karim
|
||||
</FilterBody>
|
||||
<Select
|
||||
style={{width:"200px"}}
|
||||
showSearch
|
||||
/>
|
||||
/> */}
|
||||
|
||||
</div>
|
||||
);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user