all complete

This commit is contained in:
pawan-dot 2022-07-20 11:02:56 +05:30
parent 24dbbd76ce
commit 576f29d1d5
11 changed files with 243 additions and 57 deletions

View File

@ -15,6 +15,7 @@ import News from "./views/News/News"
import ViewNews from "./views/News/ViewNews"
//Events
import Event from './views/Events/Event'
import AllRegisterUser from './views/Events/AllRegisterUser'
import EditEvent from './views/Events/EditEvent'
import AddEvent from './views/Events/AddEvent'
import ViewEvent from './views/Events/ViewEvent'
@ -73,6 +74,8 @@ const routes = [
{ path: '/news/edit/:id', name: 'EditNews', component: EditNews },
{ path: '/news', name: 'news', component: News },
//Events route
{ path: '/event/registerUsers/view/:id', name: 'AllRegisterUser', component: AllRegisterUser },
{ path: '/event/view/:id', name: 'ViewEvent', component: ViewEvent },
{ path: '/addevent', name: 'AddEvent', component: AddEvent },
{ path: '/event/edit/:id', name: 'EditEvent', component: EditEvent },

View File

@ -22,7 +22,7 @@ import {
import CIcon from '@coreui/icons-react'
import { cilPencil, cilSettings, cilLockLocked, cilUser, cilBell, cilLocationPin, cilAudioDescription } from '@coreui/icons'
const AddEvent = () => {
const { token } = isAutheticated();
const token = isAutheticated();
let history = useHistory();
const [image, setImage] = useState("");
const [title, setTitle] = useState("");
@ -98,11 +98,12 @@ const AddEvent = () => {
<CInputGroupText>
<CIcon icon={cilPencil} />
</CInputGroupText>
<CFormInput type="text"
<CFormInput maxlength="50" mtype="text"
required
onChange={(e) => setTitle(e.target.value)}
value={title}
placeholder="Title" />
placeholder="Title (maximum 50 characters)" />
</CInputGroup>
<CInputGroup className="mb-3">
@ -110,10 +111,11 @@ const AddEvent = () => {
<CIcon icon={cilAudioDescription} />
</CInputGroupText>
<CFormInput type="text"
maxlength="250"
required
onChange={(e) => setDescription(e.target.value)}
value={description}
placeholder="Description" />
placeholder="Description (maximum 250 characters)" />
</CInputGroup>
<CInputGroup className="mb-3">
<CInputGroupText>

View File

@ -0,0 +1,115 @@
import axios from "axios";
import React, { useEffect, useState, useCallback, useMemo } from "react";
import swal from 'sweetalert';
// import { API } from "../../data";
import { Link, useParams } from "react-router-dom";
import { isAutheticated } from "../../auth";
const AllRegisterUser = () => {
const { id } = useParams();
const token = isAutheticated();
const [registerUser, setRegisterUser] = useState([])
const getRegisterUser = useCallback(async () => {
let res = await axios.get(
`/api/event/admin/registerUser/getAll/${id}`,
{
headers: {
Authorization: `Bearer ${token}`,
},
}
);
console.log(res.data)
setRegisterUser(res.data.user)
}, [token]);
useEffect(() => {
getRegisterUser();
}, [getRegisterUser]);
console.log(registerUser)
//change time formate
function formatAMPM(date) {
var hours = new Date(date).getHours();
var minutes = new Date(date).getMinutes();
var ampm = hours >= 12 ? 'PM' : 'AM';
hours = hours % 12;
hours = hours ? hours : 12; // the hour '0' should be '12'
minutes = minutes < 10 ? '0' + minutes : minutes;
var strTime = hours + ':' + minutes + ' ' + ampm;
return strTime;
}
return (
<><div className=" main-content">
<div className=" my-3 page-content">
<div className="container-fluid">
{/* <!-- start page title --> */}
<div className="row">
<div className="col-12">
<div className="page-title-box d-flex align-items-center justify-content-between">
<h4 className="mb-3">CMP-Event Register Users</h4>
</div>
</div>
</div>
{/* <!-- end page title --> */}
<div className="row">
<div className="col-lg-12">
<div className="card">
<div className="card-body">
<div className="row ml-0 mr-0 mb-10">
</div>
<div className="table-responsive table-shoot">
<table className="table table-centered table-nowrap mb-0">
<thead className="thead-light">
<tr>
<th>Name</th>
<th> Profile Image</th>
<th>Email</th>
<th>Phone</th>
<th>register At</th>
</tr>
</thead>
<tbody>
{registerUser && registerUser.map((item, index) =>
<tr>
<td>{item.userId?.name}</td>
<td>
<img src={`${item.userId.avatar?.url}`} width="50" alt="" /></td>
<td>{item.userId?.email}</td>
<td>{item.userId?.phone}</td>
<td>
{/* {item?.addedOn} */}
{new Date(`${item.userId?.createdAt}`).toDateString()}<span> , {`${formatAMPM(item.userId?.createdAt)}`}</span>
</td>
</tr>
)}
</tbody>
</table>
</div>
{/* <!-- end table-responsive --> */}
</div>
</div>
</div>
</div>
</div>
{/* <!-- container-fluid --> */}
</div>
</div></>
);
}
export default AllRegisterUser;

View File

@ -25,7 +25,7 @@ import { cilPencil, cilSettings, cilLockLocked, cilUser, cilBell, cilLocationPin
const EditEvent = () => {
const { id } = useParams();
// console.log(id)
const { token } = isAutheticated();
const token = isAutheticated();
let history = useHistory();
const [image, setImage] = useState("");
const [title, setTitle] = useState("");
@ -115,20 +115,22 @@ const EditEvent = () => {
<CIcon icon={cilPencil} />
</CInputGroupText>
<CFormInput type="text"
maxlength="50"
required
onChange={(e) => setTitle(e.target.value)}
value={title}
placeholder="Title" />
placeholder="Title (maximum 50 characters)" />
</CInputGroup>
<CInputGroup className="mb-3">
<CInputGroupText>
<CIcon icon={cilAudioDescription} />
</CInputGroupText>
<CFormInput type="text"
maxlength="250"
required
onChange={(e) => setDescription(e.target.value)}
value={description}
placeholder="Description" />
placeholder="Description (maximum 250 characters)" />
</CInputGroup>
<CInputGroup className="mb-3">
<CInputGroupText>

View File

@ -3,13 +3,14 @@ import axios from "axios";
import React, { useEffect, useState, useCallback, useMemo } from "react";
import { Link } from "react-router-dom";
import swal from 'sweetalert';
import RegisterUser from "./RegisterUser";
// import { API } from "../../data";
import { isAutheticated } from "../../auth";
function Event() {
const [event, setEvent] = useState([])
const { token } = isAutheticated();
const token = isAutheticated();
const getEvent = useCallback(async () => {
let res = await axios.get(
@ -99,52 +100,13 @@ function Event() {
<th>Image</th>
<th>Location</th>
<th>Added On</th>
<th>Attended By</th>
<th>Action</th>
</tr>
</thead>
<tbody>
{event && event.map((item, index) =>
<tr>
<td>{item?.title}</td>
<td>
<img src={`${item?.image.url}`} width="50" alt="" /></td>
<td>{item?.location}</td>
<td>
{/* {item?.addedOn} */}
{new Date(`${item?.addedOn}`).toDateString()}<span> , {`${formatAMPM(item?.addedOn)}`}</span>
</td>
<td>
<Link to={`/event/view/${item._id}`}>
<button
type="button"
className=" mx-1 mt-1 btn btn-info btn-sm waves-effect waves-light btn-table ml-2"
>
View
</button>
</Link>
<Link to={`/event/edit/${item._id}`}>
<button
type="button"
className=" mx-1 mt-1 btn btn-primary btn-sm waves-effect waves-light btn-table ml-2"
>
Edit
</button>
</Link>
<button
type="button"
onClick={() => handleDelete(`${item._id}`)}
className="mx-1 mt-1 btn btn-danger btn-sm waves-effect waves-light btn-table ml-2"
id="sa-params"
>
Delete
</button>
</td>
</tr>
<RegisterUser item={item} handleDelete={handleDelete} formatAMPM={formatAMPM} />
)}
</tbody>
</table>

View File

@ -0,0 +1,90 @@
import axios from "axios";
import React, { useEffect, useState, useCallback, useMemo } from "react";
import { Link } from "react-router-dom";
import swal from 'sweetalert';
// import { API } from "../../data";
import { isAutheticated } from "../../auth";
const RegisterUser = ({ item, handleDelete, formatAMPM }) => {
const [totalRegisterUser, setTotalRegisterUser] = useState([])
const token = isAutheticated();
const getRegisterUser = useCallback(async () => {
let res = await axios.get(
`/api/event/admin/registerUser/getAll/${item._id}`,
{
headers: {
Authorization: `Bearer ${token}`,
},
}
);
console.log(res.data)
setTotalRegisterUser(res.data.totalUserRegister)
}, [token]);
useEffect(() => {
getRegisterUser();
}, [getRegisterUser, item]);
return (
<>
<tr>
<td>{item?.title}</td>
<td>
<img src={`${item?.image.url}`} width="50" alt="" /></td>
<td>{item?.location}</td>
<td>
{/* {item?.addedOn} */}
{new Date(`${item?.addedOn}`).toDateString()}<span> , {`${formatAMPM(item?.addedOn)}`}</span>
</td>
<td>
<Link to={`/event/registerUsers/view/${item._id}`}>
<button
type="button"
className=" mx-1 mt-1 btn btn-warning btn-sm waves-effect waves-light btn-table ml-2"
>
{totalRegisterUser}
</button>
</Link>
</td>
<td>
<Link to={`/event/view/${item._id}`}>
<button
type="button"
className=" mx-1 mt-1 btn btn-info btn-sm waves-effect waves-light btn-table ml-2"
>
View
</button>
</Link>
<Link to={`/event/edit/${item._id}`}>
<button
type="button"
className=" mx-1 mt-1 btn btn-primary btn-sm waves-effect waves-light btn-table ml-2"
>
Edit
</button>
</Link>
<button
type="button"
onClick={() => handleDelete(`${item._id}`)}
className="mx-1 mt-1 btn btn-danger btn-sm waves-effect waves-light btn-table ml-2"
id="sa-params"
>
Delete
</button>
</td>
</tr>
</>
)
}
export default RegisterUser

View File

@ -129,10 +129,11 @@ const AddOffer = () => {
<CIcon icon={cilPencil} />
</CInputGroupText>
<CFormInput type="text"
maxlength="250"
required
onChange={(e) => setTitle(e.target.value)}
value={title}
placeholder="Title" />
placeholder="Title (maximum 50 characters)" />
</CInputGroup>
<CInputGroup className="mb-3">
@ -140,10 +141,11 @@ const AddOffer = () => {
<CIcon icon={cilAudioDescription} />
</CInputGroupText>
<CFormInput type="text"
maxlength="250"
required
onChange={(e) => setDescription(e.target.value)}
value={description}
placeholder="Description" />
placeholder="Description (maximum 250 characters)" />
</CInputGroup>
<CInputGroup className="mb-3">
<CInputGroupText>

View File

@ -138,10 +138,11 @@ const EditOffer = () => {
<CIcon icon={cilPencil} />
</CInputGroupText>
<CFormInput type="text"
maxlength="50"
required
onChange={(e) => setTitle(e.target.value)}
value={title}
placeholder="Title" />
placeholder="Title (maximum 50 characters)" />
</CInputGroup>
<CInputGroup className="mb-3">
@ -149,10 +150,11 @@ const EditOffer = () => {
<CIcon icon={cilAudioDescription} />
</CInputGroupText>
<CFormInput type="text"
maxlength="250"
required
onChange={(e) => setDescription(e.target.value)}
value={description}
placeholder="Description" />
placeholder="Description (maximum 250 characters)" />
</CInputGroup>
<CInputGroup className="mb-3">
<CInputGroupText>

View File

@ -117,10 +117,11 @@ const AddRequirement = () => {
<CIcon icon={cilPencil} />
</CInputGroupText>
<CFormInput type="text"
maxlength="50"
required
onChange={(e) => setTitle(e.target.value)}
value={title}
placeholder="Title" />
placeholder="Title (maximum 50 characters)" />
</CInputGroup>
<CInputGroup className="mb-3">
<CInputGroupText>
@ -138,10 +139,11 @@ const AddRequirement = () => {
<CIcon icon={cilAudioDescription} />
</CInputGroupText>
<CFormInput type="text"
maxlength="250"
required
onChange={(e) => setDescription(e.target.value)}
value={description}
placeholder="Description" />
placeholder="Description (maximum 250 characters)" />
</CInputGroup>

View File

@ -133,9 +133,10 @@ const EditRequirement = () => {
</CInputGroupText>
<CFormInput type="text"
required
maxlength="50"
onChange={(e) => setTitle(e.target.value)}
value={title}
placeholder="Title" />
placeholder="Title (maximum 50 characters)" />
</CInputGroup>
<CInputGroup className="mb-3">
<CInputGroupText>
@ -153,10 +154,11 @@ const EditRequirement = () => {
<CIcon icon={cilAudioDescription} />
</CInputGroupText>
<CFormInput type="text"
maxlength="250"
required
onChange={(e) => setDescription(e.target.value)}
value={description}
placeholder="Description" />
placeholder="Description (maximum 250 characters)" />
</CInputGroup>

View File

@ -33,6 +33,10 @@ const Login = () => {
};
const Login = async () => {
if (!(auth.email && auth.password)) {
alert("please filled both fields")
return
}
setLoading({ loading: true })
try {
const res = await axios.post("/api/v1/user/login/", auth);