Skip to content

Commit

Permalink
thirty five
Browse files Browse the repository at this point in the history
  • Loading branch information
rohitchauhan0 committed Jan 4, 2024
1 parent 32cf8bc commit f0c067f
Show file tree
Hide file tree
Showing 14 changed files with 323 additions and 9 deletions.
59 changes: 59 additions & 0 deletions server/Controller/Astrology.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
const Astrology = require('../Modals/Autrology')

exports.createForm = async(req, res)=>{
try {
const {fullName, phoneNum, dob, address}= req.body
await Astrology.create({
fullName, phoneNum, dob, address
})

return res.status(200).json({
success:true,
message:"Form created"
})

} catch (error) {
console.log(error);
return res.status(500).json({
success: false,
message: error.message,
});
}
}

exports.getAstrologyForm = async(req, res)=>{
try {
const response = await Astrology.find({}).sort({createdAt:-1})
return res.status(200).json({
success:true,
data:response
})

} catch (error) {
console.log(error);
return res.status(500).json({
success: false,
message: error.message,
});
}
}


exports.deleteForm = async(req, res)=>{
try {
const {formId} = req.body
await Astrology.findByIdAndDelete(formId)
return res.status(200).json({
success:true,
message:"Delted"
})


} catch (error) {
console.log(error);
return res.status(500).json({
success: false,
message: error.message,
});
}
}
22 changes: 22 additions & 0 deletions server/Modals/Autrology.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
const mongoose = require('mongoose')

const AstrologyModal = new mongoose.Schema({
fullName:{
type:String
},
phoneNum:{
type:String,
},
address:{
type:String
},
dob:{
type:Date
},
createdAt:{
type:Date,
default: Date.now()
}
})

module.exports = mongoose.model("Astrology", AstrologyModal)
9 changes: 9 additions & 0 deletions server/Routes/AstrologyRoute.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const express = require('express')
const { createForm, getAstrologyForm, deleteForm } = require('../Controller/Astrology')
const router = express.Router()

router.post("/createForm", createForm)
router.get("/getForm", getAstrologyForm)
router.delete("/deleteForm", deleteForm)

module.exports = router
2 changes: 2 additions & 0 deletions server/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const sectionRoutes = require('./Routes/SectionRoutes')
const SubsectionRoutes = require('./Routes/SubsectionRoutes')
const reviewRoutes = require('./Routes/ReviewRoute')
const templeRoutes = require('./Routes/TempleRoute')
const astrologyRoutes = require('./Routes/AstrologyRoute')
require('dotenv').config()


Expand Down Expand Up @@ -44,6 +45,7 @@ app.use("/api/v1/section", sectionRoutes)
app.use("/api/v1/subsection", SubsectionRoutes)
app.use("/api/v1/review", reviewRoutes)
app.use("/api/v1/temple", templeRoutes)
app.use("/api/v1/astrology", astrologyRoutes)



