Skip to content
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

Webify - Final Project Web Dev Bootcamp 2024 #48

Open
wants to merge 232 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 229 commits
Commits
Show all changes
232 commits
Select commit Hold shift + click to select a range
c236bdf
installed dependencies and connected to mongoDB
SofieFerrari May 29, 2024
dfcccb3
started working on usermodel, shecma and endpoints
SofieFerrari May 29, 2024
942f21e
Created delete endpoint on users/:id
wwenzz May 29, 2024
a318097
Create models, middleware, controllers and routes folder to break dow…
wwenzz May 29, 2024
7143f43
added jsonfile with webtemplates
SofieFerrari May 30, 2024
d037ec7
added data to mockup json objects
SofieFerrari May 30, 2024
bb350dc
created folders and files for products in backend
SofieFerrari May 31, 2024
0148076
Move product json to backend and seed data to the database
wwenzz May 31, 2024
0fe7e93
Create product controllers
wwenzz May 31, 2024
f1bec56
Remove try catch block and create gloabl error handling instead
wwenzz May 31, 2024
2bf60d9
Add id to response in login and change the post to get method for use…
wwenzz May 31, 2024
bc4b733
Add route and controller for liking or disliking a product
wwenzz May 31, 2024
4172376
Futher break down the backend by creating config file & folder for Mo…
wwenzz May 31, 2024
c77ecd0
change category to tag
maikanetaka Jun 3, 2024
9f1e29c
Implement cloudinary to upload images and update Product database
wwenzz Jun 3, 2024
df60290
categorized tags and added categories to json file
SofieFerrari Jun 3, 2024
d9d04e4
Clean up the mockup endpoints and create respective files
wwenzz Jun 3, 2024
c03dd72
added dependencies to local server for cloudinary
SofieFerrari Jun 3, 2024
c11fdd8
Configure the tailwind
wwenzz Jun 4, 2024
429e546
Create button jsx file
wwenzz Jun 4, 2024
f230d56
Finish button component
wwenzz Jun 4, 2024
2904acd
Merge pull request #1 from Wen/button-component
wwenzz Jun 4, 2024
4468c8a
Initialize header component branch
wwenzz Jun 4, 2024
4de1b4b
Finish the header component
wwenzz Jun 4, 2024
fcea82d
Merge pull request #2 from Wen/header-component
wwenzz Jun 4, 2024
47d452a
worked on footer in footer branch
SofieFerrari Jun 4, 2024
46bfe23
Initialise the zustand and router
wwenzz Jun 5, 2024
ccf9291
Add 2 colors to the color theme
wwenzz Jun 5, 2024
2aae544
worked on shop-element
SofieFerrari Jun 5, 2024
7a098b6
completed footer
SofieFerrari Jun 5, 2024
b57e8d5
removed code in app.jsx to avoid merge conflict
SofieFerrari Jun 5, 2024
0a2cab2
Merge pull request #3 from SofieFerrari/footer
SofieFerrari Jun 5, 2024
542b816
Create productCard component
wwenzz Jun 5, 2024
c50c7ae
Adjust button component and add hover + disabled effect
wwenzz Jun 5, 2024
3a41994
Merge pull request #4 from Wen/product-card
wwenzz Jun 5, 2024
ab3ec97
Create ProductDetailsCard component
wwenzz Jun 5, 2024
ffa8993
Merge pull request #5 from Wen/product-details-card
wwenzz Jun 5, 2024
ea36a97
Create seededData for storing the updated database
wwenzz Jun 5, 2024
11b003a
Create Form component
maikanetaka Jun 5, 2024
a81ed64
add style
maikanetaka Jun 5, 2024
f08c8a7
style Form for mobile
maikanetaka Jun 5, 2024
066ada1
Style Form for laptop
maikanetaka Jun 6, 2024
196a411
Add category into both productDetailCard and ProductCard
wwenzz Jun 6, 2024
a549687
Merge pull request #6 from SofieFerrari/form
maikanetaka Jun 6, 2024
23f2325
Complete Form and edit login and signup pages
maikanetaka Jun 6, 2024
4807d89
Complete Form component
maikanetaka Jun 6, 2024
0e6b11b
Fix the header and remove sticky
wwenzz Jun 6, 2024
bfc1a59
Replace a tags with NavLink in the header components
wwenzz Jun 6, 2024
9aa783b
Upload image for hero section
wwenzz Jun 6, 2024
d685bf5
Create not found page
maikanetaka Jun 6, 2024
56df0fa
Put contents in notFound page
maikanetaka Jun 6, 2024
55ec881
Update NotFound page
maikanetaka Jun 6, 2024
9f20785
Create signup page
maikanetaka Jun 6, 2024
fc60d9f
Remove header and footer from Signup page
maikanetaka Jun 6, 2024
027ff4c
Merge pull request #8 from SofieFerrari/signup
maikanetaka Jun 6, 2024
ae6acd1
Create Login page
maikanetaka Jun 6, 2024
1eaac59
remove header and footer component
maikanetaka Jun 6, 2024
e9351a1
Add h1
maikanetaka Jun 6, 2024
b59d1bb
re-create signup page
maikanetaka Jun 6, 2024
6bce9d2
Merge pull request #9 from SofieFerrari/login
maikanetaka Jun 6, 2024
43b3a8d
add not-found graphic in asset file
maikanetaka Jun 6, 2024
a3b3b12
Style NotFound page
maikanetaka Jun 6, 2024
6d912fc
Merge pull request #10 from SofieFerrari/notfound
maikanetaka Jun 6, 2024
117745c
OrderConfirmation page
maikanetaka Jun 6, 2024
6274960
Merge pull request #11 from SofieFerrari/order-confirmation
maikanetaka Jun 6, 2024
e9ab00e
Create breadcrumb component
maikanetaka Jun 6, 2024
0e6f5c5
fix cursor pointer in breadcrumb
maikanetaka Jun 6, 2024
193edb5
import breadcrumb components
maikanetaka Jun 6, 2024
801581a
fix display path name and remove cursor ponter from icon
maikanetaka Jun 6, 2024
bc46c3a
Merge pull request #12 from SofieFerrari/breadcrumb
maikanetaka Jun 6, 2024
2bf40ad
we fixed the card
SofieFerrari Jun 7, 2024
dae0765
made pull from main and added breadcrumb to checkout
SofieFerrari Jun 7, 2024
13309de
Add Cartlist component
wwenzz Jun 7, 2024
8ce040f
Create components for Homepage and setuo material tailwind
wwenzz Jun 6, 2024
0be5de0
Create testimonial and category card components for homepage
wwenzz Jun 7, 2024
a7424a8
Add Cartlist component (#13)
SofieFerrari Jun 7, 2024
84e4f72
Create category card
wwenzz Jun 7, 2024
537782a
Merge pull request #14 from Wen/homepage
wwenzz Jun 7, 2024
8f21361
Add navigation to button and header
wwenzz Jun 7, 2024
f30b6ef
worked in cart and cartitem
SofieFerrari Jun 7, 2024
05f1ca6
Merge branch 'main' into cart
SofieFerrari Jun 7, 2024
b1c15b4
Merge pull request #15 from SofieFerrari/cart
SofieFerrari Jun 7, 2024
a78e0a5
fix text with ' in NotFound page
maikanetaka Jun 7, 2024
7824393
adding proptypes for category om ProductDetailsCard component
maikanetaka Jun 7, 2024
d4f241a
Add ProductDetail page
maikanetaka Jun 7, 2024
1fe7f4b
change name of path - image and template to match the json data
maikanetaka Jun 7, 2024
cc0ec26
Fix Breadcrumb component to display template name instead of id
maikanetaka Jun 7, 2024
9dda8f4
Merge pull request #16 from SofieFerrari/product-detail
maikanetaka Jun 7, 2024
08ba6f8
Create dropdown component for checkout page
wwenzz Jun 9, 2024
39744dd
Finish the checkout page
wwenzz Jun 9, 2024
b46cae3
Merge pull request #17 from SofieFerrari/checkout
wwenzz Jun 10, 2024
8f0ca9a
change product detail url to products
wwenzz Jun 10, 2024
ea06795
Add netlify.toml file for deploy
wwenzz Jun 10, 2024
27d688a
adding specified link on cors
maikanetaka Jun 10, 2024
5398a16
change fetch url to VITE_API_URL
maikanetaka Jun 10, 2024
efdd14a
consolee
maikanetaka Jun 10, 2024
c237627
fix the bug and remove console.log
maikanetaka Jun 10, 2024
2911660
add "PATCH" in cors
maikanetaka Jun 10, 2024
1997187
Finish mypage
wwenzz Jun 10, 2024
c56c5cb
Merge pull request #18 from SofieFerrari/myPage
wwenzz Jun 10, 2024
00e03b2
add ProductList without styling
maikanetaka Jun 10, 2024
f610685
change tag in productCard
maikanetaka Jun 10, 2024
2019bd6
change margin to padding
maikanetaka Jun 10, 2024
421d4d9
Adjust styling for desktop
maikanetaka Jun 10, 2024
86a8446
Style for ProductList page
maikanetaka Jun 10, 2024
b78c155
Add h1
maikanetaka Jun 10, 2024
1f0f719
Add search and filter features
maikanetaka Jun 10, 2024
0ababfc
add icons
maikanetaka Jun 10, 2024
729a942
styling for filters and search bar
maikanetaka Jun 10, 2024
3b70ffc
fix the styling
maikanetaka Jun 11, 2024
2ced3cc
Merge pull request #19 from SofieFerrari/products-list
maikanetaka Jun 11, 2024
91bd74d
adjust codes to move in useProductStore
maikanetaka Jun 11, 2024
4f1588e
Link product items in ProductList page to each product detail page
maikanetaka Jun 11, 2024
bab75b1
fix small styling in ProductList and tags in ProductDetailsCard
maikanetaka Jun 11, 2024
0732eb8
Create Pagnation component
maikanetaka Jun 11, 2024
e50fa20
Style for Pafination
maikanetaka Jun 11, 2024
7e1d70f
Create heart icon and side drawer components
wwenzz Jun 11, 2024
619bd2a
update Pagination to show only page number if there are products
maikanetaka Jun 11, 2024
1af1ffe
Update ProductList to show pagination with search feature
maikanetaka Jun 11, 2024
942bbfd
Merge pull request #20 from SofieFerrari/fix-product-list-v1
maikanetaka Jun 11, 2024
8249a97
Build connection with backend and global states to display like and u…
wwenzz Jun 11, 2024
4b6f2c1
rename the heart component, map specific state and remove loading to …
wwenzz Jun 11, 2024
a28ea02
Merge branch 'main' into cart-func
wwenzz Jun 11, 2024
0cd9f75
Merge pull request #21 from SofieFerrari/cart-func
wwenzz Jun 11, 2024
e26b5b6
Fix the Id reference after merge conflicts
wwenzz Jun 11, 2024
58a4654
trying to fix navlinks in footer
SofieFerrari Jun 11, 2024
be5f635
worked on categoryPage
SofieFerrari Jun 11, 2024
15fa322
Upload icons and graphics
maikanetaka Jun 11, 2024
e97e218
Create ProfileCard component
maikanetaka Jun 11, 2024
0b06cce
Create AboutUs page
maikanetaka Jun 11, 2024
a062921
fix bugs
maikanetaka Jun 11, 2024
3a0b28a
Add users/:id/cart and user/:id/favorites endpoints for handling cart…
wwenzz Jun 11, 2024
648e304
make tags to be selectable
maikanetaka Jun 11, 2024
34890eb
Make the cart and like connects to the backend and stored in the sess…
wwenzz Jun 11, 2024
2047354
Merge pull request #22 from SofieFerrari/cart-like-backend
wwenzz Jun 11, 2024
25575c0
Add delete endpoint back
wwenzz Jun 12, 2024
2691a6d
deleted work in categorypage and approute
SofieFerrari Jun 12, 2024
59a10cb
Merge pull request #23 from SofieFerrari/fixingfooter
SofieFerrari Jun 12, 2024
a1b37b5
Merge branch 'main' into about-us
maikanetaka Jun 12, 2024
39b3d24
Merge pull request #24 from SofieFerrari/about-us
maikanetaka Jun 12, 2024
ff5411f
add AboutUs in AppRoute
maikanetaka Jun 12, 2024
672e010
update email adress
maikanetaka Jun 12, 2024
82c2d2a
remove the wrong data in package.json
maikanetaka Jun 12, 2024
e62785f
have a category in footer
maikanetaka Jun 12, 2024
2241bf7
Implement logout button and clean up the comments
maikanetaka Jun 12, 2024
7205f95
Add link for the categories in Homepage
maikanetaka Jun 12, 2024
b4f1677
Add clear cart function and connect to the backend
wwenzz Jun 12, 2024
3811e3f
Merge pull request #25 from SofieFerrari/clear-cart
wwenzz Jun 12, 2024
7bec918
Disable continue button when no items in the cart
wwenzz Jun 12, 2024
dd887f0
Hero products link to the product detail pag
maikanetaka Jun 12, 2024
bfa5dd0
Change the header picture
maikanetaka Jun 12, 2024
fe9c7b7
By categories to be 1 col in mobile and fix paddings and margins
maikanetaka Jun 12, 2024
5e586a4
Change graphics imported from Unsplash to actual jpeg to reduce size
maikanetaka Jun 12, 2024
61d22d9
Merge pull request #26 from SofieFerrari/homepage-styling
maikanetaka Jun 12, 2024
5c431ce
Add breadcrumb in MyPage
maikanetaka Jun 12, 2024
9eed4ce
Tailwind responsive in MyPage
maikanetaka Jun 12, 2024
a58ed40
Merge pull request #27 from SofieFerrari/styling-mypage-categorylist
maikanetaka Jun 12, 2024
0a6dad2
Implement react-hook-form to do form validation
wwenzz Jun 12, 2024
3212ba1
Merge pull request #28 from SofieFerrari/fix-checkout-v1
wwenzz Jun 12, 2024
2c0a24a
Add drawer for the heart
maikanetaka Jun 12, 2024
aee9fdf
style for Add cart button (filled icon)
maikanetaka Jun 12, 2024
b69391c
Style for Card and Cart Item to be responsive
maikanetaka Jun 12, 2024
0969e9a
Merge pull request #29 from SofieFerrari/fixing-styling
maikanetaka Jun 12, 2024
4c86149
add arial-label in button
maikanetaka Jun 12, 2024
0061275
fix Cart styling
maikanetaka Jun 12, 2024
4daf5f5
Upload animation files
maikanetaka Jun 12, 2024
b679c2f
Install Lottie
maikanetaka Jun 12, 2024
0a6275c
Add scroll top animation in footer
maikanetaka Jun 12, 2024
bffcc69
set up dummy data and add a button to fill out dummy data
wwenzz Jun 12, 2024
2e4a8dd
Merge pull request #30 from SofieFerrari/scroll-up
maikanetaka Jun 12, 2024
21a355a
Merge pull request #31 from SofieFerrari/fix-checkout-v2
wwenzz Jun 12, 2024
541d547
added loading to handleCart in userStore and cartItem
SofieFerrari Jun 12, 2024
80ae531
Create protected route that redirects to the login page
wwenzz Jun 12, 2024
2c6351a
Add sccessful login and logout animation
maikanetaka Jun 12, 2024
da21417
Merge pull request #32 from SofieFerrari/login-logout-success
maikanetaka Jun 12, 2024
7e3bf69
implementing loading in footer, form and heartbutton
SofieFerrari Jun 12, 2024
47150b4
added loading to all cmponents and pages that needed it
SofieFerrari Jun 12, 2024
01f47cf
added styling to lottie
SofieFerrari Jun 13, 2024
91d9cd5
Merge branch 'main' into loading
SofieFerrari Jun 13, 2024
ff74df3
Merge pull request #33 from SofieFerrari/loading
SofieFerrari Jun 13, 2024
8427fa7
removed exta } in checkout.jsx that made deply fail
SofieFerrari Jun 13, 2024
29f423a
added error.jsx
SofieFerrari Jun 13, 2024
fbe6c87
changed img to svg in footer and error component in form.jsx
SofieFerrari Jun 13, 2024
e91b7d9
worked on error
SofieFerrari Jun 13, 2024
bea35c7
Merge pull request #34 from SofieFerrari/error
SofieFerrari Jun 13, 2024
c805abe
Revert "Error"
wwenzz Jun 13, 2024
9531128
Merge pull request #35 from SofieFerrari/revert-34-error
wwenzz Jun 13, 2024
96f3118
Fix error Form
maikanetaka Jun 13, 2024
bf2c3c9
Fixing for Loading
maikanetaka Jun 13, 2024
7c7637e
fix styling
maikanetaka Jun 13, 2024
5770503
Adjust the html body # root to be full screen height and implement er…
wwenzz Jun 13, 2024
1df9fff
Change error to error.message in zustand stores
wwenzz Jun 13, 2024
dd7ba7c
Define the proptypes for error component
wwenzz Jun 13, 2024
63da7eb
implement error on mypage productdetail productlist login/signup pages
wwenzz Jun 13, 2024
b98537f
Create tagbutton and categorybutton to use in productcard and product…
wwenzz Jun 13, 2024
9b45d61
Merge pull request #37 from SofieFerrari/error-implement-v1
wwenzz Jun 13, 2024
e91b175
fix styling in homepage
maikanetaka Jun 13, 2024
f46391a
fix styling
maikanetaka Jun 13, 2024
fc93823
change hero iamge
maikanetaka Jun 13, 2024
b5c533c
fix styling
maikanetaka Jun 13, 2024
842456c
update the bigger size image
maikanetaka Jun 13, 2024
264cd4b
create OrderValue component
maikanetaka Jun 13, 2024
ce1c650
Replace code with the OrderValue component
maikanetaka Jun 13, 2024
2e69892
Update with OrderValue component and fix small bugs
maikanetaka Jun 13, 2024
9a4c740
Fixing Search, Category, and others by Wen
maikanetaka Jun 13, 2024
1cb83dc
FIxing for the lighthouse accessibility score
maikanetaka Jun 13, 2024
e355d26
Fix
maikanetaka Jun 13, 2024
638248d
fix the background
maikanetaka Jun 13, 2024
d43c56f
add alt and remove image info from tailwind config
maikanetaka Jun 13, 2024
6f0202c
set shorter Timeout in Form animation
maikanetaka Jun 13, 2024
cfceaa7
Update README.md
SofieFerrari Jun 16, 2024
329efe3
Update README.md
SofieFerrari Jun 16, 2024
1d1136d
Update README.md
SofieFerrari Jun 16, 2024
7488a2d
Update README.md
SofieFerrari Jun 16, 2024
8718bed
Make cart/clear cart open for non-login user
wwenzz Jun 18, 2024
7f9037e
Merge pull request #38 from SofieFerrari/fix-cart-v1
wwenzz Jun 18, 2024
f82a3e5
Direct user to mypage once logged in
wwenzz Jun 18, 2024
35a9a36
Merge pull request #39 from SofieFerrari/fix-signup-v1
wwenzz Jun 18, 2024
bc2a323
Display not found page for all the unmatching routes and adjust the b…
wwenzz Jun 18, 2024
b2c4e51
Merge pull request #40 from SofieFerrari/fix-not-found-v1
wwenzz Jun 18, 2024
0a15c9e
Protect order-confirmation route and replace empty fragment with main…
wwenzz Jun 18, 2024
bc88273
Fix the remove function when users not logged in
wwenzz Jun 19, 2024
13c7550
fix the accessbility for image carousel
wwenzz Jun 20, 2024
4f9dafe
Merge pull request #41 from SofieFerrari/fix-accessibility-v1
wwenzz Jun 20, 2024
112e5d6
Clean up all the console logs in frontend
wwenzz Jun 20, 2024
9d2e505
Implement scroll to top function when navigating
wwenzz Jun 20, 2024
293c958
fix the category and make sure it wor and display when navigating
wwenzz Jun 20, 2024
07a80ce
Add scroll to top function to footer's categories
wwenzz Jun 20, 2024
ba72512
Add favicon and clean up svg and jpg images
wwenzz Jun 21, 2024
f21e8dc
integrate klarna payment to backend and frontend
wwenzz Jun 23, 2024
5b9cc58
make cart items irremovable in checkout and convert the currency to s…
wwenzz Jun 26, 2024
c4d7376
Merge pull request #42 from SofieFerrari/klarna-payment
wwenzz Jun 26, 2024
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
24 changes: 23 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,26 @@ npm-debug.log*
yarn-debug.log*
yarn-error.log*

