Skip to content

Commit

Permalink
style: the favorites view is over for now
Browse files Browse the repository at this point in the history
  • Loading branch information
Franqsanz committed Sep 3, 2024
1 parent 3e2746e commit d48216f
Show file tree
Hide file tree
Showing 10 changed files with 157 additions and 80 deletions.
3 changes: 3 additions & 0 deletions src/assets/assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ const images = {
'https://res.cloudinary.com/xbu/image/upload/v1691664467/xbu_assets/page_not_found_rl8gve.svg',
NoData:
'https://res.cloudinary.com/xbu/image/upload/v1708539494/xbu_assets/noData_gs71zg.svg',
emptyFavorites:
'https://res.cloudinary.com/xbu/image/upload/v1725365540/xbu_assets/undraw_with_love_re_1q3m_yxcely.svg',
};

export const {
Expand All @@ -22,4 +24,5 @@ export const {
PatternPadWhite,
PageNotFound,
NoData,
emptyFavorites,
} = images;
1 change: 1 addition & 0 deletions src/assets/emptyFavorites.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 3 additions & 8 deletions src/components/AllBooks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { Aside } from '@components/aside/Aside';
import { SkeletonAllBooks } from '@components/skeletons/SkeletonABooks';
import { ResultLength } from '@components/aside/ResultLength';
import { MostViewed } from '@components/aside/MostViewed';
import { MyContainer } from '@components/ui/MyContainer';

export function AllBooks() {
const { ref, inView } = useInView();
Expand Down Expand Up @@ -75,13 +76,7 @@ export function AllBooks() {
return (
<>
<ScrollRestoration />
<Flex
as='article'
direction={{ base: 'column', md: 'row' }}
maxW={{ base: '1260px', '2xl': '1560px' }}
m='0 auto'
px={{ base: 5, md: 10, '2xl': 16 }}
>
<MyContainer>
<Aside>
<ResultLength data={data.pages[0].info.totalBooks} />
<Box mt='5'>
Expand Down Expand Up @@ -134,7 +129,7 @@ export function AllBooks() {
</React.Fragment>
))}
</MySimpleGrid>
</Flex>
</MyContainer>
<Box ref={ref}>{fetchingNextPageUI}</Box>
</>
);
Expand Down
18 changes: 18 additions & 0 deletions src/components/ui/MyContainer.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import React from 'react';
import { Flex } from '@chakra-ui/react';

export function MyContainer({ children }: { children: React.ReactNode }) {
return (
<>
<Flex
as='article'
direction={{ base: 'column', md: 'row' }}
maxW={{ base: '1260px', '2xl': '1560px' }}
m='0 auto'
px={{ base: 5, md: 10, '2xl': 16 }}
>
{children}
</Flex>
</>
);
}
8 changes: 4 additions & 4 deletions src/hooks/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ function useMoreBooks() {
refetchOnWindowFocus: false,
gcTime: 3000,
staleTime: 50000,
retry: 1,
retry: false,
});
}

Expand All @@ -155,7 +155,7 @@ function useMostViewedBooks(query) {
refetchOnWindowFocus: false,
gcTime: 3000,
staleTime: 50000,
retry: 1,
retry: false,
});
}

Expand All @@ -166,7 +166,7 @@ function useRelatedBooks(id: string | undefined) {
refetchOnWindowFocus: false,
gcTime: 3000,
staleTime: 50000,
retry: 1,
retry: false,
});
}

Expand All @@ -177,7 +177,7 @@ function useMoreBooksAuthors(id: string | undefined) {
refetchOnWindowFocus: false,
gcTime: 3000,
staleTime: 50000,
retry: 1,
retry: false,
});
}

Expand Down
9 changes: 4 additions & 5 deletions src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,10 @@ Sentry.init({
dsn: import.meta.env.VITE_SENTRY_DNS,
integrations: [Sentry.browserTracingIntegration(), Sentry.replayIntegration()],
tracesSampleRate: 1.0,
tracePropagationTargets: [
API_URL,
/^\/api\//,
// /^https:\/\/xb-api\.vercel\.app\/api/,
],
// tracePropagationTargets: [
// API_URL,
// /^\/api\//,
// ],
replaysSessionSampleRate: 0.1,
replaysOnErrorSampleRate: 1.0,
});
Expand Down
6 changes: 3 additions & 3 deletions src/pages/Book.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { lazy, Suspense, useEffect, useState } from 'react';
import { useParams, useNavigate, NavLink } from 'react-router-dom';
import { useParams, useNavigate, NavLink, useLocation } from 'react-router-dom';
import {
Box,
Center,
Expand Down Expand Up @@ -49,6 +49,7 @@ const MoreBooks = lazy(() => import('@components/cards/MoreBooks'));

export default function Book() {
const shareUrl = window.location.href;
const location = useLocation();
const getToken = window.localStorage.getItem('app_tk');
const { pathUrl } = useParams();
const { currentUser } = useAuth();
Expand Down Expand Up @@ -87,7 +88,6 @@ export default function Book() {

if (Array.isArray(bookObject)) {
const [obj] = data;

bookObject = obj;
} else {
bookObject = data;
Expand All @@ -102,7 +102,7 @@ export default function Book() {

useEffect(() => {
setIsFavorite(bookObject.isFavorite);
}, [bookObject.isFavorite]);
}, [bookObject.isFavorite, location.pathname]);

if (currentUser && isCurrentUserAuthor) {
btnMoreOptions = (
Expand Down
Loading

0 comments on commit d48216f

Please sign in to comment.