Skip to content

Commit b039c0f

Browse files
author
Subhash Kandhway
committed
first commit
0 parents  commit b039c0f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+47042
-0
lines changed

.gitignore

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.js
7+
8+
# testing
9+
/coverage
10+
11+
# production
12+
/build
13+
14+
# misc
15+
.DS_Store
16+
.env.local
17+
.env.development.local
18+
.env.test.local
19+
.env.production.local
20+
.env
21+
npm-debug.log*
22+
yarn-debug.log*
23+
yarn-error.log*
24+
25+
# Local Netlify folder
26+
.netlify

README.md

+78
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# E-commerce Website - Detailed Functionality
2+
3+
## Website Images
4+
![image](https://github.com/Subhash002/capstonecommerce/assets/29842088/d7b3f457-b731-4f0f-8db1-d2284690a160)
5+
![image](https://github.com/Subhash002/capstonecommerce/assets/29842088/b85f4515-49d8-4edd-ba56-55d84720b856)
6+
![image](https://github.com/Subhash002/capstonecommerce/assets/29842088/3cc9feed-3dd2-4ade-b499-f4620fe4cd51)
7+
![image](https://github.com/Subhash002/capstonecommerce/assets/29842088/f5982a8b-d72f-488f-bcf9-7861ec4a2ba8)
8+
![image](https://github.com/Subhash002/capstonecommerce/assets/29842088/659129e3-8b6f-4847-adf7-9314eb303de1)
9+
![image](https://github.com/Subhash002/capstonecommerce/assets/29842088/e2f905ab-f35f-4a4d-9229-7a9aab93317d)
10+
![image](https://github.com/Subhash002/capstonecommerce/assets/29842088/94929f6c-14fb-4b01-a3dd-1e3b5a6babb1)
11+
![image](https://github.com/Subhash002/capstonecommerce/assets/29842088/4552cfab-0fc2-4f98-9625-5f0f4da4b1b3)
12+
![image](https://github.com/Subhash002/capstonecommerce/assets/29842088/e4b1fdac-dccf-4455-bc05-e4d82e48d535)
13+
![image](https://github.com/Subhash002/capstonecommerce/assets/29842088/68015fce-8cbe-43db-b7ee-602d929d04f0)
14+
15+
16+
17+
18+
This document provides a comprehensive description of the features and functionality of our e-commerce website. Our goal is to offer users a seamless shopping experience with secure payment processing, efficient state management, and interactive customer support.
19+
20+
## State Management
21+
22+
We leverage React's powerful Context API along with `useContext` and `useReducer` hooks to manage the application's state. This approach allows us to centralize and efficiently handle the state across various components. Custom hooks are implemented to maintain a single source of truth for data and enable smooth data retrieval and updates.
23+
24+
## Routing
25+
26+
For smooth and responsive navigation, we utilize the latest version of React Router. This ensures that users can move between different pages without experiencing full-page reloads, resulting in a more enjoyable user experience.
27+
28+
## Contexts
29+
30+
Our application employs four main contexts to manage different aspects of the app:
31+
32+
1. **Cart Context**: The Cart Context effectively manages the user's shopping cart. It provides functionality to add, remove, and update items, ensuring a seamless shopping experience for customers.
33+
34+
2. **Filter Context**: With the Filter Context, users can refine their product search based on various filters. This feature enhances usability and allows customers to find products that match their specific criteria.
35+
36+
3. **Product Context**: The Product Context centralizes product data, providing a unified store for all product-related information. This helps streamline data management and ensures data consistency throughout the application.
37+
38+
4. **Auth Context (Auth0)**: To ensure secure user authentication and account management, we implement the Auth Context using Auth0. This feature allows users to log in and log out securely and manage their accounts hassle-free.
39+
40+
## Payment Processing
41+
42+
We integrate Stripe, a widely used and reliable payment processing platform, to handle payments securely and efficiently. Stripe ensures that customer payment information is handled with the highest level of security and compliance.
43+
44+
## Backend
45+
46+
For backend management, we utilize Airtable as our Content Management System (CMS). Airtable simplifies product data management, enabling us to update and retrieve information with ease. This setup ensures that our backend operations are efficient and reliable.
47+
48+
## Live Chatbot
49+
50+
Our website boasts an interactive live chatbot that provides real-time assistance to users. This feature enhances customer support and allows users to get immediate answers to their queries.
51+
52+
- **Agent Interaction**: The chatbot is designed to interact with customer service agents seamlessly. If the chatbot cannot resolve an issue, it transfers the conversation to a human agent, ensuring that customers receive the necessary support.
53+
54+
## Notifications and Loading Handling
55+
56+
- **React-Toastify**: To keep users informed about crucial events and display error messages, we use React-Toastify. These toaster notifications provide instant feedback to users during various interactions.
57+
58+
- **Loading Component**: For improved user experience during loading processes, we implement a loading component that provides visual feedback when data is being fetched or operations are in progress. This ensures that users are aware of ongoing processes, reducing frustration.
59+
60+
## Protected Routes
61+
62+
To safeguard sensitive information and ensure privacy, we implement private routes for checkout and payment. These private routes can only be accessed by authenticated users, enhancing security throughout the transaction process.
63+
64+
## End-to-End Features
65+
66+
Our e-commerce website aims to provide a complete digital purchasing experience from product discovery to checkout and payment. We strive to deliver a user-friendly platform that simplifies the entire shopping journey for customers.
67+
68+
## Product Filters
69+
70+
Our website features multiple filters, allowing users to narrow down their search results based on their preferences. This feature enhances product discoverability and ensures that users can easily find products that meet their specific needs.
71+
72+
## Deployment
73+
74+
- **Netlify**: We deploy our application to Netlify, a reliable hosting and deployment platform. Netlify ensures accessibility, scalability, and high performance for our website.
75+
76+
- **Netlify Serverless Functions**: We utilize Netlify's serverless functions to facilitate communication with the Stripe platform for secure and seamless payment processing. This setup ensures that payment operations are reliable and efficient.
77+
78+
By incorporating these features into our e-commerce website, we provide users with a robust and enjoyable shopping experience. Our website focuses on security, efficiency, and user satisfaction, making it an ideal platform for digital purchases.

functions/create-payment-intent.js

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
const dotenv = require("dotenv");
2+
dotenv.config();
3+
const stripe = require("stripe")(process.env.REACT_APP_STRIPE_API_KEY);
4+
exports.handler = async function (event, context) {
5+
const { shipping_fee, total_amount } = JSON.parse(event.body);
6+
7+
const calculateOrderAmount = () => {
8+
// Replace this constant with a calculation of the order's amount
9+
// Calculate the order total on the server to prevent
10+
// people from directly manipulating the amount on the client
11+
return shipping_fee + total_amount;
12+
};
13+
try {
14+
// Create a PaymentIntent with the order amount and currency
15+
const paymentIntent = await stripe.paymentIntents.create({
16+
amount: calculateOrderAmount(),
17+
currency: "inr",
18+
});
19+
return {
20+
statusCode: 200,
21+
body: JSON.stringify({ clientSecret: paymentIntent.client_secret }),
22+
};
23+
} catch (error) {
24+
return {
25+
statusCode: 500,
26+
body: JSON.stringify({ error: error.message }),
27+
};
28+
}
29+
};

functions/hello.js

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
exports.handler = async function (event, context) {
2+
return {
3+
statusCode: 200,
4+
body: "Hello Js",
5+
};
6+
};

functions/products.js

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
const dotenv = require("dotenv");
2+
dotenv.config();
3+
4+
let Airtable = require("airtable-node");
5+
const airtable = new Airtable({ apiKey: process.env.REACT_APP_AIRTABLE_KEY })
6+
.base(process.env.REACT_APP_AIRTABLE_BASE)
7+
.table(process.env.REACT_APP_AIRTABLE_TABLE);
8+
9+
exports.handler = async (event, context, cb) => {
10+
try {
11+
const response = await airtable.list({ maxRecords: 200 });
12+
13+
const products = response.records.map((product) => {
14+
const { id, fields } = product;
15+
const {
16+
name,
17+
featured,
18+
price,
19+
colors,
20+
company,
21+
description,
22+
category,
23+
shipping,
24+
images,
25+
} = fields;
26+
const { url } = images[0];
27+
28+
return {
29+
id,
30+
featured: featured === undefined ? false : true,
31+
name,
32+
price,
33+
colors,
34+
company,
35+
description,
36+
category,
37+
shipping: shipping === undefined ? false : true,
38+
image: url,
39+
};
40+
});
41+
// console.log(products);
42+
return {
43+
statusCode: 200,
44+
body: JSON.stringify(products),
45+
};
46+
} catch (error) {
47+
console.log(error);
48+
return {
49+
statusCode: 500,
50+
body: "There was an error processing",
51+
};
52+
}
53+
};
54+
55+
// REACT_APP_AIRTABLE_KEY
56+
// REACT_APP_AIRTABLE_BASE
57+
// REACT_APP_AIRTABLE_TABLE

functions/single-product.js

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
const dotenv = require("dotenv");
2+
dotenv.config();
3+
4+
let Airtable = require("airtable-node");
5+
const airtable = new Airtable({ apiKey: process.env.REACT_APP_AIRTABLE_KEY })
6+
.base(process.env.REACT_APP_AIRTABLE_BASE)
7+
.table(process.env.REACT_APP_AIRTABLE_TABLE);
8+
9+
exports.handler = async (event, context, cb) => {
10+
const { id } = event.queryStringParameters;
11+
if (id) {
12+
try {
13+
let product = await airtable.retrieve(id);
14+
if (product.error) {
15+
return {
16+
statusCode: 404,
17+
body: `No product with id: ${id}`,
18+
};
19+
}
20+
product = { id: product.id, ...product.fields };
21+
return {
22+
statusCode: 200,
23+
body: JSON.stringify(product),
24+
};
25+
} catch (error) {
26+
return {
27+
statusCode: 500,
28+
body: `Server Error`,
29+
};
30+
}
31+
}
32+
return {
33+
statusCode: 400,
34+
body: "Please provide product id",
35+
};
36+
};

netlify.toml

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[build]
2+
functions = "./functions"

0 commit comments

Comments
 (0)