package-lock.json
package-lock.json
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
77 changes: 70 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,76 @@
# Final Project
Webify - Design Your Website with Ease

Replace this readme with your own information about your project.
Discover the perfect web template for you! No coding skills needed—just pick, customize, and launch.
Let's make website creation easy and fun!

Start by briefly describing the assignment in a sentence or two. Keep it short and to the point.
As part of the Technigo Web Dev Bootcamp, this project was created as the Final Project by Mai Kanetaka, Wen Zhao, and Sofie Ferrari Strahl. Webify is an e-commerce platform that sells web templates for influencers, entrepreneurs and people who want to get their projects och products to the market fast without needing any programming skills. Our goal with this website is to empower users to create professional online presences quickly and easily.

## The problem
Technologies Used

Describe how you approached to problem, and what tools and techniques you used to solve it. How did you plan? What technologies did you use? If you had more time, what would be next?
Frontend:
React
Vite
Zustand
React Router
React Icons
Tailwind CSS

## View it live
Backend:
Node.js
Express
MongoDB
Mongoose
Nodemon

Every project should be deployed somewhere. Be sure to include the link to the deployed project so that the viewer can click around and see what it's all about.
Other:
GitHub
Figma
VScode
Cloudinary
Netlify
Render
Notion

Challenges


We faced significant challenges with two major merge conflicts, experiencing double commits that we had to resolve by using the DROP command. Managing these conflicts required careful coordination and communication to ensure no work was lost and the codebase remained stable.
Implementing the products list was another challenge. We had to perform extensive filter and sort operations in various places, which required a deep understanding of both frontend and backend logic to ensure the correct display of products. Debugging and optimizing these operations were time-consuming but crucial for the functionality of our platform.

