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

Final Project || Museek || Alma & Etna #51

Open
wants to merge 188 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
188 commits
Select commit Hold shift + click to select a range
87d1105
Added json and created some folders
almaherris May 28, 2024
be14180
Created detailspage and components related to it
almaherris May 28, 2024
37d7938
setting up the components
Caracal23 May 29, 2024
8917c92
working the searchbar
Caracal23 May 29, 2024
efa670a
adding components on the landing page
Caracal23 May 29, 2024
c2a3762
some work on notfound
almaherris May 29, 2024
a1e12ff
creating carousel
Caracal23 May 29, 2024
77d7e54
Merge pull request #1 from Caracal23/detail-page
almaherris May 30, 2024
3ba6ae2
set up routes and added more items to json
almaherris May 30, 2024
24ce241
descriptions for all museums
almaherris May 30, 2024
8a182e5
removed duplicates from museum list
almaherris May 30, 2024
35f4149
setting up route with useParams
almaherris May 30, 2024
c2f09a0
commit
almaherris May 30, 2024
ff97796
"added id in json and updated userpage"
almaherris May 30, 2024
17b4f3f
solved issue in useParams and details page
almaherris May 30, 2024
929b1dd
updated details in json
almaherris May 30, 2024
7959dbe
added dummy text to pages
almaherris May 30, 2024
8e3910f
added conditional rendering of restaurant icon
almaherris May 30, 2024
d503cba
added link to museumcard
almaherris May 31, 2024
0bab588
added icons for userpage on navbar
almaherris May 31, 2024
d5d0bc9
extended search result to location and theme
almaherris May 31, 2024
fea6f49
added linking to detail page from search results
almaherris May 31, 2024
d82dea9
backend copied from last week and adjusted for this project
almaherris May 31, 2024
8c6c01e
Copied and set up login and register from auth project
almaherris May 31, 2024
631072d
Copy and set up userpage
almaherris May 31, 2024
eaed909
text and comments on userpage and login page
almaherris May 31, 2024
31ae380
started setting up review function
almaherris May 31, 2024
12755d7
added comment about delete method
almaherris May 31, 2024
5010798
Installed styled components and start working on styling landing page…
Caracal23 Jun 2, 2024
b210dba
hero and nav bar styled from mobil view
Caracal23 Jun 2, 2024
28caee0
backend - comment section
almaherris Jun 2, 2024
941c6de
tried making musuemId in comments work
almaherris Jun 2, 2024
9b61ad8
created getcomment component
almaherris Jun 2, 2024
5657f84
family font added, keep on styling
Caracal23 Jun 2, 2024
81689e8
placing correct searchbar component
Caracal23 Jun 3, 2024
485533c
keep on styling work
Caracal23 Jun 3, 2024
95c8f3a
search bar error message and result presentation
Caracal23 Jun 3, 2024
d36c17c
icon button to scroll smoothly up
Caracal23 Jun 3, 2024
7485bbd
added get comment component
almaherris Jun 3, 2024
9287fbb
backend - made sure museumId is a number
almaherris Jun 3, 2024
0e82640
made sure museumId is a number
almaherris Jun 3, 2024
9b4624e
re-arranging components; working on grid style
Caracal23 Jun 3, 2024
3a6efce
css work continues; liked button added
Caracal23 Jun 4, 2024
e380e29
museum comments appearing on the correct page
almaherris Jun 4, 2024
495e2c7
added comment in getcomments
almaherris Jun 4, 2024
73fd2f5
Merge branch 'main' into feature/comment
almaherris Jun 4, 2024
1c9514a
Merge pull request #2 from Caracal23/feature/comment
almaherris Jun 4, 2024
89cc7b4
newsletter added
Caracal23 Jun 4, 2024
54c24ca
working on fav button
Caracal23 Jun 4, 2024
1e285f4
Favorite endpoint created and button works
Caracal23 Jun 4, 2024
d2c5a69
newsletter submit button
Caracal23 Jun 4, 2024
cd4e571
Newsletter success message
Caracal23 Jun 4, 2024
2c73cb3
updated json
almaherris Jun 4, 2024
d272b2c
updated msueum json
almaherris Jun 4, 2024
2fb4c41
update json
almaherris Jun 4, 2024
659d492
json update
almaherris Jun 5, 2024
f1e041f
Merge pull request #3 from Caracal23/feature/images
almaherris Jun 5, 2024
e555efc
Update Footer.styled.jsx
Caracal23 Jun 5, 2024
de4d42b
image addition
Caracal23 Jun 5, 2024
fda2e4f
styled components in detailpage and json update
almaherris Jun 5, 2024
1b2cd56
added authentication to comment section
almaherris Jun 5, 2024
bfb898f
some styling in detailpage
almaherris Jun 5, 2024
fa7d250
Styling in progress
Caracal23 Jun 5, 2024
dc5f640
styling detailpage
almaherris Jun 5, 2024
bc7242c
starting responsiveness
Caracal23 Jun 5, 2024
03c3efd
Merge branch 'main' into detail-page
almaherris Jun 6, 2024
e3e6b53
Merge pull request #4 from Caracal23/detail-page
almaherris Jun 6, 2024
7fbdb41
detailpage - created parent component for comments, enabling instant …
almaherris Jun 6, 2024
dfdc3ab
tried adding user to comments but not working yet...!
almaherris Jun 6, 2024
e7ec2e4
working on style
Caracal23 Jun 6, 2024
5281ca0
backend - added delete method to reviews
almaherris Jun 6, 2024
f783700
Merge pull request #5 from Caracal23/detail-page
almaherris Jun 6, 2024
681f4c0
delete method for reviews working
almaherris Jun 6, 2024
29888f6
Merge pull request #6 from Caracal23/detail-page
almaherris Jun 6, 2024
b5588a5
styling detailpage
almaherris Jun 6, 2024
ec455e8
css and one item to the json file
Caracal23 Jun 6, 2024
bdabdad
working on css register and login pages
Caracal23 Jun 6, 2024
22d1702
Merge pull request #7 from Caracal23/detail-page
almaherris Jun 6, 2024
bb1a2e3
styling detailpage
almaherris Jun 6, 2024
0b0e970
more styling detailpage
almaherris Jun 6, 2024
755c2c9
updated location in json
almaherris Jun 6, 2024
d61b691
updated backarrow
almaherris Jun 6, 2024
a606894
Merge pull request #8 from Caracal23/detail-page
almaherris Jun 6, 2024
630ddf3
updated review.js
almaherris Jun 7, 2024
f5d304f
split up the backend
almaherris Jun 7, 2024
9903377
Merge pull request #9 from Caracal23/backend/structure
almaherris Jun 7, 2024
465b70e
create mongoose model for Museum
almaherris Jun 7, 2024
0345f42
fixed size problem in carousel
almaherris Jun 7, 2024
373384a
responsiveness searchbar
almaherris Jun 7, 2024
5ec76d1
added gradient black at hero bottom
almaherris Jun 7, 2024
14b4212
update detailpage
almaherris Jun 7, 2024
4ffe279
updated ref about and cotact pages
almaherris Jun 7, 2024
cca36da
typo contactpage
almaherris Jun 7, 2024
715ffd8
added wordwrap breakword to comment section
almaherris Jun 7, 2024
fbae7da
css work detail page
Caracal23 Jun 8, 2024
8e00144
todo list and add shoppage
almaherris Jun 8, 2024
66bd86d
removed museumdate ffrom insertmany
almaherris Jun 8, 2024
fc1ad1f
imported museumdata correctly
almaherris Jun 8, 2024
9c5f01b
working with the favorite button per user id
Caracal23 Jun 8, 2024
ea22565
endpoint for museums set up
almaherris Jun 9, 2024
985af94
temporary update shopPage
almaherris Jun 9, 2024
e216ada
more update to shopPage
almaherris Jun 9, 2024
cb12d3f
updated amount to show in grid
almaherris Jun 9, 2024
9a11164
added some logos
almaherris Jun 9, 2024
02b033b
set up React leaflet map for grid
almaherris Jun 9, 2024
2beb6fa
favorited museums per user
Caracal23 Jun 9, 2024
88922e2
Update toDo
Caracal23 Jun 9, 2024
7dc76ac
updated detail page image positioning for phone/tablet
almaherris Jun 9, 2024
2b82dc4
removed borders
almaherris Jun 9, 2024
79d5a22
Merge branch 'main' into frontend/general
almaherris Jun 9, 2024
65433a4
Merge pull request #10 from Caracal23/frontend/general
almaherris Jun 9, 2024
39d2666
update z-index for navbar to be on top of map
almaherris Jun 9, 2024
b844afa
solved conflict in detailpage
almaherris Jun 9, 2024
45140d1
more updated image detailpage
almaherris Jun 9, 2024
6bfe61c
Update package.json
Caracal23 Jun 9, 2024
954a8bf
user name added to the museum comments
Caracal23 Jun 9, 2024
c641f04
testing new images for carousel
Caracal23 Jun 10, 2024
38bf7ed
starting to work on comments per user in Userpage
Caracal23 Jun 10, 2024
e50d2f9
changed place of the heart in detailpage and aligned comment sections
almaherris Jun 10, 2024
b745e07
added heart function to grid page
almaherris Jun 10, 2024
82efa19
Merge pull request #11 from Caracal23/detail-page
almaherris Jun 10, 2024
3ad8b05
new font, updated links in navbar
almaherris Jun 11, 2024
f739eff
Merge pull request #12 from Caracal23/frontend/design
almaherris Jun 11, 2024
75c2213
todo list update
almaherris Jun 11, 2024
8ab0a05
added point to todolist
almaherris Jun 11, 2024
564f7cc
fetch from deployed API in landingpage
almaherris Jun 11, 2024
68fd82b
endpoint for musuem id created
almaherris Jun 11, 2024
33280d8
Merge pull request #13 from Caracal23/backend/connect
almaherris Jun 11, 2024
4920171
console logs to debug deployed version
almaherris Jun 11, 2024
ca6c157
Merge pull request #14 from Caracal23/backend/connect
almaherris Jun 11, 2024
9ce551b
fetching from real api set up
almaherris Jun 11, 2024
0d07749
starting to work on the review backend
Caracal23 Jun 11, 2024
062d2ba
navbar hamburger menu
almaherris Jun 11, 2024
83701a4
small design updates
almaherris Jun 11, 2024
42fc4e7
add the user name to userpage header
Caracal23 Jun 11, 2024
612c5bb
go back buttons and navbar
almaherris Jun 11, 2024
2da5662
break out map component
almaherris Jun 11, 2024
6adb28c
reinstalled dependencies
almaherris Jun 11, 2024
a008d0a
rename backbutton
almaherris Jun 11, 2024
8bc029d
fixed map lat long prop passing
almaherris Jun 11, 2024
a3d34a0
Merge branch 'main' into backend/connect
almaherris Jun 11, 2024
88e1adf
Merge pull request #15 from Caracal23/backend/connect
almaherris Jun 11, 2024
a48f616
solved double icons in navbar for mobile
almaherris Jun 11, 2024
cbf4c8e
update todo
almaherris Jun 11, 2024
1741a80
ToDo list points
Caracal23 Jun 12, 2024
8ccb7a3
Merge branch 'main' of https://github.com/Caracal23/project-final
Caracal23 Jun 12, 2024
c8947de
ToDo list updated
Caracal23 Jun 12, 2024
161ecc4
json update and filter bar started
almaherris Jun 12, 2024
8cd46d5
Merge branch 'main' into museumpage
almaherris Jun 12, 2024
9c40cbf
Merge pull request #16 from Caracal23/museumpage
almaherris Jun 12, 2024
259dddb
styled museumpage and filterbar
almaherris Jun 12, 2024
9273d69
added button to clear filters
almaherris Jun 12, 2024
7f3b1ea
added active state to navbar links
almaherris Jun 12, 2024
6e9f353
Updated ToDo list completed
Caracal23 Jun 12, 2024
77bc947
Rating stars for comments
Caracal23 Jun 12, 2024
a1e5272
error messages for comments and for rating stars
Caracal23 Jun 12, 2024
c785e32
toDo updated
Caracal23 Jun 12, 2024
cd8c9cd
clear rating after submit
almaherris Jun 13, 2024
4ff5611
Merge branch 'main' into museumpage
almaherris Jun 13, 2024
32eabb1
Merge pull request #17 from Caracal23/museumpage
almaherris Jun 13, 2024
80a0018
added link to usercomments
almaherris Jun 13, 2024
f4b7afd
updated shop button
almaherris Jun 13, 2024
054d17f
deleted filed not needed
almaherris Jun 13, 2024
26d6467
update image
almaherris Jun 13, 2024
7d414cf
added logic to disable login when already logged in
almaherris Jun 13, 2024
a778dd2
style unauth user page
almaherris Jun 13, 2024
44f5b37
update loading state landingpage
almaherris Jun 13, 2024
7c38f41
set up modale login from detailpage
almaherris Jun 13, 2024
08ce051
styling in modale
almaherris Jun 13, 2024
c0d6eaa
more styling modal
almaherris Jun 13, 2024
8205ac6
random styling and fixes
almaherris Jun 13, 2024
1b87786
Merge pull request #18 from Caracal23/feature/modale
almaherris Jun 13, 2024
7f7216a
update todo
almaherris Jun 13, 2024
3fe7476
styling updates everywhere
almaherris Jun 13, 2024
8a76435
Merge pull request #19 from Caracal23/feature/modale
almaherris Jun 13, 2024
4151199
filterbar and museumpage
almaherris Jun 13, 2024
88f7074
window scroll up update
almaherris Jun 14, 2024
6ae19d2
Merge pull request #20 from Caracal23/feature/modale
almaherris Jun 14, 2024
5bcc1ba
clean up styled components, single use in same component, multiple us…
almaherris Jun 16, 2024
ed52017
ordered lists alfabetically
almaherris Jun 16, 2024
c701959
Merge pull request #21 from Caracal23/frontend/design
almaherris Jun 16, 2024
194b51e
Complete ReadMe
Caracal23 Jun 19, 2024
00c951e
Remove our ToDo List
Caracal23 Jun 19, 2024
82990fc
added more padding to title in detailpage
almaherris Jun 19, 2024
8c1a309
accessibility improvements
almaherris Jun 19, 2024
f4a97fe
changed name of utils file and removed width rule in userpage as sugg…
almaherris Jun 24, 2024
1dda8cd
added loading state to museumpage
almaherris Jul 2, 2024
a9c338e
added loading state to landing page
almaherris Jul 2, 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
28 changes: 23 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,31 @@
# Final Project
# Museek - Where curiostiy meets culture.

