Skip to content
Merged
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
46 changes: 4 additions & 42 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,45 +1,7 @@
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
## Link to the S3 bucket

## Available Scripts
http://node-aws-task.s3-website.eu-central-1.amazonaws.com/

In the project directory, you can run:
You can use NPM instead of YARN (Up to you)
## Link to the CloudFront distribution

### `yarn start` OR `npm run start`

Runs the app in the development mode.<br />
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.

The page will reload if you make edits.<br />
You will also see any lint errors in the console.

### `yarn test` OR `npm run test`

Launches the test runner in the interactive watch mode.<br />
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.

### `yarn build` OR `npm run build`

Builds the app for production to the `build` folder.<br />
It correctly bundles React in production mode and optimizes the build for the best performance.

The build is minified and the filenames include the hashes.<br />
Your app is ready to be deployed!

See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.

### `yarn eject` OR `npm run eject`

**Note: this is a one-way operation. Once you `eject`, you can’t go back!**

If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.

Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.

You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.

## Learn More

You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).

To learn React, check out the [React documentation](https://reactjs.org/).
https://d1s4qelxm95ilt.cloudfront.net/
9 changes: 5 additions & 4 deletions serverless.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
org: alimovdavron
app: node-in-aws-web
service: node-in-aws-web

frameworkVersion: '2'

provider:
name: aws
runtime: nodejs12.x
# setup profile for AWS CLI.
# profile: node-aws
region: eu-central-1

plugins:
- serverless-finch
Expand All @@ -17,7 +18,7 @@ plugins:

custom:
client:
bucketName: node-in-aws-web-bucket
bucketName: node-aws-task
distributionFolder: build
s3BucketName: ${self:custom.client.bucketName}

Expand All @@ -38,7 +39,7 @@ resources:
# VersioningConfiguration:
# Status: Enabled

## Specifying the policies to make sure all files inside the Bucket are avaialble to CloudFront
## Specifying the policies to make sure all files inside the Bucket are availalble to CloudFront
WebAppS3BucketPolicy:
Type: AWS::S3::BucketPolicy
Properties:
Expand Down
4 changes: 2 additions & 2 deletions src/components/MainLayout/MainLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function Copyright() {
<Typography variant="body2" color="textSecondary" align="center">
{'Copyright © '}
<Link color="inherit" href="https://material-ui.com/">
My Store
Book store
</Link>{' '}
{new Date().getFullYear()}
{'.'}
Expand Down Expand Up @@ -49,4 +49,4 @@ const MainLayout: React.FC = ({children}) => {
);
};

export default MainLayout;
export default MainLayout;
2 changes: 1 addition & 1 deletion src/components/MainLayout/components/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export default function Header() {
<AppBar position="relative">
<Toolbar>
<Typography variant="h6" className={classes.title}>
<Link className={classes.homeLink} to="/">My Store!</Link>
<Link className={classes.homeLink} to="/">Book store</Link>
</Typography>

{auth && (
Expand Down
6 changes: 3 additions & 3 deletions src/components/pages/PageProductForm/PageProductForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ export default function PageProductForm() {
const onSubmit = (values: FormikValues) => {
const formattedValues = ProductSchema.cast(values);
const productToSave = id ? {...ProductSchema.cast(formattedValues), id} : formattedValues;
axios.put(`${API_PATHS.bff}/product`, productToSave)
axios.post(`${API_PATHS.bff}/products`, productToSave)
.then(() => history.push('/admin/products'));
};

Expand All @@ -118,7 +118,7 @@ export default function PageProductForm() {
setIsLoading(false);
return;
}
axios.get(`${API_PATHS.bff}/product/${id}`)
axios.get(`${API_PATHS.bff}/products/${id}`)
.then(res => {
setProduct(res.data);
setIsLoading(false);
Expand All @@ -141,4 +141,4 @@ export default function PageProductForm() {
</Formik>
</PaperLayout>
);
}
}
11 changes: 6 additions & 5 deletions src/components/pages/PageProducts/components/Products.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@ import {makeStyles} from '@material-ui/core/styles';
import {Product} from "models/Product";
import {formatAsPrice} from "utils/utils";
import AddProductToCart from "components/AddProductToCart/AddProductToCart";
// import axios from 'axios';
// import API_PATHS from "constants/apiPaths";
import productList from "./productList.json";
import axios from 'axios';
import API_PATHS from "constants/apiPaths";

const useStyles = makeStyles((theme) => ({
card: {
Expand All @@ -38,7 +37,9 @@ export default function Products() {
useEffect(() => {
// axios.get(`${API_PATHS.bff}/product/available/`)
// .then(res => setProducts(res.data));
setProducts(productList);
axios.get(`${API_PATHS.bff}/products`)
.then(res => setProducts(res.data));
// setProducts(productList);
}, [])

return (
Expand All @@ -48,7 +49,7 @@ export default function Products() {
<Card className={classes.card}>
<CardMedia
className={classes.cardMedia}
image={`https://source.unsplash.com/random?sig=${index}`}
image={product.img_url}
title="Image title"
/>
<CardContent className={classes.cardContent}>
Expand Down
56 changes: 4 additions & 52 deletions src/components/pages/PageProducts/components/productList.json
Original file line number Diff line number Diff line change
@@ -1,58 +1,10 @@
[
{
"count": 4,
"description": "Short Product Description1",
"description": "A 1957 novel by Ayn Rand",
"id": "7567ec4b-b10c-48c5-9345-fc73c48a80aa",
"price": 2.4,
"title": "ProductOne"
},
{
"count": 6,
"description": "Short Product Description3",
"id": "7567ec4b-b10c-48c5-9345-fc73c48a80a0",
"price": 10,
"title": "ProductNew"
},
{
"count": 7,
"description": "Short Product Description2",
"id": "7567ec4b-b10c-48c5-9345-fc73c48a80a2",
"price": 23,
"title": "ProductTop"
},
{
"count": 12,
"description": "Short Product Description7",
"id": "7567ec4b-b10c-48c5-9345-fc73c48a80a1",
"price": 15,
"title": "ProductTitle"
},
{
"count": 7,
"description": "Short Product Description2",
"id": "7567ec4b-b10c-48c5-9345-fc73c48a80a3",
"price": 23,
"title": "Product"
},
{
"count": 8,
"description": "Short Product Description4",
"id": "7567ec4b-b10c-48c5-9345-fc73348a80a1",
"price": 15,
"title": "ProductTest"
},
{
"count": 2,
"description": "Short Product Descriptio1",
"id": "7567ec4b-b10c-48c5-9445-fc73c48a80a2",
"price": 23,
"title": "Product2"
},
{
"count": 3,
"description": "Short Product Description7",
"id": "7567ec4b-b10c-45c5-9345-fc73c48a80a1",
"price": 15,
"title": "ProductName"
"price": 30,
"title": "Atlas Shrugged",
"img_url": "https://images-na.ssl-images-amazon.com/images/I/81-N8W4ZgUL.jpg"
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ export default function ProductsTable() {
const [products, setProducts] = useState<any>([]);

useEffect(() => {
axios.get(`${API_PATHS.bff}/product`)
axios.get(`${API_PATHS.bff}/products`)
.then(res => setProducts(res.data));
}, []);

const onDelete = (id: string) => {
axios.delete(`${API_PATHS.bff}/product/${id}`)
axios.delete(`${API_PATHS.bff}/products/${id}`)
.then(() => {
axios.get(`${API_PATHS.bff}/product`)
axios.get(`${API_PATHS.bff}/products`)
.then(res => setProducts(res.data));
}
);
Expand Down Expand Up @@ -65,4 +65,4 @@ export default function ProductsTable() {
</Table>
</TableContainer>
);
}
}
2 changes: 1 addition & 1 deletion src/constants/apiPaths.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const API_PATHS = {
product: 'https://.execute-api.eu-west-1.amazonaws.com/dev',
order: 'https://.execute-api.eu-west-1.amazonaws.com/dev',
import: 'https://.execute-api.eu-west-1.amazonaws.com/dev',
bff: 'https://.execute-api.eu-west-1.amazonaws.com/dev',
bff: 'https://ki4323apmh.execute-api.eu-central-1.amazonaws.com/dev',
cart: 'https://.execute-api.eu-west-1.amazonaws.com/dev',
};

Expand Down
1 change: 1 addition & 0 deletions src/models/Product.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export type Product = {
title: string,
description: string,
price: number,
img_url: string,
};

export const ProductSchema = Yup.object().shape({
Expand Down
Loading