Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
newfish-cmyk committed Apr 16, 2024
1 parent a829088 commit 748c9d2
Showing 1 changed file with 15 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useEffect, useState } from "react";
import React, { useEffect, useMemo, useState } from "react";
import { Controller, useForm } from "react-hook-form";
import { useNavigate } from "react-router-dom";
import {
Expand Down Expand Up @@ -59,9 +59,9 @@ const CreateModal = (props: {

useEffect(() => {
const searchParams = new URLSearchParams(window.location.search);
const templateid = searchParams.get("templateid");
if (!templateid) return;
localStorage.setItem("templateid", templateid);
const templateId = searchParams.get("templateId");
if (!templateId) return;
localStorage.setItem("templateId", templateId);
}, []);

const defaultValues = {
Expand Down Expand Up @@ -124,9 +124,17 @@ const CreateModal = (props: {
},
);

const recommedList = InitialTemplateList.data?.data.list || [];
const searchedList = searchedTemplateList.data?.data.list || [];
const showedList = [...searchedList, ...recommedList].slice(0, 3);
const recommendedList = useMemo(
() => InitialTemplateList.data?.data.list || [],
[InitialTemplateList],
);
const searchedList = useMemo(
() => searchedTemplateList.data?.data.list || [],
[searchedTemplateList],
);
const showedList = useMemo(() => {
return [...searchedList, ...recommendedList].slice(0, 3);
}, [searchedList, recommendedList]);

const onSubmit = async (data: any) => {
let res: any = {};
Expand Down

0 comments on commit 748c9d2

Please sign in to comment.