├── .eslintrc.json
├── .gitignore
├── README.md
├── components
├── Home.jsx
├── Search.jsx
├── admin
│ ├── AllBookings.jsx
│ ├── AllRooms.jsx
│ ├── AllUsers.jsx
│ ├── NewRoom.jsx
│ ├── RoomReviews.jsx
│ ├── UpdateRoom.jsx
│ └── UpdateUser.jsx
├── auth
│ ├── Login.jsx
│ └── Register.jsx
├── bookings
│ ├── BookingDetails.jsx
│ └── MyBookings.jsx
├── layouts
│ ├── ButtonLoader.jsx
│ ├── Footer.jsx
│ ├── Header.jsx
│ ├── Layout.jsx
│ ├── Loader.jsx
│ └── NotFound.jsx
├── review
│ ├── ListReviews.jsx
│ └── NewReview.jsx
├── room
│ ├── RoomDetails.jsx
│ ├── RoomFeatures.jsx
│ ├── RoomItem.jsx
│ └── RoomOption.jsx
└── user
│ ├── ForgotPassword.jsx
│ ├── NewPassword.jsx
│ └── Profile.jsx
├── config
└── dbConnect.js
├── controllers
├── authControllers.js
├── bookingControllers.js
├── paymentControllers.js
└── roomControllers.js
├── middlewares
├── auth.js
├── catchAsyncError.js
└── error.js
├── models
├── booking.js
├── room.js
└── user.js
├── next.config.js
├── package.json
├── pages
├── 404.jsx
├── _app.jsx
├── _document.js
├── admin
│ ├── bookings
│ │ ├── [id].jsx
│ │ └── index.jsx
│ ├── reviews.jsx
│ ├── rooms
│ │ ├── index.jsx
│ │ └── new.jsx
│ └── users
│ │ ├── [id].jsx
│ │ └── index.jsx
├── api
│ ├── admin
│ │ ├── bookings
│ │ │ ├── [id].js
│ │ │ └── index.js
│ │ ├── rooms
│ │ │ └── index.js
│ │ └── users
│ │ │ └── [id].js
│ ├── auth
│ │ ├── [...nextauth].js
│ │ └── register.js
│ ├── bookings
│ │ ├── [id].js
│ │ ├── check.js
│ │ ├── check_booked_dates.js
│ │ ├── index.js
│ │ └── me.js
│ ├── checkout_session
│ │ └── [roomId].js
│ ├── me.js
│ ├── me
│ │ └── update.js
│ ├── password
│ │ ├── forgot.js
│ │ └── reset
│ │ │ └── [token].js
│ ├── reviews
│ │ ├── check_review_availability.js
│ │ └── index.js
│ ├── rooms
│ │ ├── [id].js
│ │ └── index.js
│ ├── users
│ │ └── index.js
│ └── webhook.js
├── bookings
│ ├── [id].jsx
│ └── me.jsx
├── index.jsx
├── login.jsx
├── me
│ └── update.jsx
├── password
│ ├── forgot.jsx
│ └── reset
│ │ └── [token].jsx
├── register.jsx
├── room
│ └── [id].jsx
└── search.jsx
├── public
├── favicon.ico
├── images
│ ├── bookit_logo.png
│ └── default_avatar.png
└── vercel.svg
├── redux
├── actions
│ ├── bookingActions.js
│ ├── roomActions.js
│ └── userActions.js
├── constants
│ ├── bookingConstants.js
│ ├── roomConstants.js
│ └── userConstants.js
├── reducers
│ ├── bookingReducers.js
│ ├── reducers.js
│ ├── roomReducers.js
│ └── userReducers.js
└── store.js
├── styles
├── Home.module.css
└── globals.css
├── utils
├── apiFeatures.js
├── errorHandler.js
├── getStripe.js
├── seeder.js
└── sendEmail.js
└── yarn.lock
/.eslintrc.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "next/core-web-vitals"
3 | }
4 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
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 | # next.js
12 | /.next/
13 | /out/
14 |
15 | # production
16 | /build
17 |
18 | # misc
19 | .DS_Store
20 | *.pem
21 |
22 | # debug
23 | npm-debug.log*
24 | yarn-debug.log*
25 | yarn-error.log*
26 |
27 | # local env files
28 | .env.local
29 | .env.development.local
30 | .env.test.local
31 | .env.production.local
32 |
33 | # vercel
34 | .vercel
35 |
36 | # local data
37 | data/
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ## 概要
2 |
3 | Next.jsの練習ついでに作成した宿泊予約アプリ
4 |
5 | 
6 |
7 | ## 機能
8 |
9 | ### ユーザー側
10 |
11 | - 登録&ログイン機能(メールアドレス&パスワード)
12 | - プロフィール作成・更新(ユーザー名・メールアドレス・アバター画像)
13 | - パスワードを忘れた際の再設定(メール配信)
14 | - 宿泊の予約
15 | - 宿泊レビュー
16 | - 予約一覧確認(予約内容をPDFでダウンロード可能)
17 | - Stripe決済
18 |
19 | ### 管理者(Admin)側
20 |
21 | - ユーザー一覧確認
22 | - 宿泊施設一覧確認&編集機能
23 | - レビュー一覧確認&編集機能
24 |
25 | ## 使用技術
26 |
27 | - Next.js
28 | - Redux
29 | - Vercel
30 | - MongoDB
31 | - StripeAPI(決済用)
32 | - Cloudinary(アバター画像・宿泊施設画像の保存用)
33 |
--------------------------------------------------------------------------------
/components/Home.jsx:
--------------------------------------------------------------------------------
1 | import React, { useEffect } from "react";
2 | import { useRouter } from "next/dist/client/router";
3 | import Link from "next/dist/client/link";
4 | import { useSelector, useDispatch } from "react-redux";
5 | import { toast } from "react-toastify";
6 | import Pagination from "react-js-pagination";
7 |
8 | import { RoomItem } from "./room/RoomItem";
9 | import { clearErrors } from "../redux/actions/roomActions";
10 |
11 | export const Home = () => {
12 | const dispatch = useDispatch();
13 | const router = useRouter();
14 |
15 | const { rooms, resPerPage, roomsCount, filteredRoomsCount, error } =
16 | useSelector((state) => state.allRooms);
17 | let { location, page = 1 } = router.query;
18 | page = Number(page);
19 | let count = roomsCount;
20 | if (location) {
21 | count = filteredRoomsCount;
22 | }
23 | useEffect(() => {
24 | if (error) {
25 | toast.error(error);
26 | dispatch(clearErrors());
27 | }
28 | }, []);
29 |
30 | const handlePagination = (pageNumber) => {
31 | router.push(`/?page=${pageNumber}`);
32 | };
33 |
34 | return (
35 | <>
36 |
38 | {location ? `Rooms in ${location}` : "All Rooms"}
39 |
40 |
41 |
42 | Back to Search
43 |
44 |
45 |
34 | Name: {booking.user && booking.user.name} 35 |
36 |37 | Email: {booking.user && booking.user.email} 38 |
39 |40 | Amount: ${booking.amountPaid} 41 |
42 | 43 |47 | Check In:{" "} 48 | {new Date(booking.checkInDate).toLocaleString("ja")} 49 |
50 | 51 |52 | Check Out:{" "} 53 | {new Date(booking.checkOutDate).toLocaleString("ja")} 54 |
55 | 56 |57 | Days of Stay: {booking.daysOfStay} 58 |
59 | 60 |64 | {isPaid ? "Paid" : "Not Paid"} 65 |
66 | 67 | {user && user.role === "admin" && ( 68 | <> 69 |71 | {booking.paymentInfo.id} 72 |
73 | > 74 | )} 75 | 76 |${booking.room.pricePerNight}
98 |{booking.daysOfStay} Day(s)
102 |by {review.name}
20 |{review.comment}
21 | 22 |{room.address}
135 |{room.description}
165 |171 | $ {room.pricePerNight} / night 172 |
173 | 174 |Pick Check In & Out Date
177 | 178 |235 | No Reviews on this room 236 |
237 | )} 238 |{room.guestCapacity} Guests
11 |{room.numOfBeds} Beds
16 |23 | ${room.pricePerNight} / night 24 |
25 |{text}
13 |