Skip to content

Create basic app structure. Add deploy-dev pipeline #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion .github/workflows/deploy-dev.yml
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

really minor, but could you please make the step names consistent with the 1st action

image

Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,16 @@ jobs:
with:
node-version: 18

- name: Configure git profile
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it really needed now? Since I don't remember that we used it on the previous project. Maybe the issue is in the token permissions or the token type? I think I used the classic token type
image

run: |
git config --global user.email "amsterget@gmail.com"
git config --global user.name "amsterget"
git remote set-url origin https://${{ secrets.GIT_HUB_PERSONAL_TOKEN }}@github.com/${{ github.repository }}

- name: Install of node dependencies
run: sh install-modules.sh
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GIT_HUB_PERSONAL_TOKEN }}

- name: Deploy
run: npm run deploy
2 changes: 1 addition & 1 deletion install-modules.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
source ./.env

npm config set //npm.pkg.github.com/:_authToken=${GITHUB_TOKEN}
npm config set //npm.pkg.github.com/:_authToken=${GITHUB_TOKEN}
npm config set @aikray:registry=https://npm.pkg.github.com/

npm install
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,13 @@
},
"dependencies": {
"@aikray/menu-bot-common": "^0.0.8",
"@ant-design/icons": "^5.0.1",
"@emotion/react": "^11.10.6",
"@emotion/styled": "^11.10.6",
"@fontsource/roboto": "^4.5.8",
"@mui/icons-material": "^5.11.9",
"@mui/material": "^5.11.9",
"antd": "^5.2.2",
"classnames": "^2.3.2",
"react": "^18.2.0",
"react-dom": "^18.2.0",
Expand Down
38 changes: 2 additions & 36 deletions src/App.css
Original file line number Diff line number Diff line change
@@ -1,38 +1,4 @@
.App {
text-align: center;
}

.App-logo {
height: 40vmin;
pointer-events: none;
}

@media (prefers-reduced-motion: no-preference) {
.App-logo {
animation: App-logo-spin infinite 20s linear;
}
}

.App-header {
background-color: #282c34;
min-height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
font-size: calc(10px + 2vmin);
color: white;
}

.App-link {
color: #61dafb;
}

@keyframes App-logo-spin {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
height: 100%;
width: 100%;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Width is 100% by default, sicne it's a <div>, so please remove this prop

}
28 changes: 8 additions & 20 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,42 +1,30 @@
import './App.css';

import { fetchQuery } from 'core/fetchQuery';
import { useEffect, useState } from 'react';
import { useEffect } from 'react';

import logo from './logo.svg';
import { InitialDataProvider } from './providers/initial-data-provider';
import { Router } from './routes/Router';

export const App = () => {
const [appStatus, setAppStatus] = useState('');

useEffect(() => {
const getAppStatus = async () => {
const response = await fetchQuery<{ status: string }>({
path: `/app/health-check`,
});

setAppStatus(response.status);
// eslint-disable-next-line no-console
console.log(response.status);
};

getAppStatus();
}, []);

return (
<div className="App">
<header className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<h1>App Status: {appStatus}</h1>
<p>
Edit <code>src/App.tsx</code> and save to reload.
</p>
<a
className="App-link"
href="https://reactjs.org"
target="_blank"
rel="noopener noreferrer"
>
Learn React
</a>
</header>
<InitialDataProvider>
<Router />
</InitialDataProvider>
</div>
);
};
4 changes: 4 additions & 0 deletions src/core/styles/variables.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
:root {
--color-primary: #1677ff;
--color-default: #555;
}
14 changes: 14 additions & 0 deletions src/index.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
@import "./core/styles/variables.css";

html {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can combine html, root, body common styles

height: 100%;
width: 100%;
}

#root {
height: 100%;
width: 100%;
}

