-
Notifications
You must be signed in to change notification settings - Fork 139
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
68 changed files
with
2,024 additions
and
1,513 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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")); | ||
}); | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
86b5a18
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
medi-hub – ./frontend
medi-hub-itsmohit097s-projects.vercel.app
medi-hub-git-main-itsmohit097s-projects.vercel.app
medi--hub.vercel.app