Skip to content

Commit

Permalink
Merge pull request #154 from kakao-tech-campus-2nd-step3/revert-153-f…
Browse files Browse the repository at this point in the history
…eature/footer_리펙토링-#146

Revert "Feature/footer 리펙토링 #146"
  • Loading branch information
jasper200207 authored Nov 19, 2024
2 parents a90709f + d20aa61 commit f347805
Show file tree
Hide file tree
Showing 53 changed files with 513 additions and 1,112 deletions.
4 changes: 2 additions & 2 deletions src/api/axiosInstance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ const needAuthDefaultApi = axios.create({
baseURL: process.env.REACT_APP_API_URL,
headers: {
"Content-Type": "application/json",
Authorization: JSON.parse(localStorage.getItem("poomasi-user") || "{}")?.token
? `Bearer ${JSON.parse(localStorage.getItem("poomasi-user") || "{}").token}`
Authorization: JSON.parse(localStorage.getItem("poomasi_user") || "{}")?.token
? `Bearer ${JSON.parse(localStorage.getItem("poomasi_user") || "{}").token}`
: undefined,
},
withCredentials: true,
Expand Down
4 changes: 2 additions & 2 deletions src/api/businessApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ const useCreateBusiness = () => {
return useMutation({ mutationFn: fetcher });
};

const useGetBusiness = () => null;
const useGetBusinessDetail = () => null;

export { useCreateBusiness, useGetBusiness };
export { useCreateBusiness, useGetBusinessDetail };
38 changes: 3 additions & 35 deletions src/api/emailApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,11 @@ type LoginData = {
password: string;
};

type FarmerRegisterData = {
type FarmerData = {
name: string;
address: string;
phone: string;
};

type FarmerData = {
name: string;
email: string;
password: string;
phoneNumber: string;
storeName: string;
storeAddress: string;
};

type AddressData = {
defaultAddress: string;
addressDetail: string;
Expand All @@ -49,7 +39,7 @@ const useLoginEmail = () => {
};

const useCreateFarmer = () => {
const fetcher = (farmerData: FarmerRegisterData) =>
const fetcher = (farmerData: FarmerData) =>
needAuthDefaultApi.put(`/api/members/to-farmer`, farmerData).then(({ data }) => data);
return useMutation({ mutationFn: fetcher });
};
Expand All @@ -68,20 +58,6 @@ const useUpdateEmail = () => {
});
};

const useUpdateFarmer = () => {
const queryClient = useQueryClient();
const fetcher = (updateData: FarmerData) =>
needAuthDefaultApi.put(`/api/members/update/farmer`, updateData).then(({ data }) => data);

return useMutation({
mutationFn: fetcher,
onSuccess: () =>
queryClient.invalidateQueries({
queryKey: ["farmer"],
}),
});
};

const useUpdateAddress = () => {
const queryClient = useQueryClient();
const fetcher = (updateData: AddressData) =>
Expand All @@ -106,12 +82,4 @@ const useDeleteAccount = () => {
});
};

export {
useCreateEmail,
useLoginEmail,
useUpdateEmail,
useUpdateAddress,
useCreateFarmer,
useUpdateFarmer,
useDeleteAccount,
};
export { useCreateEmail, useLoginEmail, useUpdateEmail, useUpdateAddress, useCreateFarmer, useDeleteAccount };
58 changes: 2 additions & 56 deletions src/api/farmApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,6 @@ type FarmData = {
endTime: string;
};

type ReservationData = {
farmId: number;
startTime: string;
endTime: string;
date: ["startDate", "endDate"];
};

const useGetFarm = () => {
const fetcher = () => defaultApi.get(`/api/farms/{farmId}/detail`).then(({ data }) => data);

return useQuery({
queryKey: ["farms"],
queryFn: fetcher,
});
};

const useGetFarms = () => {
const fetcher = () => defaultApi.get(`/api/farms`).then(({ data }) => data);

Expand All @@ -53,7 +37,7 @@ const useGetFarmDetail = (farmId: number) => {
};

const useCreateFarms = () => {
const fetcher = (farmData: FarmData) => defaultApi.post(`/api/farmer/farms`, farmData).then(({ data }) => data);
const fetcher = (farmData: FarmData) => defaultApi.post(`/api/farms`, farmData).then(({ data }) => data);

return useMutation({ mutationFn: fetcher });
};
Expand All @@ -73,42 +57,4 @@ const useUpdateFarms = (farmId: number) => {
});
};