body {
height: 100%;
width: 100%;
margin: 0;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
Expand Down
1 change: 0 additions & 1 deletion src/logo.svg

This file was deleted.

22 changes: 22 additions & 0 deletions src/pages/common/footer/Footer.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
.footer {
position: fixed;
bottom: 0;
width: 100%;
padding: 20px 0;
border-top: 1px solid var(--color-primary);
}

.navigation {
display: flex;
align-items: center;
justify-content: center;
gap: 20px;
}

.nav-icon {
font-size: 40px;
color: var(--color-default);
}
.nav-icon.active {
color: var(--color-primary);
}
37 changes: 37 additions & 0 deletions src/pages/common/footer/Footer.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { ShopOutlined, UserOutlined } from '@ant-design/icons';
import classNames from 'classnames/bind';
import { NavLink } from 'react-router-dom';

import { PROFILE_PAGE, RESTAURANTS_PAGE } from '../../../routes/pages';
import styles from './Footer.module.css';

const cx = classNames.bind(styles);

interface FooterProps {}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it needed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually no, until we will paste some page specific props to Footer.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So let's remove the dead code for now?


const navItems = [
{
id: 'restaurants',
to: RESTAURANTS_PAGE,
icon: ShopOutlined,
},
{
id: 'profile',
to: PROFILE_PAGE,
icon: UserOutlined,
},
];

export const Footer = (_: FooterProps) => (
<footer className={cx('footer')}>
<nav className={cx('navigation')}>
{navItems.map(({ id, to, icon: Icon }) => (
<NavLink key={id} to={to}>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use to as key and remove id?

{({ isActive }) => (
<Icon className={cx('nav-icon', isActive ? 'active' : '')} />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More readable:

Suggested change
<Icon className={cx('nav-icon', isActive ? 'active' : '')} />
<Icon className={cx('nav-icon', { active: isActive })} />

)}
</NavLink>
))}
</nav>
</footer>
);
1 change: 1 addition & 0 deletions src/pages/common/footer/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './Footer';
6 changes: 6 additions & 0 deletions src/pages/profile-page/ProfilePage.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.profile-page {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest removing all unused styles/code to not forget to do that in the future. UI looks absolutely the same without this file.

display: flex;
flex-direction: column;
width: 100%;
height: 100%;
}
12 changes: 12 additions & 0 deletions src/pages/profile-page/ProfilePage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import classNames from 'classnames/bind';

import { Footer } from '../common/footer';
import styles from './ProfilePage.module.css';

const cx = classNames.bind(styles);

export const ProfilePage = () => (
<div className={cx('profile-page')}>
<Footer />
</div>
);
1 change: 1 addition & 0 deletions src/pages/profile-page/index.ts
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest not adding index.ts for individual components, but only for parent folders, in this case common, otherwise it will be too many files. I don't see any issues with 1 additional word in the import line. So let's use index.ts only to avoid the number of import lines in the file, but not the length of the individual line. Please remove these as well:

image

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './ProfilePage';
16 changes: 16 additions & 0 deletions src/pages/restaurants-page/RestaurantsPage.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
.restaurants-page {
display: flex;
flex-direction: column;
width: 100%;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also width prop can be removed and others styles if they are unused

height: 100%;
}

.current-city {
display: flex;
justify-content: center;
padding: 10px 5px;
}

.current-city a {
text-decoration: none;
}
44 changes: 44 additions & 0 deletions src/pages/restaurants-page/RestaurantsPage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { SearchOutlined } from '@ant-design/icons';
import Button from 'antd/lib/button';
import classNames from 'classnames/bind';
import { useContext } from 'react';
import { Link } from 'react-router-dom';

import { StoreContext } from '../../providers/store-provider';
import { SEARCH_PAGE } from '../../routes/pages';
import { Footer } from '../common/footer';
import {
SEARCH_TYPE_CITIES,
SEARCH_TYPE_RESTAURANTS,
} from '../search-page/constants';
import { NoCityBlock } from './no-city-block';
import styles from './RestaurantsPage.module.css';

const cx = classNames.bind(styles);

export const RestaurantsPage = () => {
const { selectedCity } = useContext(StoreContext);

return (
<div className={cx('restaurants-page')}>
{selectedCity ? (
<>
<span className={cx('current-city')}>
<Link to={SEARCH_PAGE} state={{ type: SEARCH_TYPE_CITIES }}>
{selectedCity}
</Link>
</span>
<Link to={SEARCH_PAGE} state={{ type: SEARCH_TYPE_RESTAURANTS }}>
<Button icon={<SearchOutlined />} size="large">
Restaurants
</Button>
</Link>
{/* TODO: Restaurants list will be here */}
</>
) : (
<NoCityBlock />
)}
<Footer />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the footer be visible for all pages i.e. be placed in the App.tsx? like the main menu (in Wolt this is always visible)

</div>
);
};
1 change: 1 addition & 0 deletions src/pages/restaurants-page/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './RestaurantsPage';
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.no-city-block {
display: flex;
align-items: center;
justify-content: center;
width: 100%;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, remove width prop

height: calc(100% - 80px);
}
20 changes: 20 additions & 0 deletions src/pages/restaurants-page/no-city-block/NoCityBlock.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { SearchOutlined } from '@ant-design/icons';
import Button from 'antd/lib/button';
import classNames from 'classnames/bind';
import { Link } from 'react-router-dom';

import { SEARCH_PAGE } from '../../../routes/pages';
import { SEARCH_TYPE_CITIES } from '../../search-page/constants';
import styles from './NoCityBlock.module.css';

const cx = classNames.bind(styles);

export const NoCityBlock = () => (
<div className={cx('no-city-block')}>
<Link to={SEARCH_PAGE} state={{ type: SEARCH_TYPE_CITIES }}>
<Button icon={<SearchOutlined />} size="large">
Choose City
</Button>
</Link>
</div>
);
1 change: 1 addition & 0 deletions src/pages/restaurants-page/no-city-block/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './NoCityBlock';
26 changes: 26 additions & 0 deletions src/pages/search-page/SearchPage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { useLocation } from 'react-router-dom';

import { SEARCH_TYPE_CITIES, SEARCH_TYPE_RESTAURANTS } from './constants';
import { CitiesSearch, RestaurantsSearch } from './supported-searches';

// TODO: change to some fallback
const EmptyComponent = () => <div />;

export const SearchPage = () => {
const { state: locationState } = useLocation();

let SearchComponent = EmptyComponent;

switch (locationState.type) {
case SEARCH_TYPE_CITIES:
SearchComponent = CitiesSearch;
break;
case SEARCH_TYPE_RESTAURANTS:
SearchComponent = RestaurantsSearch;
break;
default:
break;
}

return <SearchComponent />;
};
Comment on lines +1 to +26
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
import { useLocation } from 'react-router-dom';
import { SEARCH_TYPE_CITIES, SEARCH_TYPE_RESTAURANTS } from './constants';
import { CitiesSearch, RestaurantsSearch } from './supported-searches';
// TODO: change to some fallback
const EmptyComponent = () => <div />;
export const SearchPage = () => {
const { state: locationState } = useLocation();
let SearchComponent = EmptyComponent;
switch (locationState.type) {
case SEARCH_TYPE_CITIES:
SearchComponent = CitiesSearch;
break;
case SEARCH_TYPE_RESTAURANTS:
SearchComponent = RestaurantsSearch;
break;
default:
break;
}
return <SearchComponent />;
};
import { useLocation } from 'react-router-dom';
import { SearchType } from './constants';
import { CitiesSearch, RestaurantsSearch } from './supported-searches';
const searchComponentMap = new Map([
[SearchType.Cities, CitiesSearch],
[SearchType.Restaurants, RestaurantsSearch],
]);
export const SearchPage = () => {
const { state } = useLocation();
return searchComponentMap.get(state.type);
};
};

