From b091ae4efdef550d83663c2fe1f6aa486ac9bfa7 Mon Sep 17 00:00:00 2001 From: Akhlak Hossain Jim <73884856+Akhlak-Hossain-Jim@users.noreply.github.com> Date: Thu, 5 Dec 2024 00:46:51 +0600 Subject: [PATCH 01/10] =?UTF-8?q?=F0=9F=9B=A0=EF=B8=8Finstall=20prompt=20f?= =?UTF-8?q?unction=20and=20component=20added?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/_app.tsx | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/pages/_app.tsx b/pages/_app.tsx index 7910b44..b070c19 100644 --- a/pages/_app.tsx +++ b/pages/_app.tsx @@ -20,6 +20,7 @@ import { SignerOptions, wallets } from "cosmos-kit"; import Head from "next/head"; import { ToastContainer } from "react-toastify"; import { aminoTypes, registry } from "../config/defaults"; +import PromptInstall from "@/components/PromptInstall"; const queryClient = new QueryClient({ defaultOptions: { @@ -38,6 +39,8 @@ function CreateCosmosApp({ Component, pageProps }: AppProps) { // State to manage loading screen const [isLoading, setIsLoading] = useState(false); + const [deferredPrompt, setDeferredPrompt] = useState(null); + const [isInstallable, setIsInstallable] = useState(false); const signerOptions: SignerOptions = { // @ts-ignore @@ -94,6 +97,38 @@ function CreateCosmosApp({ Component, pageProps }: AppProps) { }; }, [router]); + // Checking if Install Prompt should be opened (only on load) + useEffect(() => { + const handleBeforeInstallPrompt = (e: Event) => { + e.preventDefault(); + setDeferredPrompt(e); + setIsInstallable(true); + }; + window.addEventListener("beforeinstallprompt", handleBeforeInstallPrompt); + return () => { + window.removeEventListener( + "beforeinstallprompt", + handleBeforeInstallPrompt + ); + }; + }, []); + + const handleInstall = async () => { + if (deferredPrompt) { + const promptEvent = deferredPrompt as any; + promptEvent.prompt(); + const choiceResult = await promptEvent.userChoice; + if (choiceResult.outcome === "accepted") { + console.log("PWA installation accepted"); + } else { + console.log("PWA installation dismissed"); + } + + setDeferredPrompt(null); + setIsInstallable(false); + } + }; + return ( <> @@ -189,6 +224,11 @@ function CreateCosmosApp({ Component, pageProps }: AppProps) { backgroundColor={useColorModeValue("#ffffff", "#ffffff")} > + setIsInstallable(false)} + /> {isLoading && } From ed0615a59173579e1cf1307f4b71bd08735263ab Mon Sep 17 00:00:00 2001 From: Akhlak Hossain Jim <73884856+Akhlak-Hossain-Jim@users.noreply.github.com> Date: Thu, 5 Dec 2024 00:47:18 +0600 Subject: [PATCH 02/10] =?UTF-8?q?=F0=9F=8F=B7=EF=B8=8F=F0=9F=92=85?= =?UTF-8?q?=F0=9F=9B=A0=EF=B8=8F=F0=9F=93=95created=20install=20prompt=20c?= =?UTF-8?q?omponent?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/PromptInstall.tsx | 50 ++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 components/PromptInstall.tsx diff --git a/components/PromptInstall.tsx b/components/PromptInstall.tsx new file mode 100644 index 0000000..6b4a79b --- /dev/null +++ b/components/PromptInstall.tsx @@ -0,0 +1,50 @@ +import Image from "next/image"; +import React from "react"; +import { GrDownload } from "react-icons/gr"; + +export default function PromptInstall({ + fun, + open, + close, +}: { + fun: () => void; + open: boolean; + close: () => void; +}) { + return open ? ( +
+
+
+ selected +

Install Our App

+
+

+ Get our App experience optimized for your device. +

+ +
+
+
+ ) : ( + <> + ); +} From b20d3e0d06ddc4501fc9df01e90c29ddb584fc78 Mon Sep 17 00:00:00 2001 From: Akhlak Hossain Jim <73884856+Akhlak-Hossain-Jim@users.noreply.github.com> Date: Thu, 5 Dec 2024 00:47:35 +0600 Subject: [PATCH 03/10] =?UTF-8?q?=F0=9F=A6=84download=20svg=20added?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/assets/images/icons/download.svg | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 public/assets/images/icons/download.svg diff --git a/public/assets/images/icons/download.svg b/public/assets/images/icons/download.svg new file mode 100644 index 0000000..0ae87f6 --- /dev/null +++ b/public/assets/images/icons/download.svg @@ -0,0 +1,4 @@ + + + + From 370f95e90dd1a342fed1336e9434652ce59fcf5c Mon Sep 17 00:00:00 2001 From: Akhlak Hossain Jim <73884856+Akhlak-Hossain-Jim@users.noreply.github.com> Date: Thu, 5 Dec 2024 01:12:09 +0600 Subject: [PATCH 04/10] =?UTF-8?q?=F0=9F=A6=84404=20&=20500=20svg=20added?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/assets/images/404.svg | 1 + public/assets/images/error.svg | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 public/assets/images/404.svg create mode 100644 public/assets/images/error.svg diff --git a/public/assets/images/404.svg b/public/assets/images/404.svg new file mode 100644 index 0000000..472170d --- /dev/null +++ b/public/assets/images/404.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/public/assets/images/error.svg b/public/assets/images/error.svg new file mode 100644 index 0000000..482c79e --- /dev/null +++ b/public/assets/images/error.svg @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + From 59cb72b7fd03353dbd7500a572c398778539066f Mon Sep 17 00:00:00 2001 From: Akhlak Hossain Jim <73884856+Akhlak-Hossain-Jim@users.noreply.github.com> Date: Thu, 5 Dec 2024 01:12:22 +0600 Subject: [PATCH 05/10] =?UTF-8?q?=F0=9F=8F=B7=EF=B8=8F=F0=9F=92=85?= =?UTF-8?q?=F0=9F=9B=A0=EF=B8=8F=F0=9F=93=95created=20404=20page?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/404.tsx | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/pages/404.tsx b/pages/404.tsx index 23b0429..29c1c97 100644 --- a/pages/404.tsx +++ b/pages/404.tsx @@ -1,11 +1,23 @@ +import Image from "next/image"; import Link from "next/link"; export default function NotFound() { return ( -
-

Not Found

-

Could not find requested resource

- Return Home +
+ {"404 +

Page Not Found

+ + Go To Home +
); } From b03ef3afa417318aa149c62ba3ae1bd01c1ae62e Mon Sep 17 00:00:00 2001 From: Akhlak Hossain Jim <73884856+Akhlak-Hossain-Jim@users.noreply.github.com> Date: Thu, 5 Dec 2024 01:12:28 +0600 Subject: [PATCH 06/10] =?UTF-8?q?=F0=9F=8F=B7=EF=B8=8F=F0=9F=92=85?= =?UTF-8?q?=F0=9F=9B=A0=EF=B8=8F=F0=9F=93=95created=20500=20page?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/500.tsx | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/pages/500.tsx b/pages/500.tsx index 9c765f0..fdcfe05 100644 --- a/pages/500.tsx +++ b/pages/500.tsx @@ -1,10 +1,24 @@ +import Image from "next/image"; +import Link from "next/link"; + // pages/error.tsx export default function ErrorPage() { - return ( -
-

Error

-

The requested profile does not exist.

-
- ); - } - \ No newline at end of file + return ( +
+ {"500 +

An Error Occurred

+ + Go To Home + +
+ ); +} From a8104e810830c4227242538d11fd16df5bdd1d63 Mon Sep 17 00:00:00 2001 From: Akhlak Hossain Jim <73884856+Akhlak-Hossain-Jim@users.noreply.github.com> Date: Fri, 20 Dec 2024 19:09:10 +0600 Subject: [PATCH 07/10] =?UTF-8?q?=F0=9F=92=85updated?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/search/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pages/search/index.tsx b/pages/search/index.tsx index 74ed694..d3820e9 100644 --- a/pages/search/index.tsx +++ b/pages/search/index.tsx @@ -95,7 +95,7 @@ export default function Home() { }, [address]); return ( -
+
Date: Fri, 20 Dec 2024 19:17:00 +0600 Subject: [PATCH 08/10] =?UTF-8?q?=F0=9F=92=85=F0=9F=9B=A0=EF=B8=8Fupdated?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- layout/Header.tsx | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/layout/Header.tsx b/layout/Header.tsx index 6c7ec0b..250ab44 100644 --- a/layout/Header.tsx +++ b/layout/Header.tsx @@ -1,16 +1,22 @@ "use client"; -import { HeaderProps } from "@/config"; import { chain } from "@/constant"; import { useChain } from "@cosmos-kit/react"; import Image from "next/image"; import Link from "next/link"; +import { useEffect, useState } from "react"; -export default function Header({ - profileName, - setIsLogin, - isLogin, -}: HeaderProps) { +export default function Header() { const { connect, address } = useChain(chain); + const [isLogin, setIsLogin] = useState(false); + + useEffect(() => { + const loginStat = localStorage.getItem("loggedIn"); + loginStat === "yes" ? setIsLogin(true) : setIsLogin(false); + }, []); + + useEffect(() => { + localStorage.loggedIn = isLogin ? "yes" : "no"; + }, [isLogin]); const handleProfileIconClick = async () => { if (!address) { From 0c8d45438bedac97561acf846c2aaf46f451dfff Mon Sep 17 00:00:00 2001 From: Akhlak Hossain Jim <73884856+Akhlak-Hossain-Jim@users.noreply.github.com> Date: Fri, 20 Dec 2024 19:17:09 +0600 Subject: [PATCH 09/10] =?UTF-8?q?=F0=9F=9B=A0=EF=B8=8Fupdated?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/_app.tsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pages/_app.tsx b/pages/_app.tsx index b070c19..5f0ffa0 100644 --- a/pages/_app.tsx +++ b/pages/_app.tsx @@ -21,6 +21,7 @@ import Head from "next/head"; import { ToastContainer } from "react-toastify"; import { aminoTypes, registry } from "../config/defaults"; import PromptInstall from "@/components/PromptInstall"; +import Header from "@/layout/Header"; const queryClient = new QueryClient({ defaultOptions: { @@ -223,6 +224,7 @@ function CreateCosmosApp({ Component, pageProps }: AppProps) { minHeight="100dvh" backgroundColor={useColorModeValue("#ffffff", "#ffffff")} > +
Date: Fri, 20 Dec 2024 19:17:13 +0600 Subject: [PATCH 10/10] =?UTF-8?q?=F0=9F=9B=A0=EF=B8=8Fupdated?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/[id]/index.tsx | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/pages/[id]/index.tsx b/pages/[id]/index.tsx index 50ebe24..9b548bc 100644 --- a/pages/[id]/index.tsx +++ b/pages/[id]/index.tsx @@ -1,7 +1,6 @@ "use client"; import Loading from "@/components/Loading"; import { defaultChainName } from "@/config"; -import Header from "@/layout/Header"; import { isValidReferrer, showToastMessage, updateMyAmiList } from "@/utils"; import ProfilePrivateView from "@/views/profile/ProfilePrivateView"; import ProfilePublicView from "@/views/profile/ProfilePublicView"; @@ -19,6 +18,11 @@ export default function Profile() { const [isMyProfile, setIsMyProfile] = useState(false); const [isLoading, setIsLoading] = useState(true); + useEffect(() => { + const loginStat = localStorage.getItem("loggedIn"); + loginStat === "yes" ? setIsLogin(true) : setIsLogin(false); + }, []); + useEffect(() => { const fetchData = async () => { // Redirect to error page if PROFILE_NAME is not available @@ -150,11 +154,6 @@ export default function Profile() { return ( <> -
{isMyProfile ? ( <>