From e2e89977ce36e8501fa3a1dbd3365adf59414fb3 Mon Sep 17 00:00:00 2001 From: teegoood Date: Mon, 13 May 2024 18:03:26 +0700 Subject: [PATCH 01/16] fix: assets URI get blocked by adblocker --- src/app/home/page.tsx | 6 ++++-- src/assets/{ads => banners}/1.webp | Bin src/assets/{ads => banners}/10.webp | Bin src/assets/{ads => banners}/11.webp | Bin src/assets/{ads => banners}/2.webp | Bin src/assets/{ads => banners}/3.webp | Bin src/assets/{ads => banners}/4.webp | Bin src/assets/{ads => banners}/5.webp | Bin src/assets/{ads => banners}/6.webp | Bin src/assets/{ads => banners}/7.webp | Bin src/assets/{ads => banners}/8.webp | Bin src/assets/{ads => banners}/9.webp | Bin src/components/Main/Banner.tsx | 22 +++++++++++----------- 13 files changed, 15 insertions(+), 13 deletions(-) rename src/assets/{ads => banners}/1.webp (100%) rename src/assets/{ads => banners}/10.webp (100%) rename src/assets/{ads => banners}/11.webp (100%) rename src/assets/{ads => banners}/2.webp (100%) rename src/assets/{ads => banners}/3.webp (100%) rename src/assets/{ads => banners}/4.webp (100%) rename src/assets/{ads => banners}/5.webp (100%) rename src/assets/{ads => banners}/6.webp (100%) rename src/assets/{ads => banners}/7.webp (100%) rename src/assets/{ads => banners}/8.webp (100%) rename src/assets/{ads => banners}/9.webp (100%) diff --git a/src/app/home/page.tsx b/src/app/home/page.tsx index 6b4d329e..8e07c641 100644 --- a/src/app/home/page.tsx +++ b/src/app/home/page.tsx @@ -43,6 +43,8 @@ const MainPage = () => { maxAge: 30, }); const { data, isLoading } = usePetsQuery(filters); + console.log(data); + return ( <> @@ -53,7 +55,7 @@ const MainPage = () => {
- +
@@ -63,7 +65,7 @@ const MainPage = () => { - +
diff --git a/src/assets/ads/1.webp b/src/assets/banners/1.webp similarity index 100% rename from src/assets/ads/1.webp rename to src/assets/banners/1.webp diff --git a/src/assets/ads/10.webp b/src/assets/banners/10.webp similarity index 100% rename from src/assets/ads/10.webp rename to src/assets/banners/10.webp diff --git a/src/assets/ads/11.webp b/src/assets/banners/11.webp similarity index 100% rename from src/assets/ads/11.webp rename to src/assets/banners/11.webp diff --git a/src/assets/ads/2.webp b/src/assets/banners/2.webp similarity index 100% rename from src/assets/ads/2.webp rename to src/assets/banners/2.webp diff --git a/src/assets/ads/3.webp b/src/assets/banners/3.webp similarity index 100% rename from src/assets/ads/3.webp rename to src/assets/banners/3.webp diff --git a/src/assets/ads/4.webp b/src/assets/banners/4.webp similarity index 100% rename from src/assets/ads/4.webp rename to src/assets/banners/4.webp diff --git a/src/assets/ads/5.webp b/src/assets/banners/5.webp similarity index 100% rename from src/assets/ads/5.webp rename to src/assets/banners/5.webp diff --git a/src/assets/ads/6.webp b/src/assets/banners/6.webp similarity index 100% rename from src/assets/ads/6.webp rename to src/assets/banners/6.webp diff --git a/src/assets/ads/7.webp b/src/assets/banners/7.webp similarity index 100% rename from src/assets/ads/7.webp rename to src/assets/banners/7.webp diff --git a/src/assets/ads/8.webp b/src/assets/banners/8.webp similarity index 100% rename from src/assets/ads/8.webp rename to src/assets/banners/8.webp diff --git a/src/assets/ads/9.webp b/src/assets/banners/9.webp similarity index 100% rename from src/assets/ads/9.webp rename to src/assets/banners/9.webp diff --git a/src/components/Main/Banner.tsx b/src/components/Main/Banner.tsx index cddc13a9..ef667e3b 100644 --- a/src/components/Main/Banner.tsx +++ b/src/components/Main/Banner.tsx @@ -1,14 +1,14 @@ -import adsImage1 from "@/assets/ads/1.webp"; -import adsImage10 from "@/assets/ads/10.webp"; -import adsImage11 from "@/assets/ads/11.webp"; -import adsImage2 from "@/assets/ads/2.webp"; -import adsImage3 from "@/assets/ads/3.webp"; -import adsImage4 from "@/assets/ads/4.webp"; -import adsImage5 from "@/assets/ads/5.webp"; -import adsImage6 from "@/assets/ads/6.webp"; -import adsImage7 from "@/assets/ads/7.webp"; -import adsImage8 from "@/assets/ads/8.webp"; -import adsImage9 from "@/assets/ads/9.webp"; +import adsImage1 from "@/assets/banners/1.webp"; +import adsImage10 from "@/assets/banners/10.webp"; +import adsImage11 from "@/assets/banners/11.webp"; +import adsImage2 from "@/assets/banners/2.webp"; +import adsImage3 from "@/assets/banners/3.webp"; +import adsImage4 from "@/assets/banners/4.webp"; +import adsImage5 from "@/assets/banners/5.webp"; +import adsImage6 from "@/assets/banners/6.webp"; +import adsImage7 from "@/assets/banners/7.webp"; +import adsImage8 from "@/assets/banners/8.webp"; +import adsImage9 from "@/assets/banners/9.webp"; import { Icon } from "@iconify/react"; import React from "react"; import { Carousel } from "react-responsive-carousel"; From 67c02177e92797b96103557215f11694e3107d6d Mon Sep 17 00:00:00 2001 From: teegoood Date: Tue, 14 May 2024 18:12:31 +0700 Subject: [PATCH 02/16] add: adopt pop up --- src/app/home/page.tsx | 2 +- src/app/pets/[id]/adopt/page.tsx | 56 +++++++++++-------- src/components/Card/PetCard/index.tsx | 2 +- .../Pets/TermsAndConditions/index.tsx | 56 ++++++++++++++++--- src/hooks/auth/useForgetPassword.ts | 4 +- src/hooks/auth/useSignIn.ts | 2 +- src/hooks/auth/useSignOut.ts | 2 +- 7 files changed, 85 insertions(+), 39 deletions(-) diff --git a/src/app/home/page.tsx b/src/app/home/page.tsx index 8e07c641..05beb1b6 100644 --- a/src/app/home/page.tsx +++ b/src/app/home/page.tsx @@ -43,7 +43,7 @@ const MainPage = () => { maxAge: 30, }); const { data, isLoading } = usePetsQuery(filters); - console.log(data); + // console.log(data); return ( <> diff --git a/src/app/pets/[id]/adopt/page.tsx b/src/app/pets/[id]/adopt/page.tsx index e0b2ae41..d517b3cd 100644 --- a/src/app/pets/[id]/adopt/page.tsx +++ b/src/app/pets/[id]/adopt/page.tsx @@ -5,8 +5,11 @@ import TermsAndConditions from "@/components/Pets/TermsAndConditions"; import { usePetQuery } from "@/hooks/queries/usePetQuery"; import { usePageParams } from "@/hooks/usePageParams"; import MainLayout from "@/layouts/MainLayout"; +import { Pet } from "@/types/pets"; import { Icon } from "@iconify/react/dist/iconify.js"; -import { useMemo } from "react"; +import { createContext, useMemo } from "react"; + +export const PetContext = createContext(null); const AdoptionPage = () => { const param = usePageParams(["id"]); @@ -18,34 +21,39 @@ const AdoptionPage = () => { }, [data?.images]); return ( data && ( - -
- -
-
-

- {data.name} -

-
+ + +
+ +
+
+

+ {data.name} +

+
+
-
-
- -
-
-

- {data.name} -

-
+
+ +
+
+

+ {data.name} +

+
+
+
-
-
- + + ) ); }; diff --git a/src/components/Card/PetCard/index.tsx b/src/components/Card/PetCard/index.tsx index 717909e2..b4245ffd 100644 --- a/src/components/Card/PetCard/index.tsx +++ b/src/components/Card/PetCard/index.tsx @@ -98,7 +98,7 @@ const PetCard = ({ addToFavorites(id); } setLiked((prev) => !prev); - console.log("liked : " + id); + // console.log("liked : " + id); }; const handleAdopt = (event: React.MouseEvent) => { diff --git a/src/components/Pets/TermsAndConditions/index.tsx b/src/components/Pets/TermsAndConditions/index.tsx index d563de5b..d86db46f 100644 --- a/src/components/Pets/TermsAndConditions/index.tsx +++ b/src/components/Pets/TermsAndConditions/index.tsx @@ -1,10 +1,13 @@ +import { PetContext } from "@/app/pets/[id]/adopt/page"; import Button from "@/components/Button"; import Modal from "@/components/Modal"; -import { useState } from "react"; +import { useContext, useState } from "react"; import { Link } from "react-router-dom"; const TermsAndConditions = () => { const [open, setOpen] = useState(false); + const pet = useContext(PetContext); + // console.log(pet) return ( <> @@ -61,24 +64,59 @@ const TermsAndConditions = () => {
+ pet?.origin == "club" ? ( + +
-
+
{/* Gender */} { />
+
+ + ติดต่อเจ้าของ + +
    +
  • + ชื่อ: + + + {showInfo?.nature || "-"} + +
  • +
  • + เบอร์: + + + {showInfo?.nature || "-"} + +
  • +
  • + ไอดีไลน์: + + + {showInfo?.nature || "-"} + +
  • +
+
+
{/* Vaccine */} From cb584587ace719a46afaa730185ed9ba18ceb8c1 Mon Sep 17 00:00:00 2001 From: teegoood Date: Tue, 14 May 2024 19:08:08 +0700 Subject: [PATCH 05/16] use gird --- src/components/Pets/TermsAndConditions/index.tsx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/components/Pets/TermsAndConditions/index.tsx b/src/components/Pets/TermsAndConditions/index.tsx index d86db46f..3ce1533b 100644 --- a/src/components/Pets/TermsAndConditions/index.tsx +++ b/src/components/Pets/TermsAndConditions/index.tsx @@ -97,21 +97,21 @@ const TermsAndConditions = () => {

) : (
    -
  • +
  • ชื่อ: - + {pet?.adopt_by || "-"}
  • -
  • +
  • เบอร์: - + {pet?.adopt_by || "-"}
  • -
  • +
  • ไอดีไลน์: - + {pet?.adopt_by || "-"}
  • From 2e1ab4537a187f68aaa5d71fc8ceb6e3041d4522 Mon Sep 17 00:00:00 2001 From: teegoood Date: Tue, 14 May 2024 19:21:01 +0700 Subject: [PATCH 06/16] add: contact state --- .../Admin/Pets/Add/EditInfoAndSubmit.tsx | 42 ++++++++++--------- .../Admin/Pets/Add/TextInputInfo.tsx | 6 ++- src/components/Pets/Details/Details.tsx | 6 +++ 3 files changed, 32 insertions(+), 22 deletions(-) diff --git a/src/components/Admin/Pets/Add/EditInfoAndSubmit.tsx b/src/components/Admin/Pets/Add/EditInfoAndSubmit.tsx index c02ffaa3..752029cc 100644 --- a/src/components/Admin/Pets/Add/EditInfoAndSubmit.tsx +++ b/src/components/Admin/Pets/Add/EditInfoAndSubmit.tsx @@ -16,6 +16,9 @@ export type info = { nature: string; vaccine: boolean; sterile: boolean; + address: string; + contact: string; + adopt_by: string; }; interface EditInfoAndSubmitProps { @@ -198,28 +201,27 @@ const EditInfoAndSubmit = (props: EditInfoAndSubmitProps) => { ติดต่อเจ้าของ -
      -
    • - ชื่อ: - - - {showInfo?.nature || "-"} - -
    • -
    • - เบอร์: +
        + handleOnChangeTextArea(event, "adopt_by")} + /> - - {showInfo?.nature || "-"} - - -
      • - ไอดีไลน์: + handleOnChangeTextArea(event, "contact")} + /> - - {showInfo?.nature || "-"} - -
      • + handleOnChangeTextArea(event, "address")} + />
      diff --git a/src/components/Admin/Pets/Add/TextInputInfo.tsx b/src/components/Admin/Pets/Add/TextInputInfo.tsx index aba0b459..7058cffc 100644 --- a/src/components/Admin/Pets/Add/TextInputInfo.tsx +++ b/src/components/Admin/Pets/Add/TextInputInfo.tsx @@ -6,14 +6,16 @@ interface TextInputInfoProps { value: string; enableEdit: boolean; onChange: (event: React.FormEvent) => void; - icon: string; + icon?: string; } const TextInputInfo = (props: TextInputInfoProps) => { return (
      - + {props.icon && ( + + )} {props.text}
      { nature: "-", vaccine: false, sterile: false, + address: "-", + adopt_by: "-", + contact: "-" }); const convertImgToFile = async (imgFilePath: string) => { @@ -91,6 +94,9 @@ const Details = (props: DetailsProps) => { nature: props.data.habit, vaccine: props.data.is_vaccinated, sterile: props.data.is_sterile, + adopt_by: props.data.adopt_by, + contact: props.data.contact, + address: props.data.address, }); }, [props.data, id]); From 1609e49a3bdfc0134ed744911977cb8681b08970 Mon Sep 17 00:00:00 2001 From: teegoood Date: Thu, 16 May 2024 09:43:51 +0700 Subject: [PATCH 07/16] data pop up --- src/app/pets/[id]/adopt/page.tsx | 1 + src/components/Pets/TermsAndConditions/index.tsx | 8 ++++---- src/types/pets.ts | 4 ++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/app/pets/[id]/adopt/page.tsx b/src/app/pets/[id]/adopt/page.tsx index d517b3cd..da335c8c 100644 --- a/src/app/pets/[id]/adopt/page.tsx +++ b/src/app/pets/[id]/adopt/page.tsx @@ -14,6 +14,7 @@ export const PetContext = createContext(null); const AdoptionPage = () => { const param = usePageParams(["id"]); const { data } = usePetQuery(param.id); + console.log(data); const petImagesArray = useMemo(() => { if (!data?.images) return [dog]; diff --git a/src/components/Pets/TermsAndConditions/index.tsx b/src/components/Pets/TermsAndConditions/index.tsx index 3ce1533b..0d0eee97 100644 --- a/src/components/Pets/TermsAndConditions/index.tsx +++ b/src/components/Pets/TermsAndConditions/index.tsx @@ -7,7 +7,7 @@ import { Link } from "react-router-dom"; const TermsAndConditions = () => { const [open, setOpen] = useState(false); const pet = useContext(PetContext); - // console.log(pet) + console.log(pet) return ( <> @@ -100,19 +100,19 @@ const TermsAndConditions = () => {
    • ชื่อ: - {pet?.adopt_by || "-"} + {pet?.owner || "-"}
    • เบอร์: - {pet?.adopt_by || "-"} + {pet?.tel || "-"}
    • ไอดีไลน์: - {pet?.adopt_by || "-"} + {pet?.contact || "-"}
    diff --git a/src/types/pets.ts b/src/types/pets.ts index 23d59875..a280a8f3 100644 --- a/src/types/pets.ts +++ b/src/types/pets.ts @@ -3,8 +3,8 @@ type Pet = { name: string; pattern: string; birthdate: string; - address: string; - adopt_by: string; + tel: string; + owner: string; caption: string; color: string; contact: string; From 0637449cae98ef6cf4eb3162c5aeb7647097945b Mon Sep 17 00:00:00 2001 From: teegoood Date: Thu, 16 May 2024 09:55:03 +0700 Subject: [PATCH 08/16] edit page --- src/api/pets.ts | 5 +---- .../Admin/Pets/Add/EditInfoAndSubmit.tsx | 16 ++++++++-------- src/components/Pets/Details/Details.tsx | 13 ++++++++----- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/api/pets.ts b/src/api/pets.ts index 295d3342..cdf7c98e 100644 --- a/src/api/pets.ts +++ b/src/api/pets.ts @@ -46,7 +46,7 @@ const getPetsAdmin = async (filters?: filterState) => { type postPetRequest = Omit< Pet, - "id" | "images" | "is_club_pet" | "address" | "adopt_by" | "contact" + "id" | "images" | "is_club_pet" | "contact" | "owner" | "contact" > & { images: string[]; // image id }; @@ -109,9 +109,6 @@ type PutPetRequest = Omit< | "is_club_pet" | "pattern" | "status" - | "address" - | "adopt_by" - | "contact" > & { origin: string; }; diff --git a/src/components/Admin/Pets/Add/EditInfoAndSubmit.tsx b/src/components/Admin/Pets/Add/EditInfoAndSubmit.tsx index 752029cc..065409b1 100644 --- a/src/components/Admin/Pets/Add/EditInfoAndSubmit.tsx +++ b/src/components/Admin/Pets/Add/EditInfoAndSubmit.tsx @@ -16,9 +16,9 @@ export type info = { nature: string; vaccine: boolean; sterile: boolean; - address: string; + tel: string; contact: string; - adopt_by: string; + owner: string; }; interface EditInfoAndSubmitProps { @@ -204,23 +204,23 @@ const EditInfoAndSubmit = (props: EditInfoAndSubmitProps) => {
      handleOnChangeTextArea(event, "adopt_by")} + onChange={(event) => handleOnChangeTextArea(event, "owner")} /> handleOnChangeTextArea(event, "contact")} + onChange={(event) => handleOnChangeTextArea(event, "tel")} /> handleOnChangeTextArea(event, "address")} + onChange={(event) => handleOnChangeTextArea(event, "contact")} />
    diff --git a/src/components/Pets/Details/Details.tsx b/src/components/Pets/Details/Details.tsx index 2cac38c9..ed7a18f2 100644 --- a/src/components/Pets/Details/Details.tsx +++ b/src/components/Pets/Details/Details.tsx @@ -50,9 +50,9 @@ const Details = (props: DetailsProps) => { nature: "-", vaccine: false, sterile: false, - address: "-", - adopt_by: "-", - contact: "-" + contact: "-", + owner: "-", + tel: "-" }); const convertImgToFile = async (imgFilePath: string) => { @@ -94,9 +94,9 @@ const Details = (props: DetailsProps) => { nature: props.data.habit, vaccine: props.data.is_vaccinated, sterile: props.data.is_sterile, - adopt_by: props.data.adopt_by, + owner: props.data.owner, + tel: props.data.tel, contact: props.data.contact, - address: props.data.address, }); }, [props.data, id]); @@ -168,6 +168,9 @@ const Details = (props: DetailsProps) => { is_vaccinated: petInfo.vaccine, is_visible: props.data.is_visible, origin: origin, + tel: petInfo.tel, + contact: petInfo.contact, + owner: petInfo.owner }; updatePetMutaion.mutate({ From 04872438bfaac22c17ee758ebe367d1966c4dc66 Mon Sep 17 00:00:00 2001 From: teegoood Date: Thu, 16 May 2024 10:05:35 +0700 Subject: [PATCH 09/16] add: @ in contact field --- src/components/Admin/Pets/Add/EditInfoAndSubmit.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/components/Admin/Pets/Add/EditInfoAndSubmit.tsx b/src/components/Admin/Pets/Add/EditInfoAndSubmit.tsx index 065409b1..e75e2792 100644 --- a/src/components/Admin/Pets/Add/EditInfoAndSubmit.tsx +++ b/src/components/Admin/Pets/Add/EditInfoAndSubmit.tsx @@ -218,7 +218,11 @@ const EditInfoAndSubmit = (props: EditInfoAndSubmitProps) => { handleOnChangeTextArea(event, "contact")} /> From 53a2a0ce7d366e9d3c8fc0b0d1978c51f59cee3b Mon Sep 17 00:00:00 2001 From: teegoood Date: Thu, 16 May 2024 10:08:33 +0700 Subject: [PATCH 10/16] lint:fix --- src/api/pets.ts | 6 +----- src/components/Pets/Details/Details.tsx | 4 ++-- src/components/Pets/TermsAndConditions/index.tsx | 8 ++++---- src/hooks/auth/useForgetPassword.ts | 4 ++-- src/hooks/auth/useSignIn.ts | 2 +- src/hooks/auth/useSignOut.ts | 2 +- 6 files changed, 11 insertions(+), 15 deletions(-) diff --git a/src/api/pets.ts b/src/api/pets.ts index cdf7c98e..76ea2a57 100644 --- a/src/api/pets.ts +++ b/src/api/pets.ts @@ -104,11 +104,7 @@ const deletePet = async (id: string) => { type PutPetRequest = Omit< Pet, - | "id" - | "images" - | "is_club_pet" - | "pattern" - | "status" + "id" | "images" | "is_club_pet" | "pattern" | "status" > & { origin: string; }; diff --git a/src/components/Pets/Details/Details.tsx b/src/components/Pets/Details/Details.tsx index ed7a18f2..903a9814 100644 --- a/src/components/Pets/Details/Details.tsx +++ b/src/components/Pets/Details/Details.tsx @@ -52,7 +52,7 @@ const Details = (props: DetailsProps) => { sterile: false, contact: "-", owner: "-", - tel: "-" + tel: "-", }); const convertImgToFile = async (imgFilePath: string) => { @@ -170,7 +170,7 @@ const Details = (props: DetailsProps) => { origin: origin, tel: petInfo.tel, contact: petInfo.contact, - owner: petInfo.owner + owner: petInfo.owner, }; updatePetMutaion.mutate({ diff --git a/src/components/Pets/TermsAndConditions/index.tsx b/src/components/Pets/TermsAndConditions/index.tsx index 0d0eee97..94f39cbd 100644 --- a/src/components/Pets/TermsAndConditions/index.tsx +++ b/src/components/Pets/TermsAndConditions/index.tsx @@ -7,7 +7,7 @@ import { Link } from "react-router-dom"; const TermsAndConditions = () => { const [open, setOpen] = useState(false); const pet = useContext(PetContext); - console.log(pet) + console.log(pet); return ( <> @@ -99,19 +99,19 @@ const TermsAndConditions = () => {
    • ชื่อ: - + {pet?.owner || "-"}
    • เบอร์: - + {pet?.tel || "-"}
    • ไอดีไลน์: - + {pet?.contact || "-"}
    • diff --git a/src/hooks/auth/useForgetPassword.ts b/src/hooks/auth/useForgetPassword.ts index b306997d..7cd9b23b 100644 --- a/src/hooks/auth/useForgetPassword.ts +++ b/src/hooks/auth/useForgetPassword.ts @@ -14,10 +14,10 @@ const useForgetPassword = () => { mutationFn: (credentials: ForgetPasswordCredentials) => forgetPassword(credentials.email), onSuccess: () => { - // console.log("forget password successful"); + console.log("forget password successful"); }, onError: (error: Error) => { - // console.log(error); + console.log(error); }, }; diff --git a/src/hooks/auth/useSignIn.ts b/src/hooks/auth/useSignIn.ts index e1ac34b3..13579729 100644 --- a/src/hooks/auth/useSignIn.ts +++ b/src/hooks/auth/useSignIn.ts @@ -19,7 +19,7 @@ const useSignIn = () => { navigate("/admin/pets"); }, onError: (error: Error) => { - // console.log(error); + console.log(error); }, }; diff --git a/src/hooks/auth/useSignOut.ts b/src/hooks/auth/useSignOut.ts index c65eb258..fd118e92 100644 --- a/src/hooks/auth/useSignOut.ts +++ b/src/hooks/auth/useSignOut.ts @@ -14,7 +14,7 @@ const useSignOut = () => { navigate("/admin"); }, onError: (error: Error) => { - // console.log(error); + console.log(error); clearAuth(); navigate("/admin"); }, From 4df91679b20e5927d429cf889a3d589aefde489a Mon Sep 17 00:00:00 2001 From: teegoood Date: Thu, 16 May 2024 11:13:43 +0700 Subject: [PATCH 11/16] fix: adopt thumbnail badge floating --- src/app/pets/[id]/adopt/page.tsx | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/app/pets/[id]/adopt/page.tsx b/src/app/pets/[id]/adopt/page.tsx index da335c8c..16d8b096 100644 --- a/src/app/pets/[id]/adopt/page.tsx +++ b/src/app/pets/[id]/adopt/page.tsx @@ -41,16 +41,20 @@ const AdoptionPage = () => {
-
- -
-
-

- {data.name} -

-
+
+
+ +
+
+
+
+

+ {data.name} +

+
+
+
-
From bb1ee4f84d58db0cff441931b026c8fec6f2f199 Mon Sep 17 00:00:00 2001 From: teegoood Date: Thu, 16 May 2024 11:14:31 +0700 Subject: [PATCH 12/16] fix: adopt thumbnail badge floating real --- src/app/pets/[id]/adopt/page.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app/pets/[id]/adopt/page.tsx b/src/app/pets/[id]/adopt/page.tsx index 16d8b096..68f20d14 100644 --- a/src/app/pets/[id]/adopt/page.tsx +++ b/src/app/pets/[id]/adopt/page.tsx @@ -42,10 +42,10 @@ const AdoptionPage = () => {
-
+
-
+

From f249b0f7fcb9192d13cd240a6fdb5ce90d83ca1f Mon Sep 17 00:00:00 2001 From: teegoood Date: Thu, 16 May 2024 11:39:33 +0700 Subject: [PATCH 13/16] fix: ensure payload data --- src/components/Pets/Details/Details.tsx | 21 +++++++++++---------- src/hooks/mutation/useDeleteImage.ts | 4 ++++ 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/components/Pets/Details/Details.tsx b/src/components/Pets/Details/Details.tsx index 903a9814..35428ebb 100644 --- a/src/components/Pets/Details/Details.tsx +++ b/src/components/Pets/Details/Details.tsx @@ -43,16 +43,16 @@ const Details = (props: DetailsProps) => { const [images, setImages] = useState([]); const [enableSubmit, setEnableSubmit] = useState(false); const [petInfo, setPetInfo] = useState({ - type: "-", - gender: "-", - color: "-", - age: "-", - nature: "-", - vaccine: false, - sterile: false, - contact: "-", - owner: "-", - tel: "-", + type: props.data.type as "dog" | "cat" | "-", + gender: props.data.gender, + color: props.data.color, + age: dayjs(props.data.birthdate).toISOString(), + nature: props.data.habit, + vaccine: props.data.is_vaccinated, + sterile: props.data.is_sterile, + owner: props.data.owner, + tel: props.data.tel, + contact: props.data.contact, }); const convertImgToFile = async (imgFilePath: string) => { @@ -140,6 +140,7 @@ const Details = (props: DetailsProps) => { try { deletedImages && (await Promise.all(deletedImages)); } catch (err) { + console.log(err); return; } diff --git a/src/hooks/mutation/useDeleteImage.ts b/src/hooks/mutation/useDeleteImage.ts index b640cad1..6f007381 100644 --- a/src/hooks/mutation/useDeleteImage.ts +++ b/src/hooks/mutation/useDeleteImage.ts @@ -1,5 +1,6 @@ import { deleteImage } from "@/api/images"; import { useMutation, useQueryClient } from "@tanstack/react-query"; +import toast from "react-hot-toast"; const useDeleteImage = () => { const queryClient = useQueryClient(); @@ -9,6 +10,9 @@ const useDeleteImage = () => { onSuccess: () => { queryClient.invalidateQueries({ queryKey: ["pet"] }); }, + onError: () => { + toast.error("มีบางอย่างผิดพลาด"); + } }); }; From e42b3ed54db005935b950ab6ac83080a13e1ec0c Mon Sep 17 00:00:00 2001 From: teegoood Date: Thu, 16 May 2024 11:58:35 +0700 Subject: [PATCH 14/16] fix: user save unsave info --- src/api/pets.ts | 2 +- src/app/admin/pets/add/page.tsx | 6 ++++++ src/components/Admin/Pets/Add/EditInfoAndSubmit.tsx | 4 ++-- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/api/pets.ts b/src/api/pets.ts index 76ea2a57..2423325e 100644 --- a/src/api/pets.ts +++ b/src/api/pets.ts @@ -46,7 +46,7 @@ const getPetsAdmin = async (filters?: filterState) => { type postPetRequest = Omit< Pet, - "id" | "images" | "is_club_pet" | "contact" | "owner" | "contact" + "id" | "images" | "is_club_pet" > & { images: string[]; // image id }; diff --git a/src/app/admin/pets/add/page.tsx b/src/app/admin/pets/add/page.tsx index 02d740dc..6b78d2d1 100644 --- a/src/app/admin/pets/add/page.tsx +++ b/src/app/admin/pets/add/page.tsx @@ -35,6 +35,9 @@ const adminCreate = () => { nature: "-", vaccine: false, sterile: false, + owner: "-", + tel: "-", + contact: "-", }); const [enableSubmit, setEnableSubmit] = useState(false); @@ -91,6 +94,9 @@ const adminCreate = () => { is_visible: true, origin: `${origin === "fromClub" ? "club" : "entrust"}`, images: allImage, + tel: info.tel, + contact: info.contact, + owner: info.owner, }; postPetMutation.mutate(petData); diff --git a/src/components/Admin/Pets/Add/EditInfoAndSubmit.tsx b/src/components/Admin/Pets/Add/EditInfoAndSubmit.tsx index e75e2792..058429da 100644 --- a/src/components/Admin/Pets/Add/EditInfoAndSubmit.tsx +++ b/src/components/Admin/Pets/Add/EditInfoAndSubmit.tsx @@ -262,9 +262,9 @@ const EditInfoAndSubmit = (props: EditInfoAndSubmitProps) => {

From 53fe80fbceb2734c1b8b56928fac7c5923fe3aa6 Mon Sep 17 00:00:00 2001 From: teegoood Date: Thu, 16 May 2024 12:01:10 +0700 Subject: [PATCH 15/16] add: edit text have border --- src/components/Admin/Pets/Add/EditName.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/Admin/Pets/Add/EditName.tsx b/src/components/Admin/Pets/Add/EditName.tsx index 7969cb5d..f8f2f7a5 100644 --- a/src/components/Admin/Pets/Add/EditName.tsx +++ b/src/components/Admin/Pets/Add/EditName.tsx @@ -75,7 +75,7 @@ const EditName = (props: EditNameProps) => { Date: Fri, 17 May 2024 14:13:35 +0700 Subject: [PATCH 16/16] fix: lint --- src/api/pets.ts | 5 +---- src/app/pets/[id]/adopt/page.tsx | 2 +- src/components/Admin/Pets/Add/EditInfoAndSubmit.tsx | 6 +++++- src/components/Admin/Pets/Add/EditName.tsx | 2 +- src/hooks/mutation/useDeleteImage.ts | 2 +- 5 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/api/pets.ts b/src/api/pets.ts index 2423325e..fd33bf17 100644 --- a/src/api/pets.ts +++ b/src/api/pets.ts @@ -44,10 +44,7 @@ const getPetsAdmin = async (filters?: filterState) => { return response.data; }; -type postPetRequest = Omit< - Pet, - "id" | "images" | "is_club_pet" -> & { +type postPetRequest = Omit & { images: string[]; // image id }; diff --git a/src/app/pets/[id]/adopt/page.tsx b/src/app/pets/[id]/adopt/page.tsx index 68f20d14..d4484741 100644 --- a/src/app/pets/[id]/adopt/page.tsx +++ b/src/app/pets/[id]/adopt/page.tsx @@ -42,7 +42,7 @@ const AdoptionPage = () => {
-
+
diff --git a/src/components/Admin/Pets/Add/EditInfoAndSubmit.tsx b/src/components/Admin/Pets/Add/EditInfoAndSubmit.tsx index 058429da..7441f67c 100644 --- a/src/components/Admin/Pets/Add/EditInfoAndSubmit.tsx +++ b/src/components/Admin/Pets/Add/EditInfoAndSubmit.tsx @@ -264,7 +264,11 @@ const EditInfoAndSubmit = (props: EditInfoAndSubmitProps) => { className="w-full text-2xl font-semibold" text={enableEdit ? "โปรดบันทึกข้อมูลก่อนโพสต์" : "โพสต์เลย"} onClick={props.onSubmit} - variant={props.enableSubmit && !enableEdit ? "accent-red" : "disabled"} + variant={ + props.enableSubmit && !enableEdit + ? "accent-red" + : "disabled" + } rounded="full" />
diff --git a/src/components/Admin/Pets/Add/EditName.tsx b/src/components/Admin/Pets/Add/EditName.tsx index f8f2f7a5..4b14dd73 100644 --- a/src/components/Admin/Pets/Add/EditName.tsx +++ b/src/components/Admin/Pets/Add/EditName.tsx @@ -75,7 +75,7 @@ const EditName = (props: EditNameProps) => { { }, onError: () => { toast.error("มีบางอย่างผิดพลาด"); - } + }, }); };