From 24f860ad18e97d3b633e3cbd9fb7fc98b9c41388 Mon Sep 17 00:00:00 2001 From: isra el Date: Mon, 16 Oct 2023 10:03:44 +0300 Subject: [PATCH] refactor(web): refactor and fix minor bugs --- README.md | 2 +- web/components/AnimatedScrollWrapper.tsx | 30 ++++ web/components/Navbar.tsx | 62 ++++--- web/components/analytics/Analytics.tsx | 43 +++++ web/components/dashboard/ApiKeyList.tsx | 92 ++++++----- web/components/dashboard/DeviceList.tsx | 84 +++++----- web/components/dashboard/GenerateApiKey.tsx | 17 +- web/components/dashboard/SendSMS.tsx | 135 ++++++++++------ web/components/dashboard/UserStats.tsx | 27 ++-- web/components/home/CodeSnippetSection.tsx | 2 +- web/components/home/DownloadAppSection.tsx | 88 ---------- web/components/home/FeaturesSection.tsx | 58 ------- web/components/home/HowItWorksSection.tsx | 57 ------- web/components/home/IntroSection.tsx | 124 -------------- web/components/landing/CodeSnippetSection.tsx | 45 ++++++ web/components/landing/DownloadAppSection.tsx | 91 +++++++++++ web/components/landing/FeaturesSection.tsx | 64 ++++++++ web/components/landing/HowItWorksSection.tsx | 60 +++++++ web/components/landing/IntroSection.tsx | 153 ++++++++++++++++++ .../{home => landing}/featuresContent.ts | 0 .../{home => landing}/howItWorksContent.ts | 0 web/lib/{customAxios.ts => httpClient.ts} | 6 +- web/pages/{404.js => 404.tsx} | 0 web/pages/_app.tsx | 4 +- .../{dashboard/index.tsx => dashboard.tsx} | 23 ++- web/pages/index.tsx | 16 +- web/pages/login.tsx | 11 +- web/pages/register.tsx | 16 +- web/services/authService.ts | 34 ++++ web/services/gatewayService.ts | 34 ++++ web/services/index.ts | 66 -------- web/services/types.ts | 6 +- web/store/apiKeyListReducer.ts | 61 ------- web/store/apiKeySlice.ts | 85 ++++++++++ web/store/{authReducer.ts => authSlice.ts} | 22 ++- web/store/deviceListReducer.ts | 61 ------- web/store/deviceSlice.ts | 92 +++++++++++ web/store/store.ts | 10 +- 38 files changed, 1026 insertions(+), 755 deletions(-) create mode 100644 web/components/AnimatedScrollWrapper.tsx create mode 100644 web/components/analytics/Analytics.tsx delete mode 100644 web/components/home/DownloadAppSection.tsx delete mode 100644 web/components/home/FeaturesSection.tsx delete mode 100644 web/components/home/HowItWorksSection.tsx delete mode 100644 web/components/home/IntroSection.tsx create mode 100644 web/components/landing/CodeSnippetSection.tsx create mode 100644 web/components/landing/DownloadAppSection.tsx create mode 100644 web/components/landing/FeaturesSection.tsx create mode 100644 web/components/landing/HowItWorksSection.tsx create mode 100644 web/components/landing/IntroSection.tsx rename web/components/{home => landing}/featuresContent.ts (100%) rename web/components/{home => landing}/howItWorksContent.ts (100%) rename web/lib/{customAxios.ts => httpClient.ts} (71%) rename web/pages/{404.js => 404.tsx} (100%) rename web/pages/{dashboard/index.tsx => dashboard.tsx} (64%) create mode 100644 web/services/authService.ts create mode 100644 web/services/gatewayService.ts delete mode 100644 web/services/index.ts delete mode 100644 web/store/apiKeyListReducer.ts create mode 100644 web/store/apiKeySlice.ts rename web/store/{authReducer.ts => authSlice.ts} (84%) delete mode 100644 web/store/deviceListReducer.ts create mode 100644 web/store/deviceSlice.ts diff --git a/README.md b/README.md index a0f8243..928a1a4 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ from their application via a REST API. It utilizes android phones as SMS gateway const API_KEY = 'YOUR_API_KEY'; const DEVICE_ID = 'YOUR_DEVICE_ID'; -await axios.post(`https://api.textbee.vernu.dev/api/v1/devices/${DEVICE_ID}/sendSMS?apiKey=${API_KEY}`, { +await axios.post(`https://api.textbee.vernu.dev/api/v1/gateway/devices/${DEVICE_ID}/sendSMS?apiKey=${API_KEY}`, { receivers: [ '+251912345678' ], smsBody: 'Hello World!', }) diff --git a/web/components/AnimatedScrollWrapper.tsx b/web/components/AnimatedScrollWrapper.tsx new file mode 100644 index 0000000..44d40fe --- /dev/null +++ b/web/components/AnimatedScrollWrapper.tsx @@ -0,0 +1,30 @@ +import React, { ReactNode } from 'react' +import { motion } from 'framer-motion' + +interface AnimatedScrollWrapperProps { + children: ReactNode +} +const AnimatedScrollWrapper = ({ children }: AnimatedScrollWrapperProps) => { + return ( + + {children} + + ) +} + +export default AnimatedScrollWrapper diff --git a/web/components/Navbar.tsx b/web/components/Navbar.tsx index aae6412..d0cc32e 100644 --- a/web/components/Navbar.tsx +++ b/web/components/Navbar.tsx @@ -11,19 +11,19 @@ import { useColorModeValue, Stack, useColorMode, - Center, Image, + SimpleGrid, } from '@chakra-ui/react' import Link from 'next/link' import { MoonIcon, SunIcon } from '@chakra-ui/icons' import Router from 'next/router' import { useDispatch, useSelector } from 'react-redux' -import { logout, selectAuth } from '../store/authReducer' +import { logout, selectAuthUser } from '../store/authSlice' export default function Navbar() { const dispatch = useDispatch() const { colorMode, toggleColorMode } = useColorMode() - const { user } = useSelector(selectAuth) + const authUser = useSelector(selectAuthUser) return ( <> @@ -62,18 +62,18 @@ export default function Navbar() { - {!user ? ( - <> - - - Login - - - Register - - - - ) : ( + {!authUser && ( + + + Login + + + Register + + + )} + + {authUser && ( -
-
- -
-
-
-

{user?.name}

-
-
+ + + + {authUser?.name} + + + { diff --git a/web/components/analytics/Analytics.tsx b/web/components/analytics/Analytics.tsx new file mode 100644 index 0000000..3430898 --- /dev/null +++ b/web/components/analytics/Analytics.tsx @@ -0,0 +1,43 @@ +import Script from 'next/script' + +const Analytics = () => { + return ( + <> + {/* Global Site Tag (gtag.js) - Google Analytics */} +