Skip to content

feature1 #55

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 2 commits into
base: master
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
83 changes: 0 additions & 83 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,84 +1 @@
# mern-ecommerce

> Frontend-> React JS

> Backend-> Node JS & Express JS

> Database-> MongoDB

## Installation process
1. #### clone the repo using this command
```bash
git clone https://github.com/ashraf-kabir/mern-ecommerce.git
```
2. #### install npm packages
1. install backend packages
```bash
cd mern-ecommerce
npm install
```
2. install frontend packages
```bash
cd client
npm install
```
3. go to the parent folder of mern-ecommerce & create .env for connection, JWT_SECRET, BRAINTREE_MERCHANT_ID, BRAINTREE_PUBLIC_KEY and BRAINTREE_PRIVATE_KEY.

```bash
cd mern-ecommerce
sudo nano .env
```
(ctrl+x to save & nano follow instruction there)

##### sample code for backend .env
```env
MONGODB_URI=YOUR_MONGODB_URI
JWT_SECRET=YOUR_JWT_SECRET
BRAINTREE_MERCHANT_ID=YOUR_BRAINTREE_MERCHANT_ID
BRAINTREE_PUBLIC_KEY=YOUR_BRAINTREE_PUBLIC_KEY
BRAINTREE_PRIVATE_KEY=YOUR_BRAINTREE_PRIVATE_KEY
```
4. create another .env file inside client directory for REACT_APP_API_URL.

```bash
cd mern-ecommerce/client
sudo nano .env
```
##### sample code for frontend .env
```env
REACT_APP_API_URL=YOUR_API_URL
```
##### Instructions:
1. for mongodb atlas database creation follow this tutorial->https://www.youtube.com/watch?v=KKyag6t98g8
2. you can use any random string as JWTSECRET
3. for localhost REACT_APP_API_URL is http://localhost:5000/api
but for heroku (server deployment) it will be different
4. #### note: add .env on .gitignore
5. for server deployment use secrets directly

5. <b>deploy this project</b> on your local server by using this command
```bash
cd mern-ecommerce
npm run dev
```
#### note: both backend & frontend server will start at once with the above command.

6. #### Database Structure: (Table: columns)
1. categories: _id, name, createdAt, updatedAt;
2. orders: _id, status, products (Array), transaction_id, amount, address, user (Object), createdAt, updatedAt
3. products: _id, photo (Object), sold, name, description, price, category, shipping, quantity, createdAt, updatedAt
4. users: _id, role, history (Array), name, email, salt, hashed_password, createdAt, updatedAt

### App Description:
1. user can view all products
2. user can view single product
3. user can search products and view products by category and price range
4. user can add to cart checkout products using credit card info
5. user can register & sign in
6. admin can create, edit, update & delete products
7. admin can create categories
8. admin can view ordered products
9. admin can change the status of a product (processing, shipped, delivered, etc.)

6. <b>Deployed on: (No longer available due to heroku free dyno plan has deprecated)</br> https://ecommerce-ak.herokuapp.com/
7. raise a star to support me
2 changes: 1 addition & 1 deletion client/src/App.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';

const App = () => <div>Hello from ashraf kabir</div>;
const App = () => <div>Hello </div>;

export default App;
2 changes: 1 addition & 1 deletion client/src/config.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const API = process.env.REACT_APP_API_URL || 'https://ecommerce-ak.herokuapp.com/api';
export const API = process.env.REACT_APP_API_URL ;
8 changes: 4 additions & 4 deletions client/src/core/Copyright.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ export default function Copyright() {
return (
<Box mt={8} mb={4}>
<Typography variant='body2' color='textSecondary' align='center'>
{'Copyright © '}

<Link color='inherit' href='#'>
Ashraf Kabir

</Link>{' '}
{new Date().getFullYear()}
{'.'}


</Typography>
</Box>
);
Expand Down
44 changes: 22 additions & 22 deletions client/src/core/Home.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,30 +11,30 @@ const Home = () => {
const [productsByArrival, setProductsByArrival] = useState([]);
const [error, setError] = useState([]);

const loadProductsBySell = () => {
getProducts('sold').then((data) => {
if (data.error) {
setError(data.error);
} else {
setProductsBySell(data);
}
});
};
// const loadProductsBySell = () => {
// getProducts('sold').then((data) => {
// if (data.error) {
// setError(data.error);
// } else {
// setProductsBySell(data);
// }
// });
// };

const loadProductsByArrival = () => {
getProducts('createdAt').then((data) => {
if (data.error) {
setError(data.error);
} else {
setProductsByArrival(data);
}
});
};
// const loadProductsByArrival = () => {
// getProducts('createdAt').then((data) => {
// if (data.error) {
// setError(data.error);
// } else {
// setProductsByArrival(data);
// }
// });
// };

useEffect(() => {
loadProductsByArrival();
loadProductsBySell();
}, []);
// useEffect(() => {
// loadProductsByArrival();
// // loadProductsBySell();
// }, []);

return (
<Layout
Expand Down
26 changes: 13 additions & 13 deletions client/src/core/Search.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,19 @@ const Search = () => {

const { categories, category, search, results, searched } = data;

const loadCategories = () => {
getCategories().then((data) => {
if (data.error) {
console.log(data.error);
} else {
setData({ ...data, categories: data });
}
});
};

useEffect(() => {
loadCategories();
}, []);
// const loadCategories = () => {
// getCategories().then((data) => {
// if (data.error) {
// console.log(data.error);
// } else {
// setData({ ...data, categories: data });
// }
// });
// };

// useEffect(() => {
// loadCategories();
// }, []);

const searchData = () => {
// console.log(search, category);
Expand Down