Commit eac818da by jaymehta

admin

1 parent 1f8452e1
import { Fragment, useState } from "react"; import { SearchOutlined } from "@ant-design/icons";
import { Button, Image, Table } from "react-bootstrap"; import { Button, Input, Space, Table } from "antd";
import { Fragment, useEffect, useRef, useState } from "react";
import { useDispatch, useSelector } from "react-redux";
import { getActivitiesForAdmin } from "../../redux/actions/activityAction";
const ActivityListing = () => { const ActivityListing = () => {
const array = [1, 2, 3, 4, 5, 6, 7, 8, 9]; const dispatch = useDispatch();
const { allActivitiesData } = useSelector(state => state.allActivitiesData);
useEffect(() => {
dispatch(getActivitiesForAdmin({}));
}, []);
console.log("allActivitiesData", allActivitiesData);
const [showMenuIndex, setShowMenuIndex] = useState(null); const [showMenuIndex, setShowMenuIndex] = useState(null);
const [data, setdata] = useState(null);
const toggleMenu = (index) => { const toggleMenu = index => {
setShowMenuIndex(index === showMenuIndex ? null : index); setShowMenuIndex(index === showMenuIndex ? null : index);
}; };
return ( useEffect(() => {
<Fragment> let allActivities = allActivitiesData && allActivitiesData.data.map(item => {
<div className="row"> return {
<div className="col-12 col-lg-12"> key: item.id,
<div className="rightContent"> name: item.attributes.name,
<div className="d-flex align-items-center justify-content-between px-2 mb-2"> category: "yet to map",
<div> pincode: item.attributes.masterPincode.data.attributes.name,
<h2>Activities</h2> price: item.attributes.pricePerPerson,
<p>View all the Activities</p> activityType: item.attributes.activityType,
</div> gift: item.attributes.giftSomeone ? "Allowed" : "Not allowed",
<div> vendorWebsite: item.attributes.link
<Button type="button" variant="" className="btnAdd m-0"> }
<Image alt="" width="16" height="16" src="/images/vendor/icon-filter.svg" className="me-2" /> Filter })
setdata(allActivities)
}, [allActivitiesData]);
const [searchText, setSearchText] = useState("");
const [searchedColumn, setSearchedColumn] = useState("");
const searchInput = useRef(null);
const handleSearch = (selectedKeys, confirm, dataIndex) => {
confirm();
setSearchText(selectedKeys[0]);
setSearchedColumn(dataIndex);
};
const handleReset = clearFilters => {
clearFilters();
setSearchText("");
};
const getColumnSearchProps = dataIndex => ({
filterDropdown: ({ setSelectedKeys, selectedKeys, confirm, clearFilters, close }) => (
<div
style={{
padding: 8
}}
onKeyDown={e => e.stopPropagation()}
>
<Input
ref={searchInput}
placeholder={`Search ${dataIndex}`}
value={selectedKeys[0]}
onChange={e => setSelectedKeys(e.target.value ? [e.target.value] : [])}
onPressEnter={() => handleSearch(selectedKeys, confirm, dataIndex)}
style={{
marginBottom: 8,
display: "block"
}}
/>
<Space>
<Button
type="primary"
onClick={() => handleSearch(selectedKeys, confirm, dataIndex)}
icon={<SearchOutlined />}
size="small"
style={{
width: 90
}}
>
Search
</Button> </Button>
<Button
onClick={() => clearFilters && handleReset(clearFilters)}
size="small"
style={{
width: 90
}}
>
Reset
</Button>
<Button
type="link"
size="small"
onClick={() => {
confirm({
closeDropdown: false
});
setSearchText(selectedKeys[0]);
setSearchedColumn(dataIndex);
}}
>
Filter
</Button>
<Button
type="link"
size="small"
onClick={() => {
close();
}}
>
close
</Button>
</Space>
</div> </div>
</div> ),
<Table responsive className="listingTable"> filterIcon: filtered => (
<thead> <SearchOutlined
<tr> style={{
<th> color: filtered ? "#1677ff" : undefined
<label className="check-container mb-0 ps-2" htmlFor="checkh"> }}
<input
type="checkbox"
id="checkh"
className="check-box"
/> />
<span className="checkmark"></span> ),
</label> onFilter: (value, record) => record[dataIndex].toString().toLowerCase().includes(value.toLowerCase()),
</th> onFilterDropdownOpenChange: visible => {
<th>Category</th> if (visible) {
<th>Name</th> setTimeout(() => searchInput.current?.select(), 100);
<th>Location</th> }
<th>Price</th> },
<th>Place</th> render: text =>
<th>Gift</th> searchedColumn === dataIndex ? (
<th>Vendor Website</th> <Highlighter
<th></th> highlightStyle={{
<th></th> backgroundColor: "#ffc069",
</tr> padding: 0
</thead> }}
<tbody> searchWords={[searchText]}
{array.map((data, index) => ( autoEscape
<tr key={index}> textToHighlight={text ? text.toString() : ""}
<td>
<label className="check-container mb-0 ps-2" htmlFor={`check${index}`}>
<input
type="checkbox"
id={`check${index}`}
className="check-box"
/> />
<span className="checkmark"></span> ) : (
</label> text
</td> )
<td><span>Adventure</span></td> });
<td>Ice-Skating in NY</td> const columns = [
<td>North Avenue</td> {
<td>$ 479</td> title: "Name",
<td>Outdoor</td> dataIndex: "name",
<td>Allowed</td> key: "name",
<td><span style={{ color: "#0070BD", marginRight: ".5rem" }}>View Link</span> <Image alt="" width={17} height={17} src="/images/admin/icon-link.svg" /></td> width: "30%",
<td><Image alt="" width={20} height={20} src="/images/vendor/icon-view.svg" /></td> ...getColumnSearchProps("name")
<td> },
<div className="actions"> {
<div className="ellipse" onClick={() => toggleMenu(index)}> title: "Category",
<Image alt="" width={20} height={20} src="/images/vendor/icon-more-vertical.svg" /> dataIndex: "category",
</div> key: "category",
{showMenuIndex === index && ( width: "20%",
<div className="menu"> ...getColumnSearchProps("category")
<ul> },
<li>Delete</li> {
</ul> title: "Address",
</div> dataIndex: "address",
)} key: "address",
</div> ...getColumnSearchProps("address"),
</td> sorter: (a, b) => a.address.length - b.address.length,
</tr> sortDirections: ["descend", "ascend"]
))} }
<tr> ];
<td colSpan={10}>Showing Results 10 of 1567</td> return (
</tr> <Fragment>
</tbody> <div className="row">
</Table> <Table columns={columns} dataSource={data} />
</div>
</div>
</div> </div>
</Fragment> </Fragment>
); );
......
import { Formik } from "formik"; import { Formik } from "formik";
import { Fragment, useState } from "react"; import { Fragment, useState } from "react";
import { Button, Form, Modal } from "react-bootstrap"; import { Button, Form, Modal } from "react-bootstrap";
import { useDispatch } from "react-redux";
import ReactSelect from "react-select"; import ReactSelect from "react-select";
import * as Yup from "yup"; import * as Yup from "yup";
import { updateApprovalStatusAdmin } from "../../redux/actions/userActions";
import { getAllVendors } from "../../redux/actions/vendorActions";
const RejectModal = ({ show, handleClose }) => { const RejectModal = ({ show, handleClose, detail, setShowDetail }) => {
const dispatch = useDispatch();
console.log("detail", detail[0].attributes.email);
const formValidationSchema = Yup.object().shape({ const formValidationSchema = Yup.object().shape({
email: Yup.string().required("Email Id is Required").email("Please Enter An Valid Email Id"), email: Yup.string(),
reason: Yup.string().required("Reason is Required"), reason: Yup.string().required("Reason is Required"),
comments: Yup.string().required("Comment is Required"), comments: Yup.string()
}); });
const reasonOptions = [ const reasonOptions = [{ value: "Not listed", label: "Not listed" }];
{ value: "Not listed", label: "Not listed" }
]
const [selectedOption, setSelectedOption] = useState(null); const [selectedOption, setSelectedOption] = useState(null);
const [showComments, setshowComments] = useState(false);
return ( return (
<Fragment> <Fragment>
<Modal show={show} onHide={handleClose} aria-labelledby="contained-modal-title-vcenter" <Modal show={show} onHide={handleClose} aria-labelledby="contained-modal-title-vcenter" centered>
centered>
<Modal.Body> <Modal.Body>
<div className="row"> <div className="row">
<div className="col-12 col-lg-12"> <div className="col-12 col-lg-12">
...@@ -28,12 +31,32 @@ const RejectModal = ({ show, handleClose }) => { ...@@ -28,12 +31,32 @@ const RejectModal = ({ show, handleClose }) => {
<div className="form-container"> <div className="form-container">
<Formik <Formik
initialValues={{ initialValues={{
email: "", email: detail[0].attributes.email,
reason: "", reason: "",
comments: "", comments: ""
}} }}
validationSchema={formValidationSchema} validationSchema={formValidationSchema}
onSubmit={(values) => { onSubmit={async values => {
console.log("values", values);
let data;
if (showComments) {
data = {
email: values.email,
rejectionReason: values.comments
};
} else {
data = {
email: values.email,
rejectionReason: values.reason
};
}
console.log(data);
let response = await updateApprovalStatusAdmin({ status: "rejected", userId: detail[0].attributes.user.data.id, rejectionReason: data.rejectionReason });
console.log(response.data);
await dispatch(getAllVendors());
handleClose()
setShowDetail(false);
}} }}
> >
{({ values, errors, touched, handleChange, handleBlur, handleSubmit }) => ( {({ values, errors, touched, handleChange, handleBlur, handleSubmit }) => (
...@@ -43,40 +66,55 @@ const RejectModal = ({ show, handleClose }) => { ...@@ -43,40 +66,55 @@ const RejectModal = ({ show, handleClose }) => {
handleSubmit(); handleSubmit();
}} }}
> >
{/* {console.log("formik.values",values)} */}
<div className="input-group"> <div className="input-group">
<label>Email Id</label> <label>Email Id</label>
<input type="text" name="email" onChange={handleChange} onBlur={handleBlur} value={values.email} placeholder="yourname@example.com" style={{ backgroundColor: "#EBEBEB", boxShadow: "1.63px 3.26px 4.07px 0px #FFFFFF40 inset", border: "none" }} /> <input
disabled={true}
type="text"
name="email"
onChange={handleChange}
onBlur={handleBlur}
value={values.email}
placeholder="yourname@example.com"
style={{ backgroundColor: "#EBEBEB", boxShadow: "1.63px 3.26px 4.07px 0px #FFFFFF40 inset", border: "none" }}
/>
{errors.email && touched.email && <span className="form-error">{errors.email}</span>} {errors.email && touched.email && <span className="form-error">{errors.email}</span>}
</div> </div>
<div className="input-group mb-1"> <div className="input-group mb-1">
<label>Reason</label> <label>Reason</label>
<select <select
name="reason" name="reason"
onChange={handleChange} onChange={e => {
console.log(e);
handleChange(e);
if (e.target.value == "notListed") {
setshowComments(true);
} else {
setshowComments(false);
}
}}
onBlur={handleBlur} onBlur={handleBlur}
value={values.reason} value={values.reason}
> >
<option value="">Select</option> <option value="">Select</option>
<option value="Not listed">Not listed</option> <option value="Invalid address details">Invalid address details</option>
<option value="Invalid business details">Invalid business details</option>
<option value="Bogus PAN number">Bogus PAN number</option>
<option value="notListed">Not listed</option>
</select> </select>
{/* <ReactSelect
defaultValue={selectedOption}
onChange={setSelectedOption}
options={reasonOptions}
/> */}
{errors.reason && touched.reason && <span className="form-error">{errors.reason}</span>} {errors.reason && touched.reason && <span className="form-error">{errors.reason}</span>}
</div> </div>
{showComments && (
<div className="input-group"> <div className="input-group">
<textarea rows={4} placeholder="Leave your comments here..." name="comments" <textarea rows={4} placeholder="Leave your comments here..." name="comments" onChange={handleChange} onBlur={handleBlur} value={values.comments} />
onChange={handleChange}
onBlur={handleBlur}
value={values.comments} />
{errors.comments && touched.comments && <span className="form-error">{errors.comments}</span>} {errors.comments && touched.comments && <span className="form-error">{errors.comments}</span>}
</div> </div>
)}
<div className="my-4"> <div className="my-4">
<div className="d-flex justify-content-center"> <div className="d-flex justify-content-center">
<Button type="submit" variant="" className="btnAdd btnApprove m-0"> <Button type="submit" variant="" className="btnAdd btnApprove m-0" disabled={values.comments == "" && showComments}>
Submit Submit
</Button> </Button>
<div className="px-1"></div> <div className="px-1"></div>
...@@ -95,6 +133,6 @@ const RejectModal = ({ show, handleClose }) => { ...@@ -95,6 +133,6 @@ const RejectModal = ({ show, handleClose }) => {
</Modal.Body> </Modal.Body>
</Modal> </Modal>
</Fragment> </Fragment>
) );
} };
export default RejectModal; export default RejectModal;
import React from 'react'
import { Modal } from 'react-bootstrap'
import VendorDetails from './VendorDetails';
const VendorDetailModal = ({setShowDetail, showDetail, detail}) => {
console.log("detail", detail);
return (
<div>
{/* <Modal show={showDetail} onHide={()=>{setShowDetail(false)}}>
<Modal.Header closeButton>
<Modal.Title>{detail[0].attributes.businessName}</Modal.Title>
</Modal.Header>
<Modal.Body>
modal
</Modal.Body>
</Modal> */}
</div>
)
}
export default VendorDetailModal
\ No newline at end of file \ No newline at end of file
...@@ -9,9 +9,9 @@ import { loadUser } from "../../redux/actions/userActions"; ...@@ -9,9 +9,9 @@ import { loadUser } from "../../redux/actions/userActions";
import { useRouter } from "next/router"; import { useRouter } from "next/router";
const Header = () => { const Header = () => {
const { user, error } = useSelector(state => state.loadedUser); const { loadedUser } = useSelector(state => state.loadedUser);
const dispatch = useDispatch(); const dispatch = useDispatch();
// console.log("user", user); // console.log("user", loadedUser);
const [isSticky, setIsSticky] = useState(false); const [isSticky, setIsSticky] = useState(false);
const router = useRouter(); const router = useRouter();
useEffect(() => { useEffect(() => {
...@@ -60,12 +60,12 @@ const Header = () => { ...@@ -60,12 +60,12 @@ const Header = () => {
</div> </div>
</Form> </Form>
{/* {console.log(user.id)} */} {/* {console.log(user.id)} */}
{user && user.id ? ( {loadedUser && loadedUser.id ? (
<div> <div>
<div> <div>
<p>Brand Logo</p> <p>Brand Logo</p>
</div> </div>
<p>{user.phone}</p> <p>{loadedUser.phone}</p>
<Button <Button
onClick={async () => { onClick={async () => {
signOut({ redirect: false }); signOut({ redirect: false });
......
...@@ -9,6 +9,8 @@ import { useDispatch, useSelector } from "react-redux"; ...@@ -9,6 +9,8 @@ import { useDispatch, useSelector } from "react-redux";
const Layout = ({ children, title = "Zango", description = "Zango" }) => { const Layout = ({ children, title = "Zango", description = "Zango" }) => {
const dispatch = useDispatch(); const dispatch = useDispatch();
// const { loadedUser } = useSelector(state => state.loadedUser);
// console.log(">>>", loadedUser);
useEffect(() => { useEffect(() => {
dispatch(loadUser()); dispatch(loadUser());
}, []); }, []);
......
...@@ -24,7 +24,7 @@ const Login = props => { ...@@ -24,7 +24,7 @@ const Login = props => {
<div className="row"> <div className="row">
<div className="col-11 col-lg-4 login-div"> <div className="col-11 col-lg-4 login-div">
<div className=""> <div className="">
<h2>{props.type == "user" ? "Login to Experience" : (props.type == "vendor" ? "Vendor Login" : "Admin Login")}</h2> <h2>{props.type == "user" ? "Login to Experience" : "Vendor Login"}</h2>
<div className="form-container"> <div className="form-container">
<Formik <Formik
initialValues={{ initialValues={{
......
...@@ -17,21 +17,21 @@ const BusinessDetails = () => { ...@@ -17,21 +17,21 @@ const BusinessDetails = () => {
const router = useRouter() const router = useRouter()
const { loggedInVendor } = useSelector(state => state.loggedInVendor); const { loggedInVendor } = useSelector(state => state.loggedInVendor);
const { vendorDetails } = useSelector(state => state.vendorDetails); const { vendorDetails } = useSelector(state => state.vendorDetails);
const { user, error } = useSelector(state => state.loadedUser); const { loadedUser, error } = useSelector(state => state.loadedUser);
// const [pincodeData, setPinCodeData] = useState() // const [pincodeData, setPinCodeData] = useState()
// const ref = useRef(null); // const ref = useRef(null);
// console.log("vendorDetails", vendorDetails); console.log("vendorDetails", vendorDetails);
const [disableFields, setdisableFields] = useState(); const [disableFields, setdisableFields] = useState();
useEffect(() => { useEffect(() => {
console.log("user", user); console.log("user", loadedUser);
if (user) { if (loadedUser) {
if (user.approved == "approved" || user.approved == "rejected") { if (loadedUser.approved == "approved" || loadedUser.approved == "rejected") {
setdisableFields(false); setdisableFields(false);
} else if (user.approved == "pending") { } else if (loadedUser.approved == "pending") {
setdisableFields(true); setdisableFields(true);
} }
} }
}, [user]); }, [loadedUser]);
// console.log("userStatus", userStatus); // console.log("userStatus", userStatus);
useEffect(() => { useEffect(() => {
const fetchSession = async () => { const fetchSession = async () => {
...@@ -82,8 +82,8 @@ const BusinessDetails = () => { ...@@ -82,8 +82,8 @@ const BusinessDetails = () => {
} }
const ApprovalStatus = () => { const ApprovalStatus = () => {
if (user) { if (loadedUser) {
switch (user.approved) { switch (loadedUser.approved) {
case "approved": case "approved":
return <></>; return <></>;
...@@ -116,7 +116,7 @@ const BusinessDetails = () => { ...@@ -116,7 +116,7 @@ const BusinessDetails = () => {
// vendorDetails && console.log("vendorData", vendorData, vendorDetails.length > 0); // vendorDetails && console.log("vendorData", vendorData, vendorDetails.length > 0);
return ( return (
<Fragment> <Fragment>
{user && ( {loadedUser && (
<div className="container p-5"> <div className="container p-5">
<div className="row"> <div className="row">
<div className="col-12 col-lg-8"> <div className="col-12 col-lg-8">
......
import React from "react"; import React, { useEffect, useState } from "react";
import Layout from "../../../components/layout/Layout"; import Layout from "../../../components/layout/Layout";
import Sidebar from "../../../components/layout/AdminDashboardSidebar"; import Sidebar from "../../../components/layout/AdminDashboardSidebar";
import ActivityListing from "../../../components/admin/ActivityListing"; import ActivityListing from "../../../components/admin/ActivityListing";
import ActivityListingRBAC from "../../../components/vendor/ActivityListingRBAC";
import { wrapper } from "../../../redux/store";
import { loadUser } from "../../../redux/actions/userActions";
import { getAllCategories, getAllSubCategories } from "../../../redux/actions/categoriesAction";
import { useDispatch } from "react-redux";
import { getActivitiesForAdmin } from "../../../redux/actions/activityAction";
import ActivityDetailsModal from "../../../components/admin/ActivityDetailsModal";
export default function ActivityListingPage() { export default function ActivityListingPage() {
const [activityDetailInfo, setactivityDetailInfo] = useState();
const [showActivityDetailsModal, setShowActivityDetailsModal] = useState(false);
const handleCloseActivityDetails = () => {
setShowActivityDetailsModal(false);
};
const dispatch = useDispatch();
useEffect(() => {
dispatch(getActivitiesForAdmin({}));
}, []);
return ( return (
<Layout> <Layout>
<div className="sidebarContainer"> <div className="sidebarContainer">
<Sidebar /> <Sidebar />
<div className="content"> <div className="content">
<ActivityListing /> {/* <ActivityListing /> */}
<ActivityListingRBAC setactivityDetailInfo={setactivityDetailInfo} setShowActivityDetailsModal={setShowActivityDetailsModal} />
{showActivityDetailsModal && (
<ActivityDetailsModal show={showActivityDetailsModal} handleClose={handleCloseActivityDetails} activityDetailInfo={activityDetailInfo} />
)}
</div> </div>
</div> </div>
</Layout> </Layout>
); );
}; }
/** For server side rendering */
export const getServerSideProps = wrapper.getServerSideProps(store => async ({ req, query }) => {
await store.dispatch(loadUser());
// await store.dispatch(getActivitiesByVendor());
await store.dispatch(getAllCategories());
await store.dispatch(getAllSubCategories());
// get the locations data.
// await store.dispatch(getVendorDetails())
return {
props: {}
};
});
import React, { useState } from "react";
import { Formik } from "formik";
import Image from "next/image";
import Link from "next/link";
import { Fragment } from "react";
import { Button, Form } from "react-bootstrap";
import * as Yup from "yup";
import { useRouter } from "next/router";
import { signIn } from "next-auth/react";
import { toast } from "react-toastify";
import { Loader } from "react-bootstrap-typeahead";
import { renderImage } from "../../services/imageHandling";
const AdminLogin = () => {
const [loading, setLoading] = useState(false);
const loginValidationSchema = Yup.object().shape({
email: Yup.string().required("Email Id is Required").email("Please Enter An Valid Email Id"),
password: Yup.string().required("Password is Required").min(6, "Password must be minimum 6 characters")
});
const router = useRouter();
return (
<div>
<Fragment>
<div className="contaier-fluid login-banner-image">
<div className="row">
{/* <div className="text-center">
<h1 style={{fontSize: "4rem"}}>Zango Admin Login</h1>
</div> */}
<div className="col-11 col-lg-4 login-div">
<div className="">
<h2 className="text-center">Zango Admin Login</h2>
<div className="form-container">
<Formik
initialValues={{
email: "",
password: ""
}}
validationSchema={loginValidationSchema}
// enableReinitialize={true}
onSubmit={async values => {
setLoading(true);
console.log("login values", values);
const signInResponse = await signIn("credentials", {
email: values.email,
password: values.password,
redirect: false
});
console.log("signInResponse", signInResponse);
if (!signInResponse.ok) {
toast.error(signInResponse.error);
setLoading(false);
return;
}
if (signInResponse.ok) {
setLoading(false);
router.push("/admin/vendors");
}
// router.push("")
}}
>
{({ values, errors, touched, handleChange, handleBlur, handleSubmit }) => (
<Form
onSubmit={e => {
e.preventDefault();
handleSubmit();
}}
>
<div className="input-group">
<label>Email Id</label>
<input type="text" name="email" onChange={handleChange} onBlur={handleBlur} value={values.email} placeholder="yourname@example.com" />
{errors.email && touched.email && <span className="form-error">{errors.email}</span>}
</div>
<div className="input-group">
<label>Password</label>
<input type="password" name="password" onChange={handleChange} onBlur={handleBlur} value={values.password} placeholder="#@$!%@#" />
{errors.password && touched.password && <span className="form-error">{errors.password}</span>}
</div>
<div className="input-group">
<Button type="submit" className="btn btn-primary btn-submit" disabled={loading}>
{loading ? <Loader /> : "Login"}
</Button>
</div>
</Form>
)}
</Formik>
{/* <div className="input-group justify-content-center">
<p className="text-center mb-0">
or{" "}
<Link href={`../signup/${}`}>
<span style={{ textDecoration: "underline", cursor: "pointer" }}>Create a new account</span>
</Link>
</p>
</div> */}
{/* {props && props.type == "user" && (
<>
<div className="input-group mb-0">
<div className="btn-continue">
<span className="col-1 image-container">
<Image src={renderImage("/images/login/icon-google.png")} layout="fill" className="image" />
</span>
<span className="col-10 text-center">Continue with Google</span>
</div>
</div>
<div className="input-group mb-0">
<div className="btn-continue">
<span className="col-1 image-container">
<Image src={renderImage("/images/login/icon-fb1.png")} layout="fill" className="image" />
</span>
<span className="col-10 text-center">Continue with Facebook</span>
</div>
</div>
<div className="input-group mb-0">
<div className="btn-continue mb-0">
<span className="col-1 image-container">
<Image src={renderImage("/images/login/icon-apple.png")} layout="fill" className="image" />
</span>
<span className="col-10 text-center">Continue with Apple</span>
</div>
</div>
</>
)} */}
</div>
</div>
</div>
</div>
</div>
</Fragment>
</div>
);
};
export default AdminLogin;
...@@ -2,9 +2,12 @@ import React from "react"; ...@@ -2,9 +2,12 @@ import React from "react";
import Layout from "../../../components/layout/Layout"; import Layout from "../../../components/layout/Layout";
import Sidebar from "../../../components/layout/AdminDashboardSidebar"; import Sidebar from "../../../components/layout/AdminDashboardSidebar";
import VendorListing from "../../../components/admin/VendorListing"; import VendorListing from "../../../components/admin/VendorListing";
import { wrapper } from "../../../redux/store";
import { getAllVendors } from "../../../redux/actions/vendorActions";
import { loadUser } from "../../../redux/actions/userActions";
import { getAllCategories, getAllSubCategories } from "../../../redux/actions/categoriesAction";
export default function VendorListingPage() { export default function VendorListingPage() {
return ( return (
<Layout> <Layout>
<div className="sidebarContainer"> <div className="sidebarContainer">
...@@ -15,4 +18,30 @@ export default function VendorListingPage() { ...@@ -15,4 +18,30 @@ export default function VendorListingPage() {
</div> </div>
</Layout> </Layout>
); );
}; }
/** For server side rendering */
// export const getServerSideProps = wrapper.getServerSideProps(store => async ({ req, query }) => {
// // Get the menu data.
// // get the locations data.
// await store.dispatch(loadUser());
// await store.dispatch(getAllVendors());
// return {
// props: {}
// };
// });
/** For server side rendering */
export const getServerSideProps = wrapper.getServerSideProps(store => async ({ req, query }) => {
// await store.dispatch(loadUser());
// await store.dispatch(getAllVendors());
await store.dispatch(loadUser());
// await store.dispatch(getActivitiesByVendor());
await store.dispatch(getAllCategories());
await store.dispatch(getAllSubCategories());
return {
props: {}
};
});
...@@ -73,7 +73,13 @@ export default NextAuth({ ...@@ -73,7 +73,13 @@ export default NextAuth({
// } // }
// } // }
return { ...userResponse.data.user, name: userResponse.data.user.email, jwt: userResponse.data.jwt, email: userResponse.data.user.email, user: userResponse.data.user }; return {
...userResponse.data.user,
name: userResponse.data.user.email,
jwt: userResponse.data.jwt,
email: userResponse.data.user.email,
user: userResponse.data.user
};
} catch (error) { } catch (error) {
console.log("Error while fetching credentials:"); console.log("Error while fetching credentials:");
console.log(error.response.data); console.log(error.response.data);
......
import Home from "../components/home/Home"; import Home from "../components/home/Home";
import Layout from "../components/layout/Layout"; import Layout from "../components/layout/Layout";
import { getActivitiesByVendor } from "../redux/actions/activityAction"; import { getActivitiesByVendor, getActivitiesForEndUser } from "../redux/actions/activityAction";
import { getAllCategories } from "../redux/actions/categoriesAction"; import { getAllCategories } from "../redux/actions/categoriesAction";
import { getHomeBanner } from "../redux/actions/homeBannerAction"; import { getHomeBanner } from "../redux/actions/homeBannerAction";
import { getTestimonial } from "../redux/actions/testimonialAction"; import { getTestimonial } from "../redux/actions/testimonialAction";
...@@ -29,7 +29,7 @@ export const getServerSideProps = wrapper.getServerSideProps(store => async ({ r ...@@ -29,7 +29,7 @@ export const getServerSideProps = wrapper.getServerSideProps(store => async ({ r
try { try {
await store.dispatch(getAllCategories()) await store.dispatch(getAllCategories())
await store.dispatch(getTestimonial()) await store.dispatch(getTestimonial())
await store.dispatch(getActivitiesByVendor()) await store.dispatch(getActivitiesForEndUser())
await store.dispatch(getHomeBanner()) await store.dispatch(getHomeBanner())
return { return {
......
import React from "react"; import React, { useEffect } from "react";
import Layout from "../../../components/layout/Layout"; import Layout from "../../../components/layout/Layout";
import { wrapper } from "../../../redux/store"; import { wrapper } from "../../../redux/store";
import Sidebar from "../../../components/layout/VendorDashboardSidebar"; import Sidebar from "../../../components/layout/VendorDashboardSidebar";
...@@ -7,10 +7,16 @@ import ActivityListingRBAC from "../../../components/vendor/ActivityListingRBAC" ...@@ -7,10 +7,16 @@ import ActivityListingRBAC from "../../../components/vendor/ActivityListingRBAC"
import { getAllCategories, getAllSubCategories } from "../../../redux/actions/categoriesAction"; import { getAllCategories, getAllSubCategories } from "../../../redux/actions/categoriesAction";
import { getActivitiesByVendor } from "../../../redux/actions/activityAction"; import { getActivitiesByVendor } from "../../../redux/actions/activityAction";
import { loadUser } from "../../../redux/actions/userActions"; import { loadUser } from "../../../redux/actions/userActions";
import { useDispatch } from "react-redux";
// import { loadUser } from "../redux/actions/userActions"; // import { loadUser } from "../redux/actions/userActions";
// import { wrapper } from "../redux/store"; // import { wrapper } from "../redux/store";
export default function ActivityListingPage() { export default function ActivityListingPage() {
const dispatch = useDispatch();
useEffect(() => {
dispatch(getActivitiesByVendor());
}, []);
return ( return (
<Layout> <Layout>
<div className="sidebarContainer"> <div className="sidebarContainer">
...@@ -26,7 +32,7 @@ export default function ActivityListingPage() { ...@@ -26,7 +32,7 @@ export default function ActivityListingPage() {
/** For server side rendering */ /** For server side rendering */
export const getServerSideProps = wrapper.getServerSideProps(store => async ({ req, query }) => { export const getServerSideProps = wrapper.getServerSideProps(store => async ({ req, query }) => {
await store.dispatch(loadUser()); await store.dispatch(loadUser());
await store.dispatch(getActivitiesByVendor()); // await store.dispatch(getActivitiesByVendor());
await store.dispatch(getAllCategories()); await store.dispatch(getAllCategories());
await store.dispatch(getAllSubCategories()); await store.dispatch(getAllSubCategories());
// get the locations data. // get the locations data.
......
...@@ -8,18 +8,18 @@ import { wrapper } from "../../../redux/store"; ...@@ -8,18 +8,18 @@ import { wrapper } from "../../../redux/store";
// import { loadUser } from "../redux/actions/userActions"; // import { loadUser } from "../redux/actions/userActions";
// import { wrapper } from "../redux/store"; // import { wrapper } from "../redux/store";
export default function BusinessDetailsPage () { export default function BusinessDetailsPage() {
const dispatch = useDispatch() const dispatch = useDispatch();
useEffect(() => { useEffect(() => {
dispatch(getVendorDetails()) dispatch(getVendorDetails());
}, []) }, []);
return ( return (
<Layout> <Layout>
<BusinessDetails /> <BusinessDetails />
</Layout> </Layout>
); );
}; }
/** For server side rendering */ /** For server side rendering */
export const getServerSideProps = wrapper.getServerSideProps(store => async ({ req, query }) => { export const getServerSideProps = wrapper.getServerSideProps(store => async ({ req, query }) => {
...@@ -31,6 +31,4 @@ export const getServerSideProps = wrapper.getServerSideProps(store => async ({ r ...@@ -31,6 +31,4 @@ export const getServerSideProps = wrapper.getServerSideProps(store => async ({ r
return { return {
props: {} props: {}
}; };
});
\ No newline at end of file \ No newline at end of file
});
...@@ -62,32 +62,32 @@ export const getActivitiesByVendor = () => async dispatch => { ...@@ -62,32 +62,32 @@ export const getActivitiesByVendor = () => async dispatch => {
const session = await getSession(); const session = await getSession();
console.log("session", session); console.log("session", session);
try { try {
// const vendorConfig = { const vendorConfig = {
// headers: { headers: {
// "Content-Type": "application/json", "Content-Type": "application/json",
// Authorization: `Bearer ${session.jwt}` Authorization: `Bearer ${session.jwt}`
// } }
// }; };
// const vendorQuery = { const vendorQuery = {
// filters: { filters: {
// user: { user: {
// id: { $eq: session.id } id: { $eq: session.id }
// } }
// } }
// }; };
// const vendorQueryString = qs.stringify(vendorQuery, { const vendorQueryString = qs.stringify(vendorQuery, {
// encodeValuesOnly: true encodeValuesOnly: true
// }); });
// const vendorResponse = await axios.get(`${process.env.NEXT_PUBLIC_BACKEND_API_URL}/api/vendors/?${vendorQueryString}`, vendorConfig); const vendorResponse = await axios.get(`${process.env.NEXT_PUBLIC_BACKEND_API_URL}/api/vendors/?${vendorQueryString}`, vendorConfig);
// console.log("vendorResponse",vendorResponse.data) console.log("vendorResponse", vendorResponse.data.data[0].id);
// const loggedinVendor = await getLoggedInVendor() // const loggedinVendor = await getLoggedInVendor()
// console.log("loggedinVendor", loggedinVendor); // console.log("loggedinVendor", loggedinVendor);
// if (!session) { if (!session) {
// return "You are not authenticated, please log in."; return "You are not authenticated, please log in.";
// } }
dispatch({ dispatch({
type: GET_ACTIVITIES_REQUEST, type: GET_ACTIVITIES_REQUEST,
loading: true loading: true
...@@ -101,7 +101,13 @@ export const getActivitiesByVendor = () => async dispatch => { ...@@ -101,7 +101,13 @@ export const getActivitiesByVendor = () => async dispatch => {
}; };
const query = { const query = {
filters: {}, filters: {
vendor: {
id: {
$eq: vendorResponse.data.data[0].id
}
}
},
populate: ["masterMonths", "subCategory", "subCategory.category", "timeSlots", "masterPincode", "vendor", "image"] populate: ["masterMonths", "subCategory", "subCategory.category", "timeSlots", "masterPincode", "vendor", "image"]
}; };
...@@ -193,7 +199,7 @@ export const updateActivityById = ...@@ -193,7 +199,7 @@ export const updateActivityById =
}; };
// const query = {} // const query = {}
const updateResponse = await axios.put(`${process.env.NEXT_PUBLIC_BACKEND_API_URL}/api/experiences/${activityId}`, {data: updatedData}, config); const updateResponse = await axios.put(`${process.env.NEXT_PUBLIC_BACKEND_API_URL}/api/experiences/${activityId}`, { data: updatedData }, config);
dispatch({ dispatch({
type: UPDATE_ACTIVITY_BY_ID_SUCCESS, type: UPDATE_ACTIVITY_BY_ID_SUCCESS,
...@@ -208,3 +214,106 @@ export const updateActivityById = ...@@ -208,3 +214,106 @@ export const updateActivityById =
}); });
} }
}; };
export const getActivitiesForAdmin =
({ vendorId }) =>
async dispatch => {
try {
dispatch({
type: GET_ACTIVITIES_REQUEST,
loading: true
});
const config = {
headers: {
"Content-Type": "application/json"
// Authorization: `Bearer ${session.jwt}`
}
};
const query = {
filters: {
vendor: {
id: {
$eq: vendorId
}
}
},
populate: ["masterMonths", "subCategory", "subCategory.category", "timeSlots", "masterPincode", "vendor", "image"]
};
const queryString = qs.stringify(query, {
encodeValuesOnly: true
});
// let activityData = {
// data: {
// ...data
// }
// };
const response = await axios.get(`${process.env.NEXT_PUBLIC_BACKEND_API_URL}/api/experiences?${queryString}`, config);
// console.log("Response", response.data);
dispatch({
type: GET_ACTIVITIES_SUCCESS,
payload: response.data
});
return response.data;
} catch (error) {
dispatch({
type: GET_ACTIVITIES_FAIL,
payload: error.response.data
});
}
};
export const getActivitiesForEndUser =
() =>
async dispatch => {
try {
dispatch({
type: GET_ACTIVITIES_REQUEST,
loading: true
});
const config = {
headers: {
"Content-Type": "application/json"
// Authorization: `Bearer ${session.jwt}`
}
};
const query = {
// filters: {
// vendor: {
// id: {
// $eq: vendorId
// }
// }
// },
populate: ["masterMonths", "subCategory", "subCategory.category", "timeSlots", "masterPincode", "vendor", "image"]
};
const queryString = qs.stringify(query, {
encodeValuesOnly: true
});
// let activityData = {
// data: {
// ...data
// }
// };
const response = await axios.get(`${process.env.NEXT_PUBLIC_BACKEND_API_URL}/api/experiences?${queryString}`, config);
// console.log("Response", response.data);
dispatch({
type: GET_ACTIVITIES_SUCCESS,
payload: response.data
});
return response.data;
} catch (error) {
dispatch({
type: GET_ACTIVITIES_FAIL,
payload: error.response.data
});
}
};
...@@ -106,8 +106,8 @@ const registerVendor = async vendorData => { ...@@ -106,8 +106,8 @@ const registerVendor = async vendorData => {
// register a new user. // register a new user.
export const loadUser = () => async dispatch => { export const loadUser = () => async dispatch => {
const session = await getSession(); const session = await getSession();
if (session) { if (session) {
console.log("session", session);
try { try {
dispatch({ dispatch({
type: LOAD_USER_REQUEST type: LOAD_USER_REQUEST
...@@ -120,8 +120,8 @@ export const loadUser = () => async dispatch => { ...@@ -120,8 +120,8 @@ export const loadUser = () => async dispatch => {
}; };
// Load the user. // Load the user.
const response = await axios.get(`${process.env.NEXT_PUBLIC_BACKEND_API_URL}/api/users/me?populate[0]=profileImage`, config); const response = await axios.get(`${process.env.NEXT_PUBLIC_BACKEND_API_URL}/api/users/me?populate[0]=profileImage&populate[1]=role`, config);
console.log("response session", response);
dispatch({ dispatch({
type: LOAD_USER_SUCCESS, type: LOAD_USER_SUCCESS,
payload: { ...response.data } payload: { ...response.data }
...@@ -404,3 +404,57 @@ export const updateUserApprovalStatus = async ({ status }) => { ...@@ -404,3 +404,57 @@ export const updateUserApprovalStatus = async ({ status }) => {
return response; return response;
}; };
export const updateApprovalStatusAdmin = async ({ status, userId, rejectionReason }) => {
const session = await getSession();
if (!session) {
console.log("You are not authorized, please login");
}
const config = {
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${session.jwt}`
}
};
if (!status == "rejected") {
rejectionReason = "";
}
const response = await axios.put(
`${process.env.NEXT_PUBLIC_BACKEND_API_URL}/api/users/${userId}`,
{
approved: status,
rejectionReason
},
config
);
return response;
};
export const updateActivityStatusAdmin = async ({ status, activityId, rejectionReason }) => {
const session = await getSession();
if (!session) {
console.log("You are not authorized, please login");
}
const config = {
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${session.jwt}`
}
};
if (status) {
rejectionReason = "";
}
const response = await axios.put(
`${process.env.NEXT_PUBLIC_BACKEND_API_URL}/api/experiences/${activityId}`,
{
data: {
approved: status,
rejectionReason
}
},
config
);
return response;
};
...@@ -2,6 +2,9 @@ import axios from "axios"; ...@@ -2,6 +2,9 @@ import axios from "axios";
import { getSession } from "next-auth/react"; import { getSession } from "next-auth/react";
import qs from "qs"; import qs from "qs";
import { import {
GET_ALL_VENDORS_FAIL,
GET_ALL_VENDORS_REQUEST,
GET_ALL_VENDORS_SUCCESS,
GET_LOGGED_IN_VENDOR_FAIL, GET_LOGGED_IN_VENDOR_FAIL,
GET_LOGGED_IN_VENDOR_REQUEST, GET_LOGGED_IN_VENDOR_REQUEST,
GET_LOGGED_IN_VENDOR_SUCCESS, GET_LOGGED_IN_VENDOR_SUCCESS,
...@@ -179,3 +182,53 @@ export const getVendorDetails = () => async dispatch => { ...@@ -179,3 +182,53 @@ export const getVendorDetails = () => async dispatch => {
}); });
} }
}; };
export const getAllVendors = () => async dispatch => {
const session = await getSession();
try {
dispatch({
type: GET_ALL_VENDORS_REQUEST
});
// console.log("here 1", session);
const config = {
headers: {
"Content-Type": "Application/json",
Authorization: `Bearer ${session.jwt}`
}
};
// console.log("here 2");
if (!session) {
return;
}
const query = {
// filters: {
// user: {
// id: {
// $eq: session.id
// }
// }
// },
populate: ["user", "experiences"]
};
// console.log("here 3", query);
const queryString = qs.stringify(query, {
encodeValuesOnly: true
});
console.log("session", session, session.id);
const response = await axios.get(`${process.env.NEXT_PUBLIC_BACKEND_API_URL}/api/vendors/?${queryString}`, config);
console.log("response", response);
dispatch({
type: GET_ALL_VENDORS_SUCCESS,
payload: response.data.data
});
return response.data.data[0];
} catch (error) {
dispatch({
type: GET_ALL_VENDORS_FAIL,
payload: error.response.data
});
}
};
...@@ -10,4 +10,8 @@ export const GET_VENDOR_DETAILS_REQUEST = "GET_VENDOR_DETAILS_REQUEST" ...@@ -10,4 +10,8 @@ export const GET_VENDOR_DETAILS_REQUEST = "GET_VENDOR_DETAILS_REQUEST"
export const GET_VENDOR_DETAILS_SUCCESS = "GET_VENDOR_DETAILS_SUCCESS" export const GET_VENDOR_DETAILS_SUCCESS = "GET_VENDOR_DETAILS_SUCCESS"
export const GET_VENDOR_DETAILS_FAIL = "GET_VENDOR_DETAILS_FAIL" export const GET_VENDOR_DETAILS_FAIL = "GET_VENDOR_DETAILS_FAIL"
export const GET_ALL_VENDORS_REQUEST = "GET_ALL_VENDORS_REQUEST"
export const GET_ALL_VENDORS_SUCCESS = "GET_ALL_VENDORS_SUCCESS"
export const GET_ALL_VENDORS_FAIL = "GET_ALL_VENDORS_FAIL"
export const CLEAR_ERRORS = "CLEAR_ERRORS"; export const CLEAR_ERRORS = "CLEAR_ERRORS";
\ No newline at end of file \ No newline at end of file
...@@ -4,7 +4,7 @@ import { townshipReducer, townshipsReducer } from "./townshipsReducer"; ...@@ -4,7 +4,7 @@ import { townshipReducer, townshipsReducer } from "./townshipsReducer";
import { authReducer, forgotPasswordReducer, loadedUserReducer, resetPasswordReducer, userReducer } from "./userReducers"; import { authReducer, forgotPasswordReducer, loadedUserReducer, resetPasswordReducer, userReducer } from "./userReducers";
import { enquiryReducer } from "./enquiryReducer"; import { enquiryReducer } from "./enquiryReducer";
import { displayEnquireNowReducer } from "./enquireNowModalReducer"; import { displayEnquireNowReducer } from "./enquireNowModalReducer";
import { getVendorDetailsReducer, loggedInVendorReducer, updateVendorReducer } from "./vendorReducers"; import { getAllVendorsReducer, getVendorDetailsReducer, loggedInVendorReducer, updateVendorReducer } from "./vendorReducers";
import { createActivityReducer, getActivitiesReducer, getActivityByIdReducer, updateActivityByIdReducer } from "./activitiesReducer"; import { createActivityReducer, getActivitiesReducer, getActivityByIdReducer, updateActivityByIdReducer } from "./activitiesReducer";
import { getAllCategoriesReducer, getAllSubCategoriesReducer } from "./categoryReducer"; import { getAllCategoriesReducer, getAllSubCategoriesReducer } from "./categoryReducer";
import { getAllTestimonialReducer } from "./testimonialReducer"; import { getAllTestimonialReducer } from "./testimonialReducer";
...@@ -37,6 +37,7 @@ const reducers = combineReducers({ ...@@ -37,6 +37,7 @@ const reducers = combineReducers({
blogs: blogsReducer, blogs: blogsReducer,
blog: blogReducer, blog: blogReducer,
homeBanner: getAllHomeBannerReducer, homeBanner: getAllHomeBannerReducer,
allVendors: getAllVendorsReducer,
}); });
export default reducers; export default reducers;
...@@ -52,7 +52,7 @@ export const authReducer = (state = { loading: false, success: false, user: null ...@@ -52,7 +52,7 @@ export const authReducer = (state = { loading: false, success: false, user: null
}; };
// Load user reducer // Load user reducer
export const loadedUserReducer = (state = { loading: true, success: false, user: null }, action) => { export const loadedUserReducer = (state = { loading: true, success: false, loadedUser: null }, action) => {
switch (action.type) { switch (action.type) {
case LOAD_USER_REQUEST: case LOAD_USER_REQUEST:
return { return {
...@@ -64,7 +64,7 @@ export const loadedUserReducer = (state = { loading: true, success: false, user: ...@@ -64,7 +64,7 @@ export const loadedUserReducer = (state = { loading: true, success: false, user:
return { return {
loading: false, loading: false,
isAuthenticated: true, isAuthenticated: true,
user: action.payload loadedUser: action.payload
}; };
case LOAD_USER_FAIL: case LOAD_USER_FAIL:
......
import { UPDATE_VENDOR_DETAILS_FAIL, UPDATE_VENDOR_DETAILS_REQUEST, UPDATE_VENDOR_DETAILS_SUCCESS, CLEAR_ERRORS, GET_LOGGED_IN_VENDOR_REQUEST, GET_LOGGED_IN_VENDOR_SUCCESS, GET_LOGGED_IN_VENDOR_FAIL, GET_VENDOR_DETAILS_FAIL, GET_VENDOR_DETAILS_SUCCESS, GET_VENDOR_DETAILS_REQUEST } from "../constants/vendorConstants"; import { UPDATE_VENDOR_DETAILS_FAIL, UPDATE_VENDOR_DETAILS_REQUEST, UPDATE_VENDOR_DETAILS_SUCCESS, CLEAR_ERRORS, GET_LOGGED_IN_VENDOR_REQUEST, GET_LOGGED_IN_VENDOR_SUCCESS, GET_LOGGED_IN_VENDOR_FAIL, GET_VENDOR_DETAILS_FAIL, GET_VENDOR_DETAILS_SUCCESS, GET_VENDOR_DETAILS_REQUEST, GET_ALL_VENDORS_REQUEST, GET_ALL_VENDORS_SUCCESS, GET_ALL_VENDORS_FAIL } from "../constants/vendorConstants";
// Load user reducer // Load user reducer
...@@ -95,3 +95,33 @@ export const getVendorDetailsReducer = (state = { loading: true, success: false, ...@@ -95,3 +95,33 @@ export const getVendorDetailsReducer = (state = { loading: true, success: false,
return state; return state;
} }
}; };
export const getAllVendorsReducer = (state = { loading: true, success: false, allVendors: null }, action) => {
switch (action.type) {
case GET_ALL_VENDORS_REQUEST:
return {
loading: true,
};
case GET_ALL_VENDORS_SUCCESS:
return {
loading: false,
allVendors: action.payload
};
case GET_ALL_VENDORS_FAIL:
return {
loading: false,
error: action.payload.error.message
};
case CLEAR_ERRORS:
return {
...state,
error: null
};
default:
return state;
}
};
\ No newline at end of file \ No newline at end of file
...@@ -1775,8 +1775,8 @@ span.form-error, ...@@ -1775,8 +1775,8 @@ span.form-error,
} }
.btnAdd.btnReject { .btnAdd.btnReject {
background-color: #ececec !important; background-color: #e02424 !important;
color: #161616 !important; color: #ffff !important;
} }
.btnAdd.btnReject:focus, .btnAdd.btnReject:focus,
...@@ -2823,6 +2823,18 @@ input[type="number"]::-webkit-outer-spin-button { ...@@ -2823,6 +2823,18 @@ input[type="number"]::-webkit-outer-spin-button {
color: #d1d1d1; color: #d1d1d1;
} }
.overlay {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.8); /* Semi-transparent black background */
z-index: 999; /* Ensure the overlay appears above other content */
}
@media (min-width: 992px) { @media (min-width: 992px) {
.navbar-expand-lg .navbar-nav .nav-link { .navbar-expand-lg .navbar-nav .nav-link {
margin: 0 2rem; margin: 0 2rem;
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!