Skip to content

Commit

Permalink
completed changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Shkirenkoroma committed Mar 23, 2023
1 parent c0f0dbe commit 58fdb9d
Show file tree
Hide file tree
Showing 26 changed files with 461 additions and 145 deletions.
39 changes: 39 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"react-dom": "^18.2.0",
"react-loader-spinner": "^5.3.4",
"react-redux": "^8.0.5",
"react-router-dom": "^6.9.0",
"react-scripts": "5.0.1",
"redux": "^4.2.1",
"redux-saga": "^1.2.3",
Expand Down
26 changes: 18 additions & 8 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,25 @@
import './App.styles.jsx';
import "./App.styles.jsx";
import * as S from "./App.styles";
import { FC } from "react";
import Main from './pages/main';
import Main from "./pages/main";
import { BrowserRouter, Routes, Route } from "react-router-dom";
import { useSelector } from "react-redux";
import DescriptionPage from "pages/description";
import { IDataBooks } from "types/index.js";

const App:FC = ():JSX.Element => {
const url = useSelector((state: IDataBooks) => state.books.id);

return (
<S.Container>
<Main />
</S.Container>
);
}
return (
<BrowserRouter>
<S.Container>
<Routes>
<Route path="/*" element={<Main />} />
<Route path={`${url}`} element={<DescriptionPage />} />
</Routes>
</S.Container>
</BrowserRouter>
);
};

export default App;
28 changes: 7 additions & 21 deletions src/assets/constants/index.tsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,9 @@
export const kindSortButtons = [
{
name: "All",
},
{
name: "Art",
},
{
name: "Biography",
},
{
name: "Computers",
},
{
name: "History",
},
{
name: "Medical",
},
{
name: "Poetry",
},
{ name: "All" },
{ name: "Art" },
{ name: "Biography" },
{ name: "Computers" },
{ name: "History" },
{ name: "Medical" },
{ name: "Poetry" },
];
File renamed without changes
1 change: 0 additions & 1 deletion src/common/api/constant/index.tsx
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
const API__KEY = `AIzaSyAPez01RNSc-o39SVYSn2nSeDiVyRHGLCo`;
export const basicUrl = `https://www.googleapis.com/books/v1/volumes`;
16 changes: 7 additions & 9 deletions src/common/api/helpers/index.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
import axios from "axios";
import { localString } from "types";
import { basicUrl } from "../constant";

