Skip to content

Commit

Permalink
refactor: use type declaration file
Browse files Browse the repository at this point in the history
  • Loading branch information
moolmin committed Nov 18, 2024
1 parent db10945 commit a340e32
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 79 deletions.
12 changes: 1 addition & 11 deletions src/app/(pages)/4q-create/_components/second.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,12 @@ import { generatePhotoImg } from "@/service/photo_api";
import { getShortenUrl } from "@/service/shorten_api";
import tagArrow from "../../../../../public/images/tag_arrow.png";
import tagTranslationMap from "@/lib/tagTranslationEnKr";
import { FormData } from "@/types/form-data";

message.config({
maxCount: 3,
});

interface FormData {
url: string;
shortenUrl: string;
title: string;
backgroundImageUrl: string;
backgroundImagId: number;
shortenUrlId: number;
tags: string[];
category: string;
}


export default function Second() {
const [emblaRef, emblaApi] = useEmblaCarousel({
Expand Down
25 changes: 4 additions & 21 deletions src/app/(pages)/4q-create/_components/third.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { generateTicket } from "@/service/photo_api";
import Lottie from "react-lottie-player";
import loadingLottie from "../../../../../public/rotties/image-loading.json";
import type { Stage as StageType } from "konva/lib/Stage";
import { FormData } from "@/types/form-data";

interface TextNode {
id: number;
Expand All @@ -21,33 +22,15 @@ interface TextNode {
color: string;
}

interface FormData {
url: string;
shortenUrl: string;
title: string;
backgroundImageUrl: string;
backgroundImageId: number;
shortenUrlId: number;
tags: string[];
category: string;
}

export default function Third() {
const [qrPosition, setQrPosition] = useState({ x: 50, y: 50 });
const [textNodes, setTextNodes] = useState<TextNode[]>([]);
const [selectedId, setSelectedId] = useState<number | null>(null);
const [selectedColor, setSelectedColor] = useState<string>("#000000");
const [qrImageUrl, setQrImageUrl] = useState<string>("");
const [storedFormData, setStoredFormData] = useState<FormData>({
url: "",
title: "",
shortenUrl: "",
backgroundImageUrl: "",
backgroundImageId: 0,
shortenUrlId: 0,
tags: [],
category: "",
});
const [storedFormData, setStoredFormData] = useState<FormData>(
{} as FormData
);
const [shortenUrl, setShortenUrl] = useState<string>("");
const stageRef = useRef<StageType>(null);
const qrImageRef = useRef<Konva.Image>(null);
Expand Down
12 changes: 1 addition & 11 deletions src/app/(pages)/4q-gallery/_components/detail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,7 @@ import { FaArrowLeft } from "react-icons/fa6";
import { Button, Divider } from "antd";
import CreateContainer from "./create-container";
import { PiFolderOpenDuotone, PiCalendarBlankDuotone } from "react-icons/pi";

type Item = {
imageId: number;
userName: string;
url: string;
likeCount: number;
tags: string[];
categoryName: string;
createdAt: string;
liked: boolean;
};
import { Item } from "@/types/item";

type DetailProps = {
item: Item;
Expand Down
12 changes: 1 addition & 11 deletions src/app/(pages)/4q-gallery/_components/item-card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,7 @@ import { likeImage, unlikeImage } from "@/service/photo_api";
import Lottie from "react-lottie-player";
import heartLottie from "../../../../../public/rotties/heart-lottie.json";
import Image from "next/image";

type Item = {
imageId: number;
userName: string;
url: string;
likeCount: number;
tags: string[];
categoryName: string;
createdAt: string;
liked: boolean;
};
import { Item } from "@/types/item";

type ItemCardProps = {
item: Item;
Expand Down
12 changes: 1 addition & 11 deletions src/app/(pages)/4q-gallery/_components/item-container.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,7 @@ import ItemCard from "./item-card";
import { getGalleryData } from "@/service/photo_api";
import { Button } from "antd";
import { BounceDot } from "basic-loading";

type Item = {
createdAt: string;
imageId: number;
likeCount: number;
userName: string;
categoryName: string;
url: string;
tags: string[];
liked: boolean;
};
import { Item } from "@/types/item";

type GalleryPage = {
content: Item[];
Expand Down
14 changes: 2 additions & 12 deletions src/app/(pages)/4q-gallery/_components/second.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import Lottie from "react-lottie-player";
import loadingLottie from "../../../../../public/rotties/image-loading.json";
import type { Stage as StageType } from "konva/lib/Stage";
import { isMobile } from "react-device-detect";
import { FormData } from "@/types/form-data";

interface TextNode {
id: number;
Expand All @@ -22,17 +23,6 @@ interface TextNode {
color: string;
}

interface FormData {
url: string;
shortenUrl: string;
title: string;
backgroundImageUrl: string;
backgroundImageId: number;
shortenUrlId: number;
tags: string;
category: string;
}

export default function Third() {
const [qrPosition, setQrPosition] = useState({ x: 50, y: 50 });
const [textNodes, setTextNodes] = useState<TextNode[]>([]);
Expand All @@ -46,7 +36,7 @@ export default function Third() {
backgroundImageUrl: "",
backgroundImageId: 0,
shortenUrlId: 0,
tags: "",
tags: [],
category: "",
});
const [shortenUrl, setShortenUrl] = useState<string>("");
Expand Down
2 changes: 1 addition & 1 deletion src/app/(pages)/4q-gallery/page.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// page.tsx
"use client";
export const dynamic = "force-dynamic";
import React, { useState, useCallback, Suspense } from "react";
import React, { useState, Suspense } from "react";
import { useSearchParams } from "next/navigation";
import Container from "./_components/item-container";
import "react-horizontal-scrolling-menu/dist/styles.css";
Expand Down
1 change: 0 additions & 1 deletion src/service/ReactQueryClientProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import React from 'react';

// Create a client
const queryClient = new QueryClient();

export const ReactQueryClientProvider = ({ children }: { children: React.ReactNode }) => {
Expand Down
10 changes: 10 additions & 0 deletions src/types/form-data.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export interface FormData {
url: string;
shortenUrl: string;
title: string;
backgroundImageUrl: string;
backgroundImageId: number;
shortenUrlId: number;
tags: string[];
category: string;
}
10 changes: 10 additions & 0 deletions src/types/item.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export interface Item {
imageId: number;
userName: string;
url: string;
likeCount: number;
tags: string[];
categoryName: string;
createdAt: string;
liked: boolean;
}

0 comments on commit a340e32

Please sign in to comment.