Replace this readme with your own information about your project.
Whenever you find yourself in a new city, wondering what to do, our webpage could give a way to explore lesser-known museums around the globe, offering an authentic alternative to the mainstream tourist attractions.

Start by briefly describing the assignment in a sentence or two. Keep it short and to the point.
It allows you to discover museums in a fun interactive way, giving you inspiration for your next trip.

## The problem

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?
For our final project we were requested to created web page from scratch. We were given 3 weeks to develop and deliver a functional backend with a friendly user frontend.

The first week, we began by brainstorming ideas based on our hobbies and preferences so we can later blend them with features that we thought our final user may find useful.
After defining the propose of our webpage, we began to build our backend, together with our routes, models and authentication.
Second week, we focus on creating the design of our frontend, together with the multiple pages that matches our backend endpoints.
During the last week, we paid close attention on executing a smoothly navigation flow as well as adjusting our CSS keeping in mind our objective to provide our final user a practical, enjoyable and enlightening experience through our page.

Altogether our project was carefully created, following the code guidelines of not repeating, organised and clean code. Our MVP was completed as well as some of our stretch goals, but if we could have more time we will add the feature to translate our page content to French and Spanish languages.

## Technologies

For the backend; we utilise Mongoose, Mongo DB, Express, Node.js
For the frontend; we worked with React hooks such as useState, useEffect, useContext. Also some libraries, such as, React-Router, Star Ratings, Select, Leaflet and Styled Components for the design.