Project Process


First, we set up a Figma board where we brainstormed and established our core values, aligning the team on the project vision, workflow, and expectations. We designed the project in Figma, working with mood boards, styling and wireframes inspired by the project where we worked with UX-designers.
We utilized Notion to work as if this was our real job, starting each morning with a standup and a meeting about the day's workload. Our Notion page included meeting notes, a project timeline, sprints, and all the tasks for the frontend and backend.
First Week: Focused on design and backend development.
Second Week: Worked on the frontend.
Third Week: Connected the frontend and backend, cleaned up code, improved functions, managed error handling, resolved bugs, and applied final styling.

Google Lighthouse and cross-browser testing show satisfactory results.

View It Live


Frontend:
https://webify-templates.netlify.app/

Backend:
https://webify-peace.onrender.com



Connect with Us


Mai Kanetaka:
https://www.linkedin.com/in/maikanetaka
https://github.com/maikanetaka
https://maikanetaka.netlify.app/

Wen Zhao:
https://www.linkedin.com/in/wendywenzhao
https://github.com/wwenzz
https://wen-portfolio.netlify.app/

Sofie Ferrari Strahl:
https://www.linkedin.com/in/sofie-ferrari-strahl-495486214
https://github.com/sofieFerrari
https://sofieferraristrahl.netlify.app
31 changes: 31 additions & 0 deletions backend/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package-lock.json
# dotenv environment variable files
.env
.env.development.local
.env.test.local
.env.production.local
.env.local
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
24 changes: 24 additions & 0 deletions backend/config/cloudinary.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import dotenv from "dotenv";
import cloudinaryFramework from "cloudinary";
import multer from "multer";
import { CloudinaryStorage } from "multer-storage-cloudinary";

