-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 parent
32cf8bc
commit f0c067f
Showing
14 changed files
with
323 additions
and
9 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
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, | ||
}); | ||
} | ||
} |
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,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) |
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,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 |
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
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
Binary file not shown.
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
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,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 |
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
62 changes: 62 additions & 0 deletions
62
src/component/core/Dashboard/Astrology/GetAstrologyUser.js
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,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 |
Oops, something went wrong.