Skip to content

Commit

Permalink
hompage fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
wldnd9904 committed Aug 5, 2024
1 parent 3d64b82 commit 55739e9
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 9 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"react-dom": "^18.2.0",
"swiper": "^11.1.3"
},
"homepage": "https://bam-j.github.io/pages/",
"homepage": "https://hanaro-trip-together-bank.github.io/TripTogether-front/",
"devDependencies": {
"@chromatic-com/storybook": "^1.4.0",
"@storybook/addon-essentials": "^8.1.1",
Expand Down
8 changes: 5 additions & 3 deletions src/hooks/useFetch.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
/* eslint-disable react-hooks/exhaustive-deps */
import { useEffect, useState } from "react";
import useToggle from "./useToggle";
Expand All @@ -14,17 +15,18 @@ type FetchMethod = "GET" | "POST" | "PUT" | "DELETE";

export function useFetch<RequestDtoType, ResponseDtoType>(
uri: string,
method: FetchMethod,
requestData: RequestDtoType | null = null
_method: FetchMethod,
_requestData: RequestDtoType | null = null
) {
const { blocked } = useCommunicationBlock();
const [isLoading, setIsLoading] = useState(false);
const [error, setError] = useState<string>("");
const [error] = useState<string>("");
const [data, setData] = useState<ResponseDtoType>();
const [trigger, toggleTrigger] = useToggle();

//데모용 fetch
useEffect(() => {
if (blocked || !uri) return;
setIsLoading(true);
setTimeout(() => {
console.log(replaceNumbersWithZero(uri));
Expand Down
10 changes: 6 additions & 4 deletions src/hooks/useFetchTrigger.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
import { useState } from "react";
import demoData from "../utils/demoData";
import replaceNumbersWithZero from "../utils/replaceNumberWithZero";
Expand All @@ -10,19 +11,20 @@ type FetchMethod = "GET" | "POST" | "PUT" | "DELETE";
// 이후 useEffect를 통해 처리 로직 만들면 됨
// ex) useEffect(()=>{ if(data) alert(data) },[data]);

export function useFetchTrigger<RequestDtoType, ResponseDtoType>(
export function useFetchTrigger<_RequestDtoType, ResponseDtoType>(
uri: string,
method: FetchMethod
_method: FetchMethod
) {
const [isLoading, setIsLoading] = useState(false);
const [error, setError] = useState<string>();
const [error] = useState<string>();
const [data, setData] = useState<ResponseDtoType>();
const [controller] = useState(new AbortController());

const abort = () => controller.abort();

//데모용 trigger
const trigger = () => {
const trigger = (a: unknown = "") => {
console.log(a);
setIsLoading(true);
setTimeout(() => {
setData(demoData[replaceNumbersWithZero(uri)] as ResponseDtoType);
Expand Down
2 changes: 1 addition & 1 deletion src/pages/SelectCountryPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export default function SelectCountryPage({ info }: SelectCountryPageProps) {
);

useEffect(() => {
countriesFetch.trigger(null);
countriesFetch.trigger();
}, [selected]);

useEffect(() => {
Expand Down

0 comments on commit 55739e9

Please sign in to comment.