dotenv.config();

const cloudinary = cloudinaryFramework.v2;
cloudinary.config({
cloud_name: process.env.CLOUDINARY_CLOUD_NAME, // this needs to be whatever you get from cloudinary
api_key: process.env.CLOUDINARY_API_KEY,
api_secret: process.env.CLOUDINARY_API_SECRET,
});

const storage = new CloudinaryStorage({
cloudinary,
params: {
folder: "mockups",
allowedFormats: ["jpg", "png", "webp"],
transformation: [{ width: 1000, height: 1000, crop: "limit" }],
},
});

export const parser = multer({ storage });
7 changes: 7 additions & 0 deletions backend/config/database.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import mongoose from "mongoose";

export const connectMongoDB = () => {
const mongoUrl = process.env.MONGO_URL || "mongodb://localhost/project-final";
mongoose.connect(mongoUrl);
mongoose.Promise = Promise;
};
14 changes: 14 additions & 0 deletions backend/controllers/mockupController.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { Product } from "../models/Product.js";
import asyncHandler from "express-async-handler";

export const uploadMockup = asyncHandler(async (req, res) => {
const { name } = req.body;
const product = await Product.findOne({ templateName: name }).exec();
product.image = req.file.path;
await product.save();
res.status(200).json({
success: true,
imageUrl: req.file.path,
imageId: req.file.filename,
});
});
38 changes: 38 additions & 0 deletions backend/controllers/productController.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { Product } from "../models/Product";
import asyncHandler from "express-async-handler";
import webTemplates from "../data/webTemplates.json";

