Skip to content

Commit

Permalink
book page and general ui improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
potat-dev committed Jul 28, 2024
1 parent 81d1e5d commit 5e16851
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 82 deletions.
5 changes: 3 additions & 2 deletions src/app/book/[id]/edit/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ export default function SearchBar() {

const dataBookshelves: Bookshelf[] | null = await resBookshelves.json();
if (dataBookshelves != null) {
console.log('resBookshelves.json() != null');
console.log(resBookshelves.json());
// console.log('resBookshelves.json() != null');
// console.log(resBookshelves.json());
setBookshelves(dataBookshelves);
}

Expand Down Expand Up @@ -102,6 +102,7 @@ export default function SearchBar() {
// Initialize the form with useForm hook
const form = useForm<BookUpdate>({
initialValues: {
// id: id, - also need to specify the id (TODO: fix the API)
title: '',
author: '',
description: '',
Expand Down
30 changes: 19 additions & 11 deletions src/app/book/[id]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
'use client';

import { useParams } from 'next/navigation';
import { Card, Container, Grid, Image, Text } from '@mantine/core';
import { Button, Card, Container, Grid, Image, SimpleGrid, Stack, Text } from '@mantine/core';
import { useEffect, useState } from 'react';
import Link from 'next/link';
import { useAuthContext } from '@/src/firebase/context';
import { Book, Bookshelf } from '@/src/types/api';
import { Loading } from '@/src/components/Loading/Loading';
Expand Down Expand Up @@ -80,13 +81,11 @@ export default function SearchBar() {

return (
<Container size="md">
<Grid>
<Grid.Col span={6}>
<Card shadow="sm" padding={0} radius="md">
<Image src={book?.cover_image} alt="Book Cover" />
</Card>
</Grid.Col>
<Grid.Col span={6}>
<SimpleGrid cols={{ base: 1, sm: 2 }}>
<Card shadow="sm" padding={0} radius="md">
<Image src={book?.cover_image} alt="Book Cover" />
</Card>
<Stack gap="md">
<Card shadow="sm" padding="lg" radius="md" withBorder>
<Grid columns={2}>
<Grid.Col span={1}>
Expand All @@ -111,7 +110,7 @@ export default function SearchBar() {
</Text>
</Grid.Col>
<Grid.Col span={1}>
<Text>{book?.description}</Text>
<Text>{book?.description || 'Описание отсутствует'}</Text>
</Grid.Col>
<Grid.Col span={1}>
<Text fw={700} size="lg">
Expand All @@ -132,8 +131,17 @@ export default function SearchBar() {
</Grid.Col>
</Grid>
</Card>
</Grid.Col>
</Grid>
<Button
component={Link}
href={`/book/${id}/edit`}
color="blue"
fullWidth
radius="md"
>
Edit Book
</Button>
</Stack>
</SimpleGrid>
</Container>
);
}
8 changes: 1 addition & 7 deletions src/components/AppFrame/AppFrame.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,6 @@ async function FetchBookshelf(user: any, shelfName: string) {
}

export function AppFrame({ children }: AppFrameProps) {
const demoProps = {
h: 50,
mt: 'md',
};
const [inputValue, setInputValue] = useState('');
const [opened, { open, close }] = useDisclosure(false);
const { user, loading: userLoading } = useAuthContext();
Expand Down Expand Up @@ -114,9 +110,7 @@ export function AppFrame({ children }: AppFrameProps) {
</AppShell.Header>

<AppShell.Main>
<Container size="76rem" {...demoProps}>
{children}
</Container>
<Container my="lg">{children}</Container>
</AppShell.Main>
</AppShell>
</div>
Expand Down
10 changes: 0 additions & 10 deletions src/components/Book/Book.module.css

This file was deleted.

42 changes: 0 additions & 42 deletions src/components/Book/Book.tsx

This file was deleted.

10 changes: 6 additions & 4 deletions src/components/CarouselCards/CarouselCards.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use client';

import React, { useState, useEffect } from 'react';
import { Loader, Title } from '@mantine/core';
import { Center, Loader, Title } from '@mantine/core';
import InfiniteScrollArea from './InfiniteList';
import { Bookshelf, Book } from '@/src/types/api';
import { useAuthContext } from '@/src/firebase/context';
Expand Down Expand Up @@ -89,9 +89,11 @@ function CarouselCards({ bookshelf }: CarouselProps) {

return (
<div style={{ marginBottom: '3rem' }}>
<Title order={2} ms={10} mb="xs" fw="bold">
{bookshelf.name}
</Title>
<Center>
<Title order={2} ms={10} mb="xs" fw="bold">
{bookshelf.name} collection
</Title>
</Center>
{loading ? (
<Loader size="md" />
) : items ? (
Expand Down
10 changes: 6 additions & 4 deletions src/components/Collections/AllBooks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import { useState, useEffect } from 'react';

import { Loader, Title } from '@mantine/core';
import { Center, Loader, Title } from '@mantine/core';
import { Book } from '@/src/types/api';
import { useAuthContext } from '@/src/firebase/context';
import InfiniteScrollArea from '@/src/components/CarouselCards/InfiniteList';
Expand Down Expand Up @@ -118,9 +118,11 @@ export default function AllBookshelvesPage() {

return (
<div style={{ marginBottom: '3rem', marginTop: '2rem' }}>
<Title order={2} ms={10} mb="xs" fw="bold">
All my books
</Title>
<Center>
<Title order={2} ms={10} mb="xs" fw="bold">
All my books
</Title>
</Center>
{loading ? (
<Loader size="md" />
) : books ? (
Expand Down
2 changes: 1 addition & 1 deletion src/components/ErrorCard/ErrorCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export function ErrorCard({ error, desc }: ErrorCardProps) {
const theme = useMantineTheme();
return (
<Center>
<Card mb="md" maw={theme.breakpoints.xs}>
<Card mb="md" w={theme.breakpoints.sm}>
<Title order={3}>{error}</Title>
<Divider my="md" />
<Text>{desc}</Text>
Expand Down
1 change: 0 additions & 1 deletion src/components/VerticalList/VerticalListForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ function BookCard({ book, isAdv, index }: BookCardProps) {
fullWidth
mt="sm"
radius="md"
style={{ width: '40%' }}
onClick={() => onClickHandler(book, user, isAdv, index)}
>
Choose this
Expand Down

0 comments on commit 5e16851

Please sign in to comment.