2 changes: 2 additions & 0 deletions src/pages/search-page/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export const SEARCH_TYPE_CITIES = 'cities';
export const SEARCH_TYPE_RESTAURANTS = 'restaurants';
Comment on lines +1 to +2
Copy link
Member

@skyRoma skyRoma May 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
export const SEARCH_TYPE_CITIES = 'cities';
export const SEARCH_TYPE_RESTAURANTS = 'restaurants';
export enum SearchType {
City,
Restaurant,
}

13 changes: 13 additions & 0 deletions src/pages/search-page/data.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const MINSK = 'Minsk';
const TBILISI = 'Tbilisi';
const MOSCOW = 'Moscow';
const TASHKENT = 'Tashkent';

export const supportedCities = [MINSK, TBILISI, MOSCOW, TASHKENT];

export const restaurantsByCities: { [name: string]: string[] } = {
[MINSK]: ['Vasilki', 'The View'],
[TBILISI]: ['Tiflis', 'Mimino'],
[MOSCOW]: ['Russkiy', 'Stolovaya'],
[TASHKENT]: ['Chaikhana', 'Plov!'],
};
1 change: 1 addition & 0 deletions src/pages/search-page/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './SearchPage';
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.search-with-list {
padding: 10px;
}

.entity-item {
display: block;
padding: 10px;
text-decoration: none;
}
Loading