export const displayProducts = asyncHandler(async (req, res) => {
// seed the data to the database when necessary
if (process.env.RESET_DB) {
const seedProductDatabase = async () => {
await Product.deleteMany();
webTemplates.forEach(template => {
new Product(template).save();
});
};
await seedProductDatabase();
}
const products = await Product.find().select("-__v -description").exec();
res.status(200).json(products);
});

export const displayProductById = asyncHandler(async (req, res) => {
const { productId } = req.params;
const product = await Product.findOne({ _id: productId }, "-__v").exec();
res.status(200).json(product);
});

export const likeOrUnlikeProductById = asyncHandler(async (req, res) => {
const { productId } = req.params;
const { unlike } = req.body;
const product = await Product.findOne({ _id: productId });
if (unlike) {
product.likes--;
await product.save();
} else {
product.likes++;
await product.save();
}
res.status(200).json(product);
});
136 changes: 136 additions & 0 deletions backend/controllers/userController.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
import bcrypt from "bcrypt";
import asyncHandler from "express-async-handler";

import { Product } from "../models/Product";
import { User } from "../models/User";

export const registerUser = asyncHandler(async (req, res) => {
const { username, email, password } = req.body;
const user = new User({
username,
email,
password: bcrypt.hashSync(password, 10),
});
await user.save();
res.status(201).json({
message: "Sign up successfully.",
success: true,
accessToken: user.accessToken,
id: user.id,
});
});

