Skip to content

Commit

Permalink
frontend structure changed
Browse files Browse the repository at this point in the history
  • Loading branch information
imohit1o1 committed Jun 12, 2024
1 parent fb17852 commit 86b5a18
Show file tree
Hide file tree
Showing 68 changed files with 2,024 additions and 1,513 deletions.
12 changes: 7 additions & 5 deletions backend/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,14 @@ import userRouter from "./src/routes/user.routes.js";
import contactUsRouter from "./src/routes/contactus.routes.js";
import appointmentRouter from "./src/routes/appointment.routes.js";
import medicineRouter from "./src/routes/medicine.routes.js";
import CartRouter from "./src/routes/UserCart.routes.js"
import PaymentRouter from "./src/routes/payment.routes.js"
import CartRouter from "./src/routes/UserCart.routes.js";
import PaymentRouter from "./src/routes/payment.routes.js";
import TestimonialRouter from "./src/routes/testimonial.routes.js";

// Define the root route
app.get('/', (req, res) => {
res.send('Welcome to the homepage!');
});
// app.get('/', (req, res) => {
// res.send('Welcome to the homepage!');
// });

// routes declaration
app.use("/api/v1/user", userRouter);
Expand All @@ -44,6 +45,7 @@ app.use("/api/v1/appointment", appointmentRouter);
app.use("/api/v1/medicines", medicineRouter);
app.use("/api/v1/medicines-cart", CartRouter)
app.use("/api/v1/payment", PaymentRouter)
app.use("/api/v1/testimonial", TestimonialRouter)


// error middleware
Expand Down
55 changes: 55 additions & 0 deletions backend/src/controllers/testimonial.controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import asyncHandler from "../utilis/asyncHandler.js";
import { ApiError } from "../utilis/ApiError.js";
import { Testimonial } from "../models/testimonial.model.js";
import { ApiResponse } from "../utilis/ApiResponse.js";
import { uploadOnCloudinary } from "../utilis/cloudinary.js"


//! Adding a new testimonial by any user
export const addNewTestimonial = asyncHandler(async (req, res, next) => {
// taking the info from the user
const { fullName, email, country, state, review } = req.body;

// checking the info provided by the user
if (!fullName || !email || !country || !state || !review) {
throw new ApiError(400, "Please Fill Full Form!");
}
console.log(req.body);

// testimonialImage
const testimonialImgLocalPath = req.file?.path;

if (!testimonialImgLocalPath) {
throw new ApiError(400, "Testimonial Image Path Not Found!");
}

const testimonialImg = await uploadOnCloudinary(testimonialImgLocalPath);
if (!testimonialImg) {
throw new ApiError(400, "Testimonial Image is required")
}

// finally create the testimonial
const createdTestimonial = await Testimonial.create({
fullName,
email,
country,
state,
review,
testimonialImg: testimonialImg.url,
});

res
.status(200)
.json(new ApiResponse(200, createdTestimonial, "Testimonial created successfully"));
});


//! Getting all testimonials by admin
export const getAllTestimonial = asyncHandler(async (req, res, next) => {
const testimonials = await Testimonial.find();

res
.status(200)
.json(new ApiResponse(200, testimonials, " TESTIMONIALS LIST"));
});

70 changes: 0 additions & 70 deletions backend/src/docs.json

This file was deleted.

34 changes: 34 additions & 0 deletions backend/src/models/testimonial.model.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import mongoose from "mongoose";
import validator from "validator";

const TestimonialSchema = new mongoose.Schema(
{
fullName: {
type: String,
required: [true, "Full Name is required"],
},
email: {
type: String,
required: [true, "Email is required!"],
validate: [validator.isEmail, "Email is invalid"]
},
country: {
type: String,
required: [true, "Country is required!"],
},
state: {
type: String,
required: [true, "State is required!"],
},
review: {
type: String,
},
testimonialImg: {
type: String, // cloudinary url
}
},
{ timestamps: true }
);


export const Testimonial = mongoose.model("Testimonial", TestimonialSchema);
12 changes: 12 additions & 0 deletions backend/src/routes/testimonial.routes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import express from "express";
import { addNewTestimonial, getAllTestimonial } from "../controllers/testimonial.controller.js";
import { isAdminAuthenticated } from "../middlewares/auth.middleware.js";

const router = express.Router();


router.post("/add", addNewTestimonial);
router.get("/getall", getAllTestimonial);


export default router;
2 changes: 1 addition & 1 deletion backend/src/routes/user.routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ router.post("/patient/register", patientRegister);
router.post("/login", login);
router.post("/admin/addnew", isAdminAuthenticated, addNewAdmin);
router.post("/doctor/addnew", isAdminAuthenticated, upload.single("docAvatar"), addNewDoctor);
router.get("/doctors/getall", getAllDoctors);
router.get("/alldoctors", getAllDoctors);
router.get("/admin/me", isAdminAuthenticated, getUserDetails);
router.get("/patient/me", isPatientAuthenticated, getUserDetails);
router.get("/doctor/me", isDoctorAuthenticated, getDoctorDetails);
Expand Down
16 changes: 16 additions & 0 deletions frontend/hooks/useLoading.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { useState, useEffect } from "react";