const useDeleteFarms = (farmId: number) => {
const queryClient = useQueryClient();

const fetcher = () => defaultApi.delete(`/api/farmer/farms/${farmId}`).then(({ data }) => data);

return useMutation({
mutationFn: fetcher,
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: ["farms"] });
},
});
};

const useCreateReservations = () => {
const fetcher = (reservationData: ReservationData) =>
defaultApi.post(`/api/farms/schedule`, reservationData).then(({ data }) => data);

return useMutation({ mutationFn: fetcher });
};

const useGetReservations = (farmId: number) => {
const fetcher = () => defaultApi.get(`/api/farms/schedule?farmId=17&year=2024&month=10`).then(({ data }) => data);

return useQuery({
queryKey: ["reservations", farmId],
queryFn: fetcher,
});
};

export {
useGetFarm,
useGetFarms,
useGetFarmDetail,
useCreateFarms,
useUpdateFarms,
useDeleteFarms,
useCreateReservations,
useGetReservations,
};
export { useGetFarms, useGetFarmDetail, useCreateFarms, useUpdateFarms };
4 changes: 2 additions & 2 deletions src/api/intercepters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ const refrechIntercepter = async (response: AxiosResponse): Promise<AxiosRespons
alert("로그아웃 되었습니다. 다시 로그인해주세요.");
window.location.href = "/";
});
const user = JSON.parse(localStorage.getItem("poomasi-user") || "{}");
const user = JSON.parse(localStorage.getItem("poomasi_user") || "{}");

localStorage.setItem(
"poomasi-user",
"poomasi_user",
JSON.stringify({
...user,
token: result,
Expand Down
8 changes: 1 addition & 7 deletions src/api/productApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,12 @@ type ProductData = {
categoryId: number;
name: string;
description: string;
imageUrl: string;
stock: string;
price: string;
growEnv: string;
shippingFee: string;
phoneNumber: string;
mainTitle: string;
subTitle1: string;
subDesc1: string;
subTitle2: string;
subDesc2: string;
subTitle3: string;
subDesc3: string;
};

const useGetProducts = () => {
Expand Down
80 changes: 0 additions & 80 deletions src/api/reviewApi.ts

This file was deleted.

30 changes: 0 additions & 30 deletions src/api/storeApi.ts

This file was deleted.

30 changes: 0 additions & 30 deletions src/api/wishlistApi.ts

This file was deleted.

4 changes: 2 additions & 2 deletions src/atoms/userAtom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ type UserAtomValue = {
role: string;
};

const userAtom = atom(localStorage.getItem("poomasi-user") ?? "");
const userAtom = atom(localStorage.getItem("poomasi_user") ?? "");

const userAtomWithPersistence = atom(
get => {
Expand All @@ -16,7 +16,7 @@ const userAtomWithPersistence = atom(
},
(_, set, data: UserAtomValue | null) => {
set(userAtom, JSON.stringify(data));
localStorage.setItem("poomasi-user", JSON.stringify(data));
localStorage.setItem("poomasi_user", JSON.stringify(data));
},
);

Expand Down
2 changes: 1 addition & 1 deletion src/components/common/KaKaoLoginButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Image from "@components/common/Image";
type KaKaoLoginButtonProps = ImageProps;

const KaKaoLoginButton = ({ ...props }: KaKaoLoginButtonProps) => {
const link = `${process.env.REACT_APP_API_URL}/oauth2/authentication/kakao`;
const link = "https://api.poomasi.shop/oauth2/authentication/kakao";

return (
<Link href={link} isExternal>
Expand Down
Loading

0 comments on commit f347805

Please sign in to comment.