## View it live

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.
Frontend: https://museek-project.netlify.app/
Backend: https://museek-2ejb.onrender.com/

## Connect with us

Alma Herrström: https://github.com/almaherris/
Etna Zuniga: https://github.com/Caracal23/
8 changes: 0 additions & 8 deletions backend/README.md

This file was deleted.

63 changes: 63 additions & 0 deletions backend/controllers/authController.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import bcrypt from "bcrypt";
import { User } from "../models/User.js";

// User registration
export const registerUser = async (req, res) => {
const salt = bcrypt.genSaltSync(10);

try {
const { name, email, password } = req.body;

if (name === "" || email === "" || password === "") {
res.status(400).json({ message: "All fields are required" });
}

// Check if the user already exists
const existingUser = await User.findOne({ email: email.toLowerCase() });

if (existingUser) {
return res.status(409).json({ message: "User already exists" });
}

// Create new user
const user = new User({
name,
email,
id: crypto.randomUUID(),
password: bcrypt.hashSync(password, salt),
});

await user.save();

return res
.status(201)
.json({ id: user._id, accessToken: user.accessToken });
} catch (error) {
res.status(400).json({
response: error.message,
success: false,
message: "Could not create user",
errors: error.errors,
});
}
};

// User login
export const loginUser = async (req, res) => {
const { email, password } = req.body;

const user = await User.findOne({ email: email.toLowerCase() });
if (user && bcrypt.compareSync(password, user.password)) {
res.json({ userId: user._id, accessToken: user.accessToken });
} else if (user && !bcrypt.compareSync(password, user.password)) {
// Wrong password
res.status(400).json({});
} else {
// User does not exist
res.status(404).json({});
}
};