export const loginUser = asyncHandler(async (req, res) => {
const { username, password, cartItems } = req.body;
const user = await User.findOne({ username }).exec();

if (user && bcrypt.compareSync(password, user.password)) {
if (cartItems) {
await User.updateOne(
{ username: username },
{ $addToSet: { cartItems: { $each: cartItems } } }
);
}
res.status(200).json({
message: "Login Successful.",
success: true,
accessToken: user.accessToken,
id: user.id,
});
} else if (user) {
const err = new Error("Incorrect password");
err.statusCode = 401;
throw err;
} else {
const err = new Error("Invalid username");
err.statusCode = 401;
throw err;
}
});

export const deleteUser = asyncHandler(async (req, res) => {
const { userId } = req.params;
const user = await User.deleteOne({ _id: userId });
res.status(200).json({
message: "Delete Successful.",
success: true,
});
});

export const displayUser = asyncHandler(async (req, res) => {
const { userId } = req.params;
const user = await User.findOne(
{ _id: userId },
"-__v -password -accessToken"
).exec();
res.status(200).json({
message: user,
success: true,
});
});

export const handleCart = asyncHandler(async (req, res) => {
const { userId } = req.params;
const { productId, remove } = req.body;
if (remove) {
const user = await User.findOneAndUpdate(
{ _id: userId },
{ $pull: { cartItems: productId } },
{ new: true }
)
.select("cartItems -_id")
.exec();
res.status(200).json(user);
} else {
const product = await Product.findOne({ _id: productId }).exec();
const user = await User.findOneAndUpdate(
{ _id: userId },
{ $addToSet: { cartItems: product } },
{
new: true,
}
)
.select("cartItems -_id")
.exec();
res.status(200).json(user);
}
});

export const handleFavorite = asyncHandler(async (req, res) => {
const { userId } = req.params;
const { productId, remove } = req.body;
if (remove) {
const user = await User.findOneAndUpdate(
{ _id: userId },
{ $pull: { favoriteTemplates: productId } },
{ new: true }
)
.select("favoriteTemplates -_id")
.exec();
res.status(200).json(user);
} else {
const product = await Product.findOne({ _id: productId }).exec();
const user = await User.findOneAndUpdate(
{ _id: userId },
{ $addToSet: { favoriteTemplates: product } },
{
new: true,
}
)
.select("favoriteTemplates -_id")
.exec();
res.status(200).json(user);
}
});

export const clearCart = asyncHandler(async (req, res) => {
const { userId } = req.params;
const user = await User.findOneAndUpdate(
{ _id: userId },
{ $set: { cartItems: [] } },
{ new: true }
)
.select("cartItems -_id")
.exec();
res.status(200).json(user);
});
Loading