const useLoading = (delay = 1000) => {
const [loading, setLoading] = useState(true);

useEffect(() => {
const timer = setTimeout(() => {
setLoading(false);
}, delay);
return () => clearTimeout(timer);
}, [delay]);

return loading;
};

export default useLoading;
27 changes: 27 additions & 0 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@
"react-dom": "^18.2.0",
"react-helmet": "^6.1.0",
"react-icons": "^5.2.0",
"react-loading-skeleton": "^3.4.0",
"react-lottie": "^1.2.4",
"react-multi-carousel": "^2.8.5",
"react-razorpay": "^2.0.1",
"react-router-dom": "^6.22.3",
"react-shimmer-effects": "^1.0.3",
"react-slick": "^0.30.2",
"react-toastify": "^10.0.5",
"slick-carousel": "^1.8.1",
Expand Down
Binary file added frontend/public/heroimg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
76 changes: 44 additions & 32 deletions frontend/src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,58 +2,70 @@ import React from "react";
import { BrowserRouter, Routes, Route } from "react-router-dom";
import { ToastContainer } from "react-toastify";
import "react-toastify/dist/ReactToastify.css";

import AppContext from "./Context/Context.jsx";

import {
Navbar,
Footer,
Home,
Appointment,
AllDoctors,
AboutUs,
Login,
Signup,
HomePage,
AllDoctorsPage,
SpecialitiesPage,
MedicinesPage,
LoginPage,
SignupPage,
ErrorPage,
TermsAndConditions,
PrivacyPolicy,
FaqsPage,
AboutUsPage,
PrivacyPolicyPage,
TermsAndConditionsPage,
OrderHistoryPage,
// Appointment,
AddtoCart,
Categoryitems,
SingleMedicine,
Medicines,
GoToTop,
CartPage,
ProductsByCategory,
// SingleMedicine,
// GoToTop,
Bot,
} from "./import-export/ImportExport.js";
// import TopSpecialitiesCard from "./components/TopSpecialitiesCard.jsx";
import SpecialitiesPage from "./pages/SpecialitiesPage.jsx";

function App() {
return (
<BrowserRouter>
<AppContext>
<Navbar />
<Routes>
<Route path="/" element={<Home />} />
<Route path="/appointment" element={<Appointment />} />
<Route path="/alldoctors" element={<AllDoctors />} />
<Route path="/aboutus" element={<AboutUs />} />
<Route path="/termsandconditions" element={<TermsAndConditions />} />
<Route path="/privacypolicy" element={<PrivacyPolicy />} />
<Route path="/medicines" element={<Medicines />} />
<Route path="/buy-medicines/:id" element={<SingleMedicine />} />
<Route path="/shop-by-category/:id" element={<Categoryitems />} />
<Route path="/medicine-cart" element={<AddtoCart />} />
<Route path="/login" element={<Login />} />
<Route path="/signup" element={<Signup />} />
<Route path="/" element={<HomePage />} />
<Route path="/alldoctors" element={<AllDoctorsPage />} />
{/* <Route path="/appointment" element={<Appointment />} /> */}

<Route path="/specialities" element={<SpecialitiesPage />} />
<Route path="/cart" element={<CartPage />} />

<Route path="/medicines" element={<MedicinesPage />} />
<Route
path="/medicines/shop_by_category/:id"
element={<ProductsByCategory />}
/>
{/* <Route path="/buy-medicines/:id" element={<SingleMedicine />} /> */}
<Route path="/medicines/cart" element={<AddtoCart />} />
<Route
path="/medicines/order_history"
element={<OrderHistoryPage />}
/>

<Route path="/login" element={<LoginPage />} />
<Route path="/signup" element={<SignupPage />} />

<Route path="/*" element={<ErrorPage />} />
<Route path="/faqs" element={<FaqsPage />} />
<Route path="/aboutus" element={<AboutUsPage />} />
<Route path="/privacypolicy" element={<PrivacyPolicyPage />} />
<Route
path="/termsandconditions"
element={<TermsAndConditionsPage />}
/>
</Routes>
<Bot />
<GoToTop />
{/* <GoToTop /> */}
<Footer />
<ToastContainer position="top-center" />
<ToastContainer position="top-right" />
</AppContext>
</BrowserRouter>
);
Expand Down
Loading

1 comment on commit 86b5a18

@vercel
Copy link

@vercel vercel bot commented on 86b5a18 Jun 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.