export const getUserPage = (req, res) => {
res.json({ message: "You are logged in!", user: req.user });
};
100 changes: 100 additions & 0 deletions backend/controllers/favoriteController.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
import { application } from "express";
import { SavedFavorites } from "../models/SavedFavorites.js";
import { User } from "../models/User.js";
import { Museum } from "../models/Museum.js";

export const toggleFavorite = async (req, res) => {
const { museumId, accessToken } = req.body;

if (isNaN(museumId)) {
return res.status(400).json({
success: false,
message: "Invalid museumId",
});
}

let savedAsFavorite;

try {
const user = await User.findOne({ accessToken });
if (await SavedFavorites.findOne({ museumId, userId: user.id })) {
await SavedFavorites.deleteOne({ museumId, userId: user.id });
savedAsFavorite = false;
} else {
await SavedFavorites.create({ museumId, userId: user.id });
savedAsFavorite = true;
}

res.status(200).json({ success: true, savedAsFavorite });
} catch (error) {
res.status(400).json({
response: error.message,
succes: false,
message: "Something went wrong",
errors: error.errors || {},
});
}
};

export const likedMuseums = async (req, res) => {
const { accessToken } = req.body;

try {
const user = await User.findOne({ accessToken });
const likedMuseumsForUser = await SavedFavorites.find({ userId: user.id });
const likedMuseumsWithMuseumInfo = await Promise.all(
likedMuseumsForUser.map(async (likedMuseum) => {
const museumInfo = await Museum.findOne({
id: likedMuseum.museumId,
});
return {
museumId: likedMuseum.museumId,
userId: likedMuseum.userId,
museum: {
name: museumInfo.name,
theme: museumInfo.theme,
description: museumInfo.description,
location: museumInfo.location,
lat: museumInfo.lat,
lon: museumInfo.lon,
ticket_price: museumInfo.ticket_price,
has_cafe: museumInfo.has_cafe,
website: museumInfo.website,
opening_hours: museumInfo.opening_hours,
id: museumInfo.id,
url: museumInfo.url,
},
};
})
);
res
.status(200)
.json({ success: true, likedMuseums: likedMuseumsWithMuseumInfo ?? [] });
} catch (error) {
res.status(400).json({
response: error.message,
succes: false,
message: "Something went wrong",
error: error.errors || {},
});
}
};

