Skip to content

Commit

Permalink
new features
Browse files Browse the repository at this point in the history
  • Loading branch information
ShinokiX3 committed May 22, 2023
1 parent af4a16f commit 7fb0a8b
Show file tree
Hide file tree
Showing 58 changed files with 1,662 additions and 1,308 deletions.
Binary file added design/images/78913.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added design/images/Zhivchik_15.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added design/images/maxresdefault.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 4 additions & 20 deletions design/images/promo.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,5 @@
import promo2 from './51wdlDCbVHL._SX3000_.jpg';
import promo1 from './6167vdrHU-L._SX3000_.jpg';
import promo3 from './61DUO0NqyyL._SX3000_.jpg';
import promo4 from './61TD5JLGhIL._SX3000_.jpg';
import promo5 from './61Y1w2JbF2L._SX3000_.jpg';
import promo6 from './61jovjd+f9L._SX3000_.jpg';
import promo7 from './717kU6K3R2L._SX3000_.jpg';
import promo8 from './71bmrI6EfqL._SX3000_.jpg';
import promo9 from './71qid7QFWJL._SX3000_.jpg';
import promo1 from './78913.jpg';
import promo2 from './Zhivchik_15.jpg';
import promo3 from './maxresdefault.jpg';

export const promo = [
promo1,
promo2,
promo3,
promo4,
promo5,
promo6,
promo7,
promo8,
promo9,
];
export const promo = [promo2, promo1, promo3];
Binary file added design/images/sasd.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 0 additions & 9 deletions src/api/amazonApi.ts

This file was deleted.

2 changes: 1 addition & 1 deletion src/api/serverApi.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import axios from 'axios';

export const serverApi = axios.create({
baseURL: 'https://store-server-eight.vercel.app',
baseURL: 'http://localhost:3000',
headers: {
'Content-Type': 'application/json',
},
Expand Down
30 changes: 30 additions & 0 deletions src/api/serverApiClient.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import axios from 'axios';

export const serverApiClient = axios.create({
baseURL: 'http://localhost:3000',
headers: {
'Content-Type': 'application/json',
},
});

serverApiClient.interceptors.request.use(
(config) => {
config.headers = {
authorization: `Bearer ${localStorage.getItem('token')}`,
};

return config;
},
(error) => {}
);

serverApiClient.interceptors.response.use(
(config) => {
config.headers = {
authorization: `Bearer ${localStorage.getItem('token')}`,
};

return config;
},
(error) => {}
);
44 changes: 19 additions & 25 deletions src/components/layout/Layout.tsx
Original file line number Diff line number Diff line change
@@ -1,47 +1,41 @@
import React, { useEffect, useState } from 'react';
import Header from './header/Header';

import { AmazonCategory } from '@/services/Amazon/AmazonCategory';
import { IAmazonCategory } from '@/types/categories.interface';
import DrawCategory from '../ui/drawer/DrawCategory';
import { CategoryService } from '@/services/Server/ServerCategory';

interface ILayout {
children?: React.ReactNode;
children?: React.ReactNode;
}

// TODO: change categories variable to object like {data, changeData, loading, error} or set 'em to redux storage

const Layout: React.FC<ILayout> = ({ children }) => {
const [categories, setCategories] = useState<IAmazonCategory[] | null>(null);
const [loading, setLoading] = useState(false);

useEffect(() => {
setLoading(true);
(async () => {
const response = await AmazonCategory.getAllCategories()
console.log(response);

const [categories, setCategories] = useState<any>(null);
const [loading, setLoading] = useState(false);

useEffect(() => {
setLoading(true);
(async () => {
const response = await CategoryService.getAllCategories();
if (response) {
setCategories(response)
} else setCategories([])
setLoading(false);
})()
setCategories(response);
} else setCategories([]);
setLoading(false);
})();
}, []);

if (loading) return <div>Loading...</div>
if (loading) return <div>Loading...</div>;

// TODO: create recurcive function for fetching data

return (
<main style={{width: '100%'}}>
<main style={{ width: '100%' }}>
<Header />
<DrawCategory categories={categories} />
<section style={{display: 'flex'}}>
{children}
</section>
<section style={{ display: 'flex' }}>{children}</section>
</main>
)
}
);
};

export default Layout
export default Layout;
1 change: 1 addition & 0 deletions src/components/layout/auth/LoginForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const LoginForm: React.FC<ILoginForm> = ({ children }) => {

if (resp?.token) {
setStatus('success');
localStorage.setItem('token', resp.token);
login({ token: resp.token, user: resp.user[0] });
} else setStatus('error');

Expand Down
5 changes: 4 additions & 1 deletion src/components/layout/header/Logo.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { useActions } from '@/hooks/useActions';
import { useTypedSelector } from '@/hooks/useTypedSelector';
import { MenuOutlined } from '@ant-design/icons';
import Link from 'next/link';
import styled from 'styled-components';

const StyledLogo = styled.span`
Expand Down Expand Up @@ -29,7 +30,9 @@ const Logo = () => {
style={{ width: '20px', height: '20px' }}
onClick={() => toggleUpperDrawer(!user.upperDrawer)}
/>
<h3>Shinoki store</h3>
<Link href={`/`} style={{ textDecoration: 'none' }}>
<h3 style={{ color: 'black', paddingTop: '5px' }}>Оболонь Маркет</h3>
</Link>
</StyledLogo>
);
};
Expand Down
Loading

0 comments on commit 7fb0a8b

Please sign in to comment.