export const getBooksApi = (action: any) => {
const response = axios.get(`${basicUrl}?q=${action}&maxResults=40`);
export const getBooksApi = (queryParams:localString) => {
const response = axios.get(`${basicUrl}?=${queryParams}&maxResults=40`);
return response;
};

export const getSortingBooksApi = (action: any) => {
const response = axios.get(`${basicUrl}?q=${action}&maxResults=40`);
export const getSortingBooksApi = (queryParams:localString) => {
const response = axios.get(`${basicUrl}?q=${queryParams}&maxResults=40`);
return response;
};

export const getBookByIDApi = (action: any) => {
console.log('response in last function')
const response = axios.get(`${basicUrl}/${action}`);
console.log('response in last function', response)
export const getBookByIDApi = (queryParams:localString) => {
const response = axios.get(`${basicUrl}/${queryParams}`);
return response;
};

2 changes: 1 addition & 1 deletion src/components/button/index.styles.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const ContainerButton = styled.button`
}
:hover {
cursor: pointer;
background-color: #fdd;
background-color: #9f9999;
border: 1px solid #000;
transition: all 500ms;
}
Expand Down
12 changes: 10 additions & 2 deletions src/components/button/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@ import { FC } from "react";
import { IPropsButton } from "types";
import * as S from "./index.styles";

export const Button:FC<IPropsButton> = ({ onClick, buttonName }):JSX.Element => {
return <S.ContainerButton onClick={onClick} ><span>{buttonName}</span></S.ContainerButton>;
export const Button: FC<IPropsButton> = ({
onClick,
buttonName,
className,
}): JSX.Element => {
return (
<S.ContainerButton onClick={ onClick } className={ className }>
<span>{ buttonName }</span>
</S.ContainerButton>
);
};
5 changes: 2 additions & 3 deletions src/components/input/index.styles.jsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import styled from "styled-components";

export const ContainerInput = styled.input`
max-width: 600px;
width: 100%;;
max-width: 600px;
width: 100%;
outline: none;
min-height: 50px;
border-radius: 10px;
Expand Down
5 changes: 3 additions & 2 deletions src/components/input/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ import { useDispatch } from "react-redux";
import * as S from "./index.styles";
import { getBooks } from "redux/reducer";
import React from "react";
import { IPropsInput } from "types";

const Input: FC<any> = ({ value, setValue }): JSX.Element => {
const Input: FC<IPropsInput> = ({ value, setValue }): JSX.Element => {
const dispatch = useDispatch();

const handleValue = (e: any) => {
const handleValue = (e: React.ChangeEvent<HTMLInputElement>): void => {
setValue(e.target.value);
};

Expand Down
5 changes: 2 additions & 3 deletions src/components/select/index.styles.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ export const ContainerSelect = styled.select`
height: 30px;
border-radius: 5px;
margin-top: 20px;
font-family: "Edu NSW ACT Foundation", cursive;
font-weight: 700;
font-family: "Edu NSW ACT Foundation", cursive;
font-weight: 700;
&:hover {
cursor: pointer;
}
Expand Down
9 changes: 5 additions & 4 deletions src/components/select/index.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { FC } from "react";
import { useDispatch } from "react-redux";
import { getSortingBooks } from "redux/reducer";
import { IPropsSelect } from "types";
import * as S from "./index.styles";

const Select = ({ value }:any) => {
const Select: FC<IPropsSelect> = ({ value }): JSX.Element => {
const dispatch = useDispatch();

const handleSortingBy = (e: any) => {
const queryParams = `${value}&orderBy=${e.target.value}`
//@ts-ignore
const handleSortingBy = (e: React.ChangeEvent<HTMLInputElement>): void => {
const queryParams = `${value}&orderBy=${e.target.value}`;
dispatch(getSortingBooks(queryParams));
};

Expand Down
4 changes: 2 additions & 2 deletions src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ body {
sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
};

code {
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
monospace;
}
};
1 change: 0 additions & 1 deletion src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import App from "./App";
import { Provider } from "react-redux";
import { store } from "redux/index";


const root = ReactDOM.createRoot(
document.getElementById("root") as HTMLElement,
);
Expand Down
37 changes: 37 additions & 0 deletions src/pages/description/index.styles.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import styled from "styled-components";

export const Container = styled.div`
display: flex;
max-width: 1400px;
width: 100%;
justify-content: space-around;
align-items: center;
min-height: 700px;
background-color: #cdcdcd;
border-radius: 20px;
img {
max-width: 700px;
width: 100%;
height: 500px;
}
.container__label {
max-width: 400px;
width: 100%;
}
.container__description {
max-width: 700px;
width: 100%;
.name {
max-width: 300px;
width: 100%;
}
.categories {
max-width: 300px;
width: 100%;
}
.authors {
max-width: 300px;
width: 100%;
}
}
`;
67 changes: 67 additions & 0 deletions src/pages/description/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import * as S from "./index.styles";
import { useSelector } from "react-redux";
import { Button } from "components/button";
import { Link } from "react-router-dom";
import { MagnifyingGlass } from "react-loader-spinner";
import { ICurrentState, IState } from "types";

const DescriptionPage = () => {
const bookImage = useSelector(
(state:ICurrentState) => state.books.book.data?.volumeInfo.imageLinks.smallThumbnail,
);
const bookName = useSelector(
(state:ICurrentState) => state.books.book.data?.volumeInfo.title,
);
const bookCategories = useSelector(
(state:ICurrentState) => state.books.book.data?.volumeInfo.categories,
);
const bookAuthors = useSelector(
(state:ICurrentState) => state.books.book.data?.volumeInfo.authors,
);
const bookDescription = useSelector(
(state:ICurrentState) => state.books.book.data?.volumeInfo.description,
);
const isLoading = useSelector((state:IState) => state.books?.loading);

return (
<S.Container>
{isLoading ? (
<MagnifyingGlass
visible={true}
height="110"
width="110"
ariaLabel="MagnifyingGlass-loading"
wrapperStyle={{ marginTop: "10px" }}
wrapperClass="MagnifyingGlass-wrapper"
glassColor="#c0efff"
color="#bb7d81"
/>
) : (
<>
<Link to="/*">
<Button buttonName={"Back"} className={"backbutton"} />
</Link>
<div className="container__label">
<img src={bookImage} alt="label of book" />
</div>
<div className="container__description">
<p className="name">
Name: <span className="namingBook">{bookName}</span>
</p>
<p className="categories">
Categories: <span className="namingBook">{bookCategories}</span>
</p>
<p className="authors">
Authors: <span className="namingBook">{bookAuthors}</span>
</p>
<p className="description">
Description: <span className="namingBook">{bookDescription}</span>
</p>
</div>
</>
)}
</S.Container>
);
};

export default DescriptionPage;
12 changes: 12 additions & 0 deletions src/pages/items/index.styles.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,22 @@ export const Container = styled.div`
gap: 15px;
min-height: calc(100vh - 200px);
.container__content {
text-decoration: none;
color: #000;
display: flex;
flex-direction: row;
flex-wrap: wrap;
justify-content: center;
gap: 30px;
a {
text-decoration: none;
color: #000;
max-width: 200px;
width: 100%;
display: flex;
flex-wrap: wrap;
}
}
`;
Loading

0 comments on commit 58fdb9d

Please sign in to comment.