export const isMuseumLiked = async (req, res) => {
const museumId = req.params.museumId;
const { accessToken } = req.body;

try {
const user = await User.findOne({ accessToken });
const savedAsFavorite =
(await SavedFavorites.findOne({ museumId, userId: user.id })) != null;
res.status(200).json({ success: true, savedAsFavorite });
} catch (error) {
res.status(400).json({
response: error.message,
succes: false,
message: "Something went wrong",
error: error.errors || {},
});
}
};
12 changes: 12 additions & 0 deletions backend/controllers/museumController.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { Museum } from "../models/Museum.js"

// Get list of all museums
export const getMuseums = async (req, res) => {
try {
const museums = await Museum.find()
res.status(200).json(museums)
} catch (error) {
console.error("Error fetching museums:", error)
res.status(500).json({ error: "Internal server error" })
}
}
93 changes: 93 additions & 0 deletions backend/controllers/reviewController.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
import { Museum } from "../models/Museum.js";
import { Review } from "../models/Review.js";
import { User } from "../models/User.js";

export const getReviews = async (req, res) => {
try {
const reviews = await Review.find().sort({ createdAt: -1 });
res.json(reviews);
} catch (error) {
res.status(500).json({ error: "Something went wrong" });
}
};

// getReviewsForUser