Expand Down
10 changes: 10 additions & 0 deletions src/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,14 @@ background: linear-gradient(0deg, rgba(67,67,67,0) 0%, rgba(255,253,253,0.997724
.fadeColor1{
background: rgb(255,253,253);
background: linear-gradient(0deg, rgba(255,253,253,0.9977240896358543) 0%, rgba(67,67,67,0) 100%);
}


@keyframes spin {
to {
transform: rotate(360deg);
}
}
.animate-spin {
animation: spin 15s linear infinite;
}
4 changes: 4 additions & 0 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ import AllCoupon from "./component/core/Dashboard/Coupon/AllCoupon";
import CreateTempleLoc from "./component/core/Dashboard/TempleLoc/CreateTempleLoc";
import CreateTempleDetails from "./component/core/Dashboard/TempleDetail/CreateTempleDetails";
import TempleById from "./component/core/TempleSection/TempleById";
import Astrology from "./Pages/Astrology";
import GetAstrologyUser from "./component/core/Dashboard/Astrology/GetAstrologyUser";


const App = () => {
Expand All @@ -50,6 +52,7 @@ const App = () => {
<Route path="/articles" element={<AllArticles />} />
<Route path="/temples" element={<TemplePage />} />
<Route path="/temples/:templeId" element={<TempleById />} />
<Route path="/astrology" element={<Astrology />} />

<Route path="/dashboard" element={<Dashboard />}>
<Route path="/dashboard/my-profile" element={<PrivateRoute><MyProfile /></PrivateRoute>} />
Expand All @@ -76,6 +79,7 @@ const App = () => {
<Route path="/dashboard/all-Coupon" element={<PrivateRoute><AllCoupon /></PrivateRoute>} />
<Route path="/dashboard/temple-loc" element={<PrivateRoute><CreateTempleLoc /></PrivateRoute>} />
<Route path="/dashboard/temple-detail" element={<PrivateRoute><CreateTempleDetails /></PrivateRoute>} />
<Route path="/dashboard/astrology-user" element={<PrivateRoute><GetAstrologyUser /></PrivateRoute>} />
</Route>
</Routes>

Expand Down
Binary file added src/Assets/astrology.webp
Binary file not shown.
Binary file added src/Assets/astrologyFront.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 13 additions & 6 deletions src/Data/DashboardLinks.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,7 @@ export const DASHBOARD_LINK = [
path:"/dashboard/my-items",
accountType: ACCOUNT_TYPE.ADMIN
},
{
id:7,
title:"Enrolled user",
accountType: ACCOUNT_TYPE.ADMIN,
path:"/dashboard/Enrolled-user",
},

{
id:11,
title:"Booked pooja",
Expand Down Expand Up @@ -116,6 +111,18 @@ export const DASHBOARD_LINK = [
accountType: ACCOUNT_TYPE.ADMIN,
path:"/dashboard/temple-detail",
},
{
id:7,
title:"Enrolled user",
accountType: ACCOUNT_TYPE.ADMIN,
path:"/dashboard/Enrolled-user",
},
{
id:20,
title:"Astrology user",
accountType: ACCOUNT_TYPE.ADMIN,
path:"/dashboard/astrology-user",
},


]
9 changes: 7 additions & 2 deletions src/Data/NavbarLink.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,18 @@ export const NavLinks = [
id:2,
title:"Puja",
path:"/puja"
}, {
},
{
id:3,
title:"Astrology",
path:"/astrology"
}, {
id:4,
title:"Temples",
path:"/temples"
},
{
id:4,
id:5,
title:"Library",
},
]
112 changes: 112 additions & 0 deletions src/Pages/Astrology.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
import React from 'react'
import { useForm } from 'react-hook-form'
import { astrologyEndPoint } from '../Services/AllApi'
import toast from 'react-hot-toast'
import { apiConnector } from '../Services/ApiConnector'
import astrologyImage from "../Assets/astrologyFront.jpg"
import Footer from '../component/common/Footer'

const Astrology = () => {
const {register, setValue, handleSubmit, formState:{errors}}= useForm()
const {CREATE_FORM_API}= astrologyEndPoint
const onSubmit = async(data)=>{
const {fullName, address, phoneNum, dob} = data
const toastid = toast.loading("Please wait..")
try {
const response = await apiConnector("POST", CREATE_FORM_API, {fullName, address, phoneNum, dob})
toast.success("Thank you!")
setValue("fullName", " ")
setValue("address", " ")
setValue("phoneNum", " ")
setValue("dob", " ")
} catch (error) {
console.log(error)
}
toast.dismiss(toastid)

}
return (
<>
<div className=" flex items-center justify-between flex-col min-h-screen mt-20">
<div className=' max-w-screen-xl mx-auto flex flex-col h-full '>
<div className=' flex justify-between w-full items-center h-full'>

<p className=' text-2xl font-bold px-5'>
Astrology is the study of the movements and relative positions of celestial objects as a means of divining information about human affairs and terrestrial events.
Please fill out the form below to get personalized astrology insights.
</p>

<img src={astrologyImage} alt="" className=' rounded-full w-full h-full object-cover animate-spin' />
</div>

<div className=' w-full flex flex-col items-center justify-center mt-14'>
<form className=' w-full lg:w-[40%] flex flex-col gap-3 p-3' onSubmit={handleSubmit(onSubmit)}>
<div className=" flex flex-col gap-2 px-2" >
<label className=" text-orange-500 font-semibold">
Enter Full name<sup className=" text-red-500 text-sm">*</sup>
</label>
<input
type="text"
className=" w-full border-2 border-orange-500 rounded-xl p-2"
placeholder="Enter full name here"
{...register("fullName", { required: true })}
/>
{errors.fullName && (
<span className=" text-red-500">fullName is required</span>
)}
</div>
<div className=" flex flex-col gap-2 px-2">
<label className=" text-orange-500 font-semibold">
Enter phone number<sup className=" text-red-500 text-sm">*</sup>
</label>
<input
type="number"
placeholder="Whatsapp Number"
className=" w-full border-2 border-orange-500 rounded-xl p-2"
{...register("phoneNum", {
required: { value: true, message: "Please enter Phone Number" },
maxLength: { value: 10, message: "Invalid Phone Number" },
minLength: { value: 8, message: "Invalid Phone Number" }
})}
/>
{errors.phoneNum && (
<span className=" text-red-500">phoneNum is required</span>
)}
</div>
<div className=" flex flex-col gap-2 px-2" >
<label className=" text-orange-500 font-semibold">
Enter address <sup className=" text-red-500 text-sm">(optional)</sup>
</label>
<input
type="text"
className=" w-full border-2 border-orange-500 rounded-xl p-2"
placeholder="Enter address here"
{...register("address", { required: false })}
/>

</div>
<div className=" flex flex-col gap-2 px-2" >
<label className=" text-orange-500 font-semibold">
Enter Date of birth <sup className=" text-red-500 text-sm">(optional)</sup>
</label>
<input
type="date"
className=" w-full border-2 border-orange-500 rounded-xl p-2"
{...register("dob", { required: false })}
/>

</div>
<div className=" w-full items-center flex justify-center p-2">
<button className=" bg-orange-500 px-5 py-2 rounded-xl hover:bg-orange-600 transition-all duration-200">Submit</button>
</div>
</form>
</div>

</div>
</div>
<Footer/>
</>
)
}

export default Astrology
7 changes: 7 additions & 0 deletions src/Services/AllApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,10 @@ export const templeEndPoint = {
}


export const astrologyEndPoint = {
CREATE_FORM_API : BASE_URL + "/astrology/createForm",
GET_FORM_API : BASE_URL + "/astrology/getForm",
DELETE_FORM_API : BASE_URL + "/astrology/deleteForm",

}

62 changes: 62 additions & 0 deletions src/component/core/Dashboard/Astrology/GetAstrologyUser.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import React, { useEffect, useState } from 'react'
import { astrologyEndPoint } from '../../../../Services/AllApi'
import { apiConnector } from '../../../../Services/ApiConnector'
import toast from 'react-hot-toast'
import { RiDeleteBin7Line } from 'react-icons/ri'

const GetAstrologyUser = () => {
const {GET_FORM_API, DELETE_FORM_API} = astrologyEndPoint
const [details, setdetails] = useState([])
const getData = async()=>{
try {
const response= await apiConnector("GET", GET_FORM_API)
setdetails(response.data.data)


} catch (error) {
console.log(error)
}
}
useEffect(() => {
getData()
}, [])
console.log(details)

const handleDelete = async(formId)=>{
try {
await apiConnector("DELETE", DELETE_FORM_API, {formId})
toast.success("Deleted successfully")
getData()


} catch (error) {
console.log(error)
}

}

return (
<div className=' flex flex-col items-center justify-center gap-10 lg:px-0 px-2'>
<h1 className=' text-3xl font-bold text-orange-500'>Astrology users</h1>
<div className=' w-full flex p-3 gap-5 flex-wrap border border-gray-500 rounded-xl '>
{
details.map((data, index)=>{
return <div key={ index} className=' w-full h-fit flex flex-col gap-3 rounded-xl p-3'>
<p className=' text-lg'><span className=' text-orange-500'>Full name:</span> {data?.fullName}</p>
<p className=' text-lg'><span className=' text-orange-500'>Address:</span> {data?.address}</p>
<p className=' text-lg'><span className=' text-orange-500'>Phone number:</span> {data?.phoneNum}</p>
<p className=' text-lg'><span className=' text-orange-500'>Date of birth:</span> {data?.dob?.split("T")[0]}</p>
<button className=' flex items-center gap-2 bg-red-500 p-2 w-fit'
onClick={()=> handleDelete(data._id)}
>Delete<RiDeleteBin7Line /></button>
</div>
})
}

</div>

</div>
)
}

export default GetAstrologyUser
Loading

0 comments on commit f0c067f

Please sign in to comment.