diff --git a/src/components/dashboards/AnalysisClient.tsx b/src/components/dashboards/AnalysisClient.tsx index 6c5bddb..57e0954 100644 --- a/src/components/dashboards/AnalysisClient.tsx +++ b/src/components/dashboards/AnalysisClient.tsx @@ -5,6 +5,7 @@ import { Sparkles, X } from "lucide-react"; import { Input } from "../ui/input"; import { Button } from "../ui/button"; import ResultSection from "./ResultSection"; +import UrlInputList from "./UrlInputList"; export default function AnalysisClient() { const { @@ -23,39 +24,6 @@ export default function AnalysisClient() { setVisibleFields, } = useAnalyseText(); - const urlInput = () => { - return urlDatas.slice(0, visibleFields).map((item, index) => ( -
- -
-
- -
- {index === visibleFields - 1 && ( - - )} -
-
- )); - }; - return (
- {urlInput()} + {visibleFields < 2 && (
{ + return ( +
+ +
+
+ +
+ {index === visibleFields - 1 && ( + + )} +
+
+ ); +}; + +export default UrlInputItem; diff --git a/src/components/dashboards/UrlInputList.tsx b/src/components/dashboards/UrlInputList.tsx new file mode 100644 index 0000000..1d0fb3d --- /dev/null +++ b/src/components/dashboards/UrlInputList.tsx @@ -0,0 +1,24 @@ +import { UrlInputListProps } from "@/src/types"; +import UrlInputItem from "./UrlInputItem"; + +const UrlInputList = ({ + urlDatas, + visibleFields, + setVisibleFields, +}: UrlInputListProps) => { + return ( + <> + {urlDatas.slice(0, visibleFields).map((item, index) => ( + setVisibleFields((prev) => prev - 1)} + /> + ))} + + ); +}; + +export default UrlInputList; diff --git a/src/hooks/useUrlInput.ts b/src/hooks/useUrlInput.ts new file mode 100644 index 0000000..e69de29 diff --git a/src/types/index.ts b/src/types/index.ts index defd41c..e7f8ea6 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -5,6 +5,7 @@ import { profileSchema } from "../app/validation/profile.schema"; import { Session } from "next-auth"; import { NextResponse } from "next/server"; import { analyzeSchema } from "../app/validation/analyze.schema"; +import { FieldError, UseFormRegisterReturn } from "react-hook-form"; export interface ModelDB { modelName: string; @@ -19,7 +20,7 @@ export interface ModelDB { export interface ProfileClientProps { name: string; bio?: string; - preferenceBrand: string + preferenceBrand: string; preferenceOS: string; budgetMin: number; budgetMax: number; @@ -371,4 +372,23 @@ export interface AnalysisWithMetric { metricId: number; name: string; } | null; -} \ No newline at end of file +} + +type UrlData = { + labels: string; + errors: FieldError | undefined; + title: UseFormRegisterReturn; +}; + +export type UrlInputItemProps = { + item: UrlData; + index: number; + visibleFields: number; + onRemove: () => void; +}; + +export type UrlInputListProps = { + urlDatas: UrlData[]; + visibleFields: number; + setVisibleFields: React.Dispatch>; +};