export const getReviewsForUser = async (req, res) => {
const { accessToken } = req.body;

try {
const user = await User.findOne({ accessToken });
const userReviews = await Review.find({
userId: user.id,
});
const userReviewsWhitMuseumsName = await Promise.all(
userReviews.map(async (review) => {
const museumInfo = await Museum.findOne({
id: review.museumId,
});
return {
museumId: review.museumId,
createdAt: review.createdAt,
userId: review.userId,
userName: review.userName,
message: review.message,
museumName: museumInfo.name,
rating: review.rating,
};
})
);
res.status(200).json(userReviewsWhitMuseumsName);
} catch (error) {
res.status(400).json({
response: error.message,
success: false,
message: "Could not get user reviews",
errors: error.errors,
});
}
};

export const postReviews = async (req, res) => {
const { museumId, message, accessToken, rating } = req.body;

if (isNaN(museumId)) {
return res.status(400).json({
success: false,
message: "Invalid museumId",
});
}

try {
const user = await User.findOne({ accessToken });
const review = await Review.create({
museumId,
message,
userId: user.id,
userName: user.name,
rating: rating,
});
res.status(201).json(review);
} catch (error) {
res.status(400).json({
response: error.message,
success: false,
message: "Could not create message",
errors: error.errors,
});
}
};

export const deleteReviews = async (req, res) => {
const reviewId = req.params.id;

try {
const review = await Review.findByIdAndDelete(reviewId);
if (!review) {
return res.status(404).json({ message: "Review not found" });
}
res.json({ message: "Review deleted successfully" });
} catch (error) {
res.status(500).json({ error: "Something went wrong" });
}
};
Loading