From 67ec6e3eaf316b15a05006a64d05afdb8dc6d6d0 Mon Sep 17 00:00:00 2001 From: franco sanchez Date: Tue, 20 Aug 2024 10:28:43 -0300 Subject: [PATCH] chore: folder organization within components has been improved --- src/components/AllBooks.tsx | 8 ++++---- src/components/Categories.tsx | 2 +- src/components/{ => aside}/AboutCategories.tsx | 2 +- src/components/{ => aside}/Aside.tsx | 0 src/components/{ => aside}/MostViewed.tsx | 0 src/components/{ => aside}/ResultLength.tsx | 0 src/components/cards/Card.tsx | 2 +- src/components/forms/FormEdit.tsx | 2 +- src/components/forms/NewBook.tsx | 2 +- src/components/{ => layout}/ContainerTitle.tsx | 0 src/components/{ => layout}/Footer.tsx | 0 src/components/{ => layout}/Head.tsx | 0 src/components/{ => nav}/PrivateRoute.tsx | 0 src/components/skeletons/SkeletonABooks.tsx | 4 ++-- src/components/{ => ui}/ImageZoom.tsx | 0 src/components/{ => ui}/MyLink.tsx | 0 src/components/{ => ui}/MyPopover.tsx | 0 src/components/{ => ui}/MySimpleGrid.tsx | 0 src/components/{ => ui}/MySliderCategories.tsx | 0 src/components/{ => ui}/MyTag.tsx | 0 src/pages/404.tsx | 2 +- src/pages/Book.tsx | 8 ++++---- src/pages/CreateUser.tsx | 2 +- src/pages/Explore.tsx | 6 +++--- src/pages/Home.tsx | 2 +- src/pages/Login.tsx | 4 ++-- src/pages/MostViewed.tsx | 8 ++++---- src/pages/NewBook.tsx | 4 ++-- src/pages/PrivacyPolicies.tsx | 4 ++-- src/pages/Search.tsx | 14 +++++++------- src/pages/layout/Layout.tsx | 2 +- src/pages/profile/Profile.tsx | 8 ++++---- src/pages/profile/account/MyAccount.tsx | 4 ++-- src/routes.tsx | 2 +- src/utils/utils.ts | 11 +---------- 35 files changed, 47 insertions(+), 56 deletions(-) rename src/components/{ => aside}/AboutCategories.tsx (94%) rename src/components/{ => aside}/Aside.tsx (100%) rename src/components/{ => aside}/MostViewed.tsx (100%) rename src/components/{ => aside}/ResultLength.tsx (100%) rename src/components/{ => layout}/ContainerTitle.tsx (100%) rename src/components/{ => layout}/Footer.tsx (100%) rename src/components/{ => layout}/Head.tsx (100%) rename src/components/{ => nav}/PrivateRoute.tsx (100%) rename src/components/{ => ui}/ImageZoom.tsx (100%) rename src/components/{ => ui}/MyLink.tsx (100%) rename src/components/{ => ui}/MyPopover.tsx (100%) rename src/components/{ => ui}/MySimpleGrid.tsx (100%) rename src/components/{ => ui}/MySliderCategories.tsx (100%) rename src/components/{ => ui}/MyTag.tsx (100%) diff --git a/src/components/AllBooks.tsx b/src/components/AllBooks.tsx index e63dd70..71719c6 100644 --- a/src/components/AllBooks.tsx +++ b/src/components/AllBooks.tsx @@ -14,12 +14,12 @@ import { useInView } from 'react-intersection-observer'; import { CardType } from '@components/types'; import { useBooksPaginate } from '@hooks/queries'; import { useScrollRestoration } from '@hooks/useScrollRestoration'; -import { MySimpleGrid } from '@components/MySimpleGrid'; +import { MySimpleGrid } from '@components/ui/MySimpleGrid'; import { Card } from '@components/cards/Card'; -import { Aside } from '@components/Aside'; +import { Aside } from '@components/aside/Aside'; import { SkeletonAllBooks } from '@components/skeletons/SkeletonABooks'; -import { ResultLength } from '@components/ResultLength'; -import { MostViewed } from '@components/MostViewed'; +import { ResultLength } from '@components/aside/ResultLength'; +import { MostViewed } from '@components/aside/MostViewed'; export function AllBooks() { const { ref, inView } = useInView(); diff --git a/src/components/Categories.tsx b/src/components/Categories.tsx index d984907..26ae990 100644 --- a/src/components/Categories.tsx +++ b/src/components/Categories.tsx @@ -3,7 +3,7 @@ import { NavLink } from 'react-router-dom'; import { Link } from '@chakra-ui/react'; import { BsTag } from 'react-icons/bs'; -import { MyTag } from '@components/MyTag'; +import { MyTag } from '@components/ui/MyTag'; import { useAllFilterOptions } from '@hooks/queries'; export default function Categories() { diff --git a/src/components/AboutCategories.tsx b/src/components/aside/AboutCategories.tsx similarity index 94% rename from src/components/AboutCategories.tsx rename to src/components/aside/AboutCategories.tsx index 184a7c5..7292f3a 100644 --- a/src/components/AboutCategories.tsx +++ b/src/components/aside/AboutCategories.tsx @@ -1,7 +1,7 @@ import React from 'react'; import { Box, Text } from '@chakra-ui/react'; -import { aboutCategories } from '../data/links'; +import { aboutCategories } from '../../data/links'; export function AboutCategories({ category }: any) { const filteredAboutCategories = aboutCategories.filter((item) => { diff --git a/src/components/Aside.tsx b/src/components/aside/Aside.tsx similarity index 100% rename from src/components/Aside.tsx rename to src/components/aside/Aside.tsx diff --git a/src/components/MostViewed.tsx b/src/components/aside/MostViewed.tsx similarity index 100% rename from src/components/MostViewed.tsx rename to src/components/aside/MostViewed.tsx diff --git a/src/components/ResultLength.tsx b/src/components/aside/ResultLength.tsx similarity index 100% rename from src/components/ResultLength.tsx rename to src/components/aside/ResultLength.tsx diff --git a/src/components/cards/Card.tsx b/src/components/cards/Card.tsx index 2329b37..308d22b 100644 --- a/src/components/cards/Card.tsx +++ b/src/components/cards/Card.tsx @@ -14,7 +14,7 @@ import { BsTag } from 'react-icons/bs'; import { IoLanguageOutline } from 'react-icons/io5'; import { CardType } from '@components/types'; -import { MyTag } from '@components/MyTag'; +import { MyTag } from '@components/ui/MyTag'; import { handleImageLoad, useHandleEnterKey, isSpanish } from '@utils/utils'; export function Card({ diff --git a/src/components/forms/FormEdit.tsx b/src/components/forms/FormEdit.tsx index 82d2b24..4a36ee4 100644 --- a/src/components/forms/FormEdit.tsx +++ b/src/components/forms/FormEdit.tsx @@ -28,7 +28,7 @@ import { BookType, MyChangeEvent } from '@components/types'; import { useUpdateBook } from '@hooks/queries'; import { ModalCropper } from '@components/modals/ModalCropper'; import { sortArrayByLabel } from '@utils/utils'; -import { MyPopover } from '@components/MyPopover'; +import { MyPopover } from '@components/ui/MyPopover'; import { handleInputChange, handleCategory, diff --git a/src/components/forms/NewBook.tsx b/src/components/forms/NewBook.tsx index 5bc10a7..a528a66 100644 --- a/src/components/forms/NewBook.tsx +++ b/src/components/forms/NewBook.tsx @@ -29,7 +29,7 @@ import { useMutatePost, useCheckUser } from '@hooks/queries'; import { ModalCropper } from '@components/modals/ModalCropper'; import { sortArrayByLabel } from '@utils/utils'; import { useGenerateSlug } from '@hooks/useGenerateSlug'; -import { MyPopover } from '@components/MyPopover'; +import { MyPopover } from '@components/ui/MyPopover'; import { handleInputChange, handleCategory, diff --git a/src/components/ContainerTitle.tsx b/src/components/layout/ContainerTitle.tsx similarity index 100% rename from src/components/ContainerTitle.tsx rename to src/components/layout/ContainerTitle.tsx diff --git a/src/components/Footer.tsx b/src/components/layout/Footer.tsx similarity index 100% rename from src/components/Footer.tsx rename to src/components/layout/Footer.tsx diff --git a/src/components/Head.tsx b/src/components/layout/Head.tsx similarity index 100% rename from src/components/Head.tsx rename to src/components/layout/Head.tsx diff --git a/src/components/PrivateRoute.tsx b/src/components/nav/PrivateRoute.tsx similarity index 100% rename from src/components/PrivateRoute.tsx rename to src/components/nav/PrivateRoute.tsx diff --git a/src/components/skeletons/SkeletonABooks.tsx b/src/components/skeletons/SkeletonABooks.tsx index bb4019a..7b03d7b 100644 --- a/src/components/skeletons/SkeletonABooks.tsx +++ b/src/components/skeletons/SkeletonABooks.tsx @@ -1,8 +1,8 @@ import React from 'react'; import { Skeleton, SkeletonText, Flex, Box, Stack } from '@chakra-ui/react'; -import { MySimpleGrid } from '@components/MySimpleGrid'; -import { Aside } from '@components/Aside'; +import { MySimpleGrid } from '@components/ui/MySimpleGrid'; +import { Aside } from '@components/aside/Aside'; import { SkeletonTags } from '@components/skeletons/SkeletonTags'; import { SkeletonType } from '@components/types'; diff --git a/src/components/ImageZoom.tsx b/src/components/ui/ImageZoom.tsx similarity index 100% rename from src/components/ImageZoom.tsx rename to src/components/ui/ImageZoom.tsx diff --git a/src/components/MyLink.tsx b/src/components/ui/MyLink.tsx similarity index 100% rename from src/components/MyLink.tsx rename to src/components/ui/MyLink.tsx diff --git a/src/components/MyPopover.tsx b/src/components/ui/MyPopover.tsx similarity index 100% rename from src/components/MyPopover.tsx rename to src/components/ui/MyPopover.tsx diff --git a/src/components/MySimpleGrid.tsx b/src/components/ui/MySimpleGrid.tsx similarity index 100% rename from src/components/MySimpleGrid.tsx rename to src/components/ui/MySimpleGrid.tsx diff --git a/src/components/MySliderCategories.tsx b/src/components/ui/MySliderCategories.tsx similarity index 100% rename from src/components/MySliderCategories.tsx rename to src/components/ui/MySliderCategories.tsx diff --git a/src/components/MyTag.tsx b/src/components/ui/MyTag.tsx similarity index 100% rename from src/components/MyTag.tsx rename to src/components/ui/MyTag.tsx diff --git a/src/pages/404.tsx b/src/pages/404.tsx index a71a29c..b6aa245 100644 --- a/src/pages/404.tsx +++ b/src/pages/404.tsx @@ -3,7 +3,7 @@ import { NavLink } from 'react-router-dom'; import { Link, Text, VStack, Box, Image, Flex, Icon } from '@chakra-ui/react'; import { FiArrowLeft } from 'react-icons/fi'; -import { MainHead } from '@components/Head'; +import { MainHead } from '@components/layout/Head'; import { PageNotFound } from '@assets/assets'; export function ErrorPage() { diff --git a/src/pages/Book.tsx b/src/pages/Book.tsx index a554e60..c0ab8fb 100644 --- a/src/pages/Book.tsx +++ b/src/pages/Book.tsx @@ -28,12 +28,12 @@ import 'atropos/css'; import { useBook, useDeleteBook } from '@hooks/queries'; import { handleImageLoad } from '@utils/utils'; -import { MainHead } from '@components/Head'; -import { MyTag } from '@components/MyTag'; +import { MainHead } from '@components/layout/Head'; +import { MyTag } from '@components/ui/MyTag'; import { ModalShare } from '@components/modals/ModalShare'; -import { MyLink } from '@components/MyLink'; +import { MyLink } from '@components/ui/MyLink'; import { BooksSection } from '@components/BooksSection'; -import { ImageZoom } from '@components/ImageZoom'; +import { ImageZoom } from '@components/ui/ImageZoom'; import { ModalOptions } from '@components/modals/ModalOptions'; import { ModalConfirmation } from '@components/modals/ModalConfirmation'; import { ModalForm } from '@components/modals/ModalForm'; diff --git a/src/pages/CreateUser.tsx b/src/pages/CreateUser.tsx index c39b210..853158b 100644 --- a/src/pages/CreateUser.tsx +++ b/src/pages/CreateUser.tsx @@ -1,7 +1,7 @@ import React from 'react'; import { FormCreateUser } from '@components/forms/FormCreateUser'; -import { MainHead } from '@components/Head'; +import { MainHead } from '@components/layout/Head'; export function CreateUser() { return ( diff --git a/src/pages/Explore.tsx b/src/pages/Explore.tsx index fba6df2..ee62674 100644 --- a/src/pages/Explore.tsx +++ b/src/pages/Explore.tsx @@ -1,9 +1,9 @@ import React from 'react'; import { AllBooks } from '@components/AllBooks'; -import { ContainerTitle } from '@components/ContainerTitle'; -import { MySliderCategories } from '@components/MySliderCategories'; -import { MainHead } from '@components/Head'; +import { ContainerTitle } from '@components/layout/ContainerTitle'; +import { MySliderCategories } from '@components/ui/MySliderCategories'; +import { MainHead } from '@components/layout/Head'; export default function Explore() { return ( diff --git a/src/pages/Home.tsx b/src/pages/Home.tsx index 1a24e13..8ed05db 100644 --- a/src/pages/Home.tsx +++ b/src/pages/Home.tsx @@ -17,7 +17,7 @@ import { useBreakpointValue, } from '@chakra-ui/react'; -import { MainHead } from '@components/Head'; +import { MainHead } from '@components/layout/Head'; import { useAuth } from '@contexts/AuthContext'; import { PatternPadWhite, diff --git a/src/pages/Login.tsx b/src/pages/Login.tsx index dc4eea5..c0e5fe2 100644 --- a/src/pages/Login.tsx +++ b/src/pages/Login.tsx @@ -2,8 +2,8 @@ import React from 'react'; import { Box, Flex, Button, Stack } from '@chakra-ui/react'; import { BsFacebook, BsTwitterX } from 'react-icons/bs'; -import { ContainerTitle } from '@components/ContainerTitle'; -import { MainHead } from '@components/Head'; +import { ContainerTitle } from '@components/layout/ContainerTitle'; +import { MainHead } from '@components/layout/Head'; import { SignIn } from '@services/auth/auth'; export function Login() { diff --git a/src/pages/MostViewed.tsx b/src/pages/MostViewed.tsx index 9ad0e0a..25e97b3 100644 --- a/src/pages/MostViewed.tsx +++ b/src/pages/MostViewed.tsx @@ -1,13 +1,13 @@ import React from 'react'; import { Flex } from '@chakra-ui/react'; -import { MainHead } from '@components/Head'; -import { ContainerTitle } from '@components/ContainerTitle'; -import { MySimpleGrid } from '@components/MySimpleGrid'; +import { MainHead } from '@components/layout/Head'; +import { ContainerTitle } from '@components/layout/ContainerTitle'; +import { MySimpleGrid } from '@components/ui/MySimpleGrid'; import { Card } from '@components/cards/Card'; import { CardType } from '@components/types'; import { useMostViewedBooks } from '@hooks/queries'; -import { MySliderCategories } from '@components/MySliderCategories'; +import { MySliderCategories } from '@components/ui/MySliderCategories'; export default function MostViewed() { const { data } = useMostViewedBooks('full'); diff --git a/src/pages/NewBook.tsx b/src/pages/NewBook.tsx index 97384ac..4fd4f5d 100644 --- a/src/pages/NewBook.tsx +++ b/src/pages/NewBook.tsx @@ -1,8 +1,8 @@ import React from 'react'; import { FormNewBook } from '@components/forms/NewBook'; -import { MainHead } from '@components/Head'; -import { ContainerTitle } from '@components/ContainerTitle'; +import { MainHead } from '@components/layout/Head'; +import { ContainerTitle } from '@components/layout/ContainerTitle'; export default function NewBook() { return ( diff --git a/src/pages/PrivacyPolicies.tsx b/src/pages/PrivacyPolicies.tsx index 5d0ea99..39b611d 100644 --- a/src/pages/PrivacyPolicies.tsx +++ b/src/pages/PrivacyPolicies.tsx @@ -1,8 +1,8 @@ import React from 'react'; import { Box, Flex, Text, Link } from '@chakra-ui/react'; -import { ContainerTitle } from '@components/ContainerTitle'; -import { MainHead } from '@components/Head'; +import { ContainerTitle } from '@components/layout/ContainerTitle'; +import { MainHead } from '@components/layout/Head'; export default function PrivacyPolicies() { return ( diff --git a/src/pages/Search.tsx b/src/pages/Search.tsx index c38782c..ea29d82 100644 --- a/src/pages/Search.tsx +++ b/src/pages/Search.tsx @@ -22,14 +22,14 @@ import { Card } from '@components/cards/Card'; import { CardType } from '@components/types'; import { useFilter, useFilterPaginated } from '@hooks/queries'; import { useScrollRestoration } from '@hooks/useScrollRestoration'; -import { ContainerTitle } from '@components/ContainerTitle'; -import { MySimpleGrid } from '@components/MySimpleGrid'; -import { MainHead } from '@components/Head'; -import { Aside } from '@components/Aside'; -import { MySliderCategories } from '@components/MySliderCategories'; +import { ContainerTitle } from '@components/layout/ContainerTitle'; +import { MySimpleGrid } from '@components/ui/MySimpleGrid'; +import { MainHead } from '@components/layout/Head'; +import { Aside } from '@components/aside/Aside'; +import { MySliderCategories } from '@components/ui/MySliderCategories'; import { FilterDrawer } from '@components/FilterDrawer'; -import { ResultLength } from '@components/ResultLength'; -import { AboutCategories } from '@components/AboutCategories'; +import { ResultLength } from '@components/aside/ResultLength'; +import { AboutCategories } from '@components/aside/AboutCategories'; import { Lost } from '@assets/assets'; import { aboutCategories } from '../data/links'; import { SkeletonAllBooks } from '@components/skeletons/SkeletonABooks'; diff --git a/src/pages/layout/Layout.tsx b/src/pages/layout/Layout.tsx index b6cca1f..1c96962 100644 --- a/src/pages/layout/Layout.tsx +++ b/src/pages/layout/Layout.tsx @@ -3,7 +3,7 @@ import { Outlet } from 'react-router-dom'; import { SkeletonMain } from '@components/skeletons/SkeletonMain'; import { Nav } from '@components/nav/Nav'; -import { Footer } from '@components/Footer'; +import { Footer } from '@components/layout/Footer'; export function Layout() { return ( diff --git a/src/pages/profile/Profile.tsx b/src/pages/profile/Profile.tsx index 86083b9..6b26878 100644 --- a/src/pages/profile/Profile.tsx +++ b/src/pages/profile/Profile.tsx @@ -16,14 +16,14 @@ import { AiOutlineCloudUpload } from 'react-icons/ai'; import { useInView } from 'react-intersection-observer'; // import Cookies from 'js-cookie'; -import { MySimpleGrid } from '@components/MySimpleGrid'; +import { MySimpleGrid } from '@components/ui/MySimpleGrid'; import { Card } from '@components/cards/Card'; -import { Aside } from '@components/Aside'; -import { MainHead } from '@components/Head'; +import { Aside } from '@components/aside/Aside'; +import { MainHead } from '@components/layout/Head'; import { useProfile } from '@hooks/queries'; import { parseDate } from '@utils/utils'; import { CardType } from '@components/types'; -import { ResultLength } from '@components/ResultLength'; +import { ResultLength } from '@components/aside/ResultLength'; import { useAuth } from '@contexts/AuthContext'; import { NoData } from '@assets/assets'; import { SkeletonAllBooks } from '@components/skeletons/SkeletonABooks'; diff --git a/src/pages/profile/account/MyAccount.tsx b/src/pages/profile/account/MyAccount.tsx index 06cb313..6c11496 100644 --- a/src/pages/profile/account/MyAccount.tsx +++ b/src/pages/profile/account/MyAccount.tsx @@ -12,14 +12,14 @@ import { // import { MySimpleGrid } from '@components/MySimpleGrid'; // import { Card } from '@components/cards/Card'; // import { Aside } from '@components/Aside'; -import { MainHead } from '@components/Head'; +import { MainHead } from '@components/layout/Head'; // import { useProfile } from '@hooks/queries'; // import { parseDate } from '@utils/utils'; // import { CardType } from '@components/types'; // import ResultLength from '@components/ResultLength'; // import { useAuth } from '@contexts/AuthContext'; import { useAccountActions } from '@hooks/useAccountActions'; -import { ContainerTitle } from '@components/ContainerTitle'; +import { ContainerTitle } from '@components/layout/ContainerTitle'; import { ModalConfirmation } from '@components/modals/ModalConfirmation'; // import { logOut } from '../../services/firebase/auth'; diff --git a/src/routes.tsx b/src/routes.tsx index f6fa1f6..0ba590d 100644 --- a/src/routes.tsx +++ b/src/routes.tsx @@ -9,7 +9,7 @@ import { ErrorPage } from '@pages/404'; import { Layout } from '@pages/layout/Layout'; import { SkeletonAllBooks } from '@components/skeletons/SkeletonABooks'; import { SkeletonDetailsBook } from '@components/skeletons/SkeletonDBook'; -import { PrivateRoute } from '@components/PrivateRoute'; +import { PrivateRoute } from '@components/nav/PrivateRoute'; import { MyAccount } from '@pages/profile/account/MyAccount'; import { Profile } from '@pages/profile/Profile'; diff --git a/src/utils/utils.ts b/src/utils/utils.ts index cc9d988..d020ac3 100644 --- a/src/utils/utils.ts +++ b/src/utils/utils.ts @@ -45,7 +45,7 @@ function generatePathUrl(name: string) { const formattedName = name .toLowerCase() .normalize('NFD') - .replace(/[\u0300-\u036f()°º:]/g, ''); + .replace(/[\u0300-\u036f()°º:,]/g, ''); const withoutDotsName = formattedName.replace(/\.|\//g, ''); const withoutQuestionMarks = withoutDotsName.replace(/[?¿]/g, ''); const dashedName = withoutQuestionMarks.replace(/\s+/g, '-'); @@ -54,15 +54,6 @@ function generatePathUrl(name: string) { return `${dashedName}-${randomId}`; } -// function aboutAuthors(authorNames: string[]) { -// const authorLinks = authorNames.map((authorName) => { -// const encodedAuthorName = encodeURIComponent(authorName); -// return `https://www.google.com/search?q=${encodedAuthorName}+escritor`; -// }); - -// return authorLinks; -// } - // Funcion para verificar si se encuentra en otro idioma que no sea español function isSpanish(language) { const spanishLanguage = ['Español', 'español'];