Commit eac818da by jaymehta

admin

1 parent 1f8452e1
import { Fragment, useState } from "react";
import { Button, Image, Table } from "react-bootstrap";
import { SearchOutlined } from "@ant-design/icons";
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 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 [data, setdata] = useState(null);
const toggleMenu = (index) => {
const toggleMenu = index => {
setShowMenuIndex(index === showMenuIndex ? null : index);
};
return (
<Fragment>
<div className="row">
<div className="col-12 col-lg-12">
<div className="rightContent">
<div className="d-flex align-items-center justify-content-between px-2 mb-2">
<div>
<h2>Activities</h2>
<p>View all the Activities</p>
</div>
<div>
<Button type="button" variant="" className="btnAdd m-0">
<Image alt="" width="16" height="16" src="/images/vendor/icon-filter.svg" className="me-2" /> Filter
useEffect(() => {
let allActivities = allActivitiesData && allActivitiesData.data.map(item => {
return {
key: item.id,
name: item.attributes.name,
category: "yet to map",
pincode: item.attributes.masterPincode.data.attributes.name,
price: item.attributes.pricePerPerson,
activityType: item.attributes.activityType,
gift: item.attributes.giftSomeone ? "Allowed" : "Not allowed",
vendorWebsite: item.attributes.link
}
})
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
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>
<Table responsive className="listingTable">
<thead>
<tr>
<th>
<label className="check-container mb-0 ps-2" htmlFor="checkh">
<input
type="checkbox"
id="checkh"
className="check-box"
),
filterIcon: filtered => (
<SearchOutlined
style={{
color: filtered ? "#1677ff" : undefined
}}
/>
<span className="checkmark"></span>
</label>
</th>
<th>Category</th>
<th>Name</th>
<th>Location</th>
<th>Price</th>
<th>Place</th>
<th>Gift</th>
<th>Vendor Website</th>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
{array.map((data, index) => (
<tr key={index}>
<td>
<label className="check-container mb-0 ps-2" htmlFor={`check${index}`}>
<input
type="checkbox"
id={`check${index}`}
className="check-box"
),
onFilter: (value, record) => record[dataIndex].toString().toLowerCase().includes(value.toLowerCase()),
onFilterDropdownOpenChange: visible => {
if (visible) {
setTimeout(() => searchInput.current?.select(), 100);
}
},
render: text =>
searchedColumn === dataIndex ? (
<Highlighter
highlightStyle={{
backgroundColor: "#ffc069",
padding: 0
}}
searchWords={[searchText]}
autoEscape
textToHighlight={text ? text.toString() : ""}
/>
<span className="checkmark"></span>
</label>
</td>
<td><span>Adventure</span></td>
<td>Ice-Skating in NY</td>
<td>North Avenue</td>
<td>$ 479</td>
<td>Outdoor</td>
<td>Allowed</td>
<td><span style={{ color: "#0070BD", marginRight: ".5rem" }}>View Link</span> <Image alt="" width={17} height={17} src="/images/admin/icon-link.svg" /></td>
<td><Image alt="" width={20} height={20} src="/images/vendor/icon-view.svg" /></td>
<td>
<div className="actions">
<div className="ellipse" onClick={() => toggleMenu(index)}>
<Image alt="" width={20} height={20} src="/images/vendor/icon-more-vertical.svg" />
</div>
{showMenuIndex === index && (
<div className="menu">
<ul>
<li>Delete</li>
</ul>
</div>
)}
</div>
</td>
</tr>
))}
<tr>
<td colSpan={10}>Showing Results 10 of 1567</td>
</tr>
</tbody>
</Table>
</div>
</div>
) : (
text
)
});
const columns = [
{
title: "Name",
dataIndex: "name",
key: "name",
width: "30%",
...getColumnSearchProps("name")
},
{
title: "Category",
dataIndex: "category",
key: "category",
width: "20%",
...getColumnSearchProps("category")
},
{
title: "Address",
dataIndex: "address",
key: "address",
...getColumnSearchProps("address"),
sorter: (a, b) => a.address.length - b.address.length,
sortDirections: ["descend", "ascend"]
}
];
return (
<Fragment>
<div className="row">
<Table columns={columns} dataSource={data} />
</div>
</Fragment>
);
......
import { Formik } from "formik";
import { Fragment, useState } from "react";
import { Button, Form, Modal } from "react-bootstrap";
import { useDispatch } from "react-redux";
import ReactSelect from "react-select";
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({
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"),
comments: Yup.string().required("Comment is Required"),
comments: Yup.string()
});
const reasonOptions = [
{ value: "Not listed", label: "Not listed" }
]
const reasonOptions = [{ value: "Not listed", label: "Not listed" }];
const [selectedOption, setSelectedOption] = useState(null);
const [showComments, setshowComments] = useState(false);
return (
<Fragment>
<Modal show={show} onHide={handleClose} aria-labelledby="contained-modal-title-vcenter"
centered>
<Modal show={show} onHide={handleClose} aria-labelledby="contained-modal-title-vcenter" centered>
<Modal.Body>
<div className="row">
<div className="col-12 col-lg-12">
......@@ -28,12 +31,32 @@ const RejectModal = ({ show, handleClose }) => {
<div className="form-container">
<Formik
initialValues={{
email: "",
email: detail[0].attributes.email,
reason: "",
comments: "",
comments: ""
}}
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 }) => (
......@@ -43,40 +66,55 @@ const RejectModal = ({ show, handleClose }) => {
handleSubmit();
}}
>
{/* {console.log("formik.values",values)} */}
<div className="input-group">
<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>}
</div>
<div className="input-group mb-1">
<label>Reason</label>
<select
name="reason"
onChange={handleChange}
onChange={e => {
console.log(e);
handleChange(e);
if (e.target.value == "notListed") {
setshowComments(true);
} else {
setshowComments(false);
}
}}
onBlur={handleBlur}
value={values.reason}
>
<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>
{/* <ReactSelect
defaultValue={selectedOption}
onChange={setSelectedOption}
options={reasonOptions}
/> */}
{errors.reason && touched.reason && <span className="form-error">{errors.reason}</span>}
</div>
{showComments && (
<div className="input-group">
<textarea rows={4} placeholder="Leave your comments here..." name="comments"
onChange={handleChange}
onBlur={handleBlur}
value={values.comments} />
<textarea rows={4} placeholder="Leave your comments here..." name="comments" onChange={handleChange} onBlur={handleBlur} value={values.comments} />
{errors.comments && touched.comments && <span className="form-error">{errors.comments}</span>}
</div>
)}
<div className="my-4">
<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
</Button>
<div className="px-1"></div>
......@@ -95,6 +133,6 @@ const RejectModal = ({ show, handleClose }) => {
</Modal.Body>
</Modal>
</Fragment>
)
}
);
};
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
......@@ -9,9 +9,9 @@ import { loadUser } from "../../redux/actions/userActions";
import { useRouter } from "next/router";
const Header = () => {
const { user, error } = useSelector(state => state.loadedUser);
const { loadedUser } = useSelector(state => state.loadedUser);
const dispatch = useDispatch();
// console.log("user", user);
// console.log("user", loadedUser);
const [isSticky, setIsSticky] = useState(false);
const router = useRouter();
useEffect(() => {
......@@ -60,12 +60,12 @@ const Header = () => {
</div>
</Form>
{/* {console.log(user.id)} */}
{user && user.id ? (
{loadedUser && loadedUser.id ? (
<div>
<div>
<p>Brand Logo</p>
</div>
<p>{user.phone}</p>
<p>{loadedUser.phone}</p>
<Button
onClick={async () => {
signOut({ redirect: false });
......
......@@ -9,6 +9,8 @@ import { useDispatch, useSelector } from "react-redux";
const Layout = ({ children, title = "Zango", description = "Zango" }) => {
const dispatch = useDispatch();
// const { loadedUser } = useSelector(state => state.loadedUser);
// console.log(">>>", loadedUser);
useEffect(() => {
dispatch(loadUser());
}, []);
......
......@@ -24,7 +24,7 @@ const Login = props => {
<div className="row">
<div className="col-11 col-lg-4 login-div">
<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">
<Formik
initialValues={{
......
......@@ -17,21 +17,21 @@ const BusinessDetails = () => {
const router = useRouter()
const { loggedInVendor } = useSelector(state => state.loggedInVendor);
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 ref = useRef(null);
// console.log("vendorDetails", vendorDetails);
console.log("vendorDetails", vendorDetails);
const [disableFields, setdisableFields] = useState();
useEffect(() => {
console.log("user", user);
if (user) {
if (user.approved == "approved" || user.approved == "rejected") {
console.log("user", loadedUser);
if (loadedUser) {
if (loadedUser.approved == "approved" || loadedUser.approved == "rejected") {
setdisableFields(false);
} else if (user.approved == "pending") {
} else if (loadedUser.approved == "pending") {
setdisableFields(true);
}
}
}, [user]);
}, [loadedUser]);
// console.log("userStatus", userStatus);
useEffect(() => {
const fetchSession = async () => {
......@@ -82,8 +82,8 @@ const BusinessDetails = () => {
}
const ApprovalStatus = () => {
if (user) {
switch (user.approved) {
if (loadedUser) {
switch (loadedUser.approved) {
case "approved":
return <></>;
......@@ -116,7 +116,7 @@ const BusinessDetails = () => {
// vendorDetails && console.log("vendorData", vendorData, vendorDetails.length > 0);
return (
<Fragment>
{user && (
{loadedUser && (
<div className="container p-5">
<div className="row">
<div className="col-12 col-lg-8">
......
import React from "react";
import React, { useEffect, useState } from "react";
import Layout from "../../../components/layout/Layout";
import Sidebar from "../../../components/layout/AdminDashboardSidebar";
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() {
const [activityDetailInfo, setactivityDetailInfo] = useState();
const [showActivityDetailsModal, setShowActivityDetailsModal] = useState(false);
const handleCloseActivityDetails = () => {
setShowActivityDetailsModal(false);
};
const dispatch = useDispatch();
useEffect(() => {
dispatch(getActivitiesForAdmin({}));
}, []);
return (
<Layout>
<div className="sidebarContainer">
<Sidebar />
<div className="content">
<ActivityListing />
{/* <ActivityListing /> */}
<ActivityListingRBAC setactivityDetailInfo={setactivityDetailInfo} setShowActivityDetailsModal={setShowActivityDetailsModal} />
{showActivityDetailsModal && (
<ActivityDetailsModal show={showActivityDetailsModal} handleClose={handleCloseActivityDetails} activityDetailInfo={activityDetailInfo} />
)}
</div>
</div>
</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";
import Layout from "../../../components/layout/Layout";
import Sidebar from "../../../components/layout/AdminDashboardSidebar";
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() {
return (
<Layout>
<div className="sidebarContainer">
......@@ -15,4 +18,30 @@ export default function VendorListingPage() {
</div>
</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({
// }
// }
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) {
console.log("Error while fetching credentials:");
console.log(error.response.data);
......
import Home from "../components/home/Home";
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 { getHomeBanner } from "../redux/actions/homeBannerAction";
import { getTestimonial } from "../redux/actions/testimonialAction";
......@@ -29,7 +29,7 @@ export const getServerSideProps = wrapper.getServerSideProps(store => async ({ r
try {
await store.dispatch(getAllCategories())
await store.dispatch(getTestimonial())
await store.dispatch(getActivitiesByVendor())
await store.dispatch(getActivitiesForEndUser())
await store.dispatch(getHomeBanner())
return {
......
import React from "react";
import React, { useEffect } from "react";
import Layout from "../../../components/layout/Layout";
import { wrapper } from "../../../redux/store";
import Sidebar from "../../../components/layout/VendorDashboardSidebar";
......@@ -7,10 +7,16 @@ import ActivityListingRBAC from "../../../components/vendor/ActivityListingRBAC"
import { getAllCategories, getAllSubCategories } from "../../../redux/actions/categoriesAction";
import { getActivitiesByVendor } from "../../../redux/actions/activityAction";
import { loadUser } from "../../../redux/actions/userActions";
import { useDispatch } from "react-redux";
// import { loadUser } from "../redux/actions/userActions";
// import { wrapper } from "../redux/store";
export default function ActivityListingPage() {
const dispatch = useDispatch();
useEffect(() => {
dispatch(getActivitiesByVendor());
}, []);
return (
<Layout>
<div className="sidebarContainer">
......@@ -26,7 +32,7 @@ export default function ActivityListingPage() {
/** For server side rendering */
export const getServerSideProps = wrapper.getServerSideProps(store => async ({ req, query }) => {
await store.dispatch(loadUser());
await store.dispatch(getActivitiesByVendor());
// await store.dispatch(getActivitiesByVendor());
await store.dispatch(getAllCategories());
await store.dispatch(getAllSubCategories());
// get the locations data.
......
......@@ -8,18 +8,18 @@ import { wrapper } from "../../../redux/store";
// import { loadUser } from "../redux/actions/userActions";
// import { wrapper } from "../redux/store";
export default function BusinessDetailsPage () {
const dispatch = useDispatch()
export default function BusinessDetailsPage() {
const dispatch = useDispatch();
useEffect(() => {
dispatch(getVendorDetails())
}, [])
dispatch(getVendorDetails());
}, []);
return (
<Layout>
<BusinessDetails />
</Layout>
);
};
}
/** For server side rendering */
export const getServerSideProps = wrapper.getServerSideProps(store => async ({ req, query }) => {
......@@ -31,6 +31,4 @@ export const getServerSideProps = wrapper.getServerSideProps(store => async ({ r
return {
props: {}
};
});
\ No newline at end of file
});
......@@ -62,32 +62,32 @@ export const getActivitiesByVendor = () => async dispatch => {
const session = await getSession();
console.log("session", session);
try {
// const vendorConfig = {
// headers: {
// "Content-Type": "application/json",
// Authorization: `Bearer ${session.jwt}`
// }
// };
// const vendorQuery = {
// filters: {
// user: {
// id: { $eq: session.id }
// }
// }
// };
const vendorConfig = {
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${session.jwt}`
}
};
const vendorQuery = {
filters: {
user: {
id: { $eq: session.id }
}
}
};
// const vendorQueryString = qs.stringify(vendorQuery, {
// encodeValuesOnly: true
// });
const vendorQueryString = qs.stringify(vendorQuery, {
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()
// console.log("loggedinVendor", loggedinVendor);
// if (!session) {
// return "You are not authenticated, please log in.";
// }
if (!session) {
return "You are not authenticated, please log in.";
}
dispatch({
type: GET_ACTIVITIES_REQUEST,
loading: true
......@@ -101,7 +101,13 @@ export const getActivitiesByVendor = () => async dispatch => {
};
const query = {
filters: {},
filters: {
vendor: {
id: {
$eq: vendorResponse.data.data[0].id
}
}
},
populate: ["masterMonths", "subCategory", "subCategory.category", "timeSlots", "masterPincode", "vendor", "image"]
};
......@@ -193,7 +199,7 @@ export const updateActivityById =
};
// 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({
type: UPDATE_ACTIVITY_BY_ID_SUCCESS,
......@@ -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 => {
// register a new user.
export const loadUser = () => async dispatch => {
const session = await getSession();
if (session) {
console.log("session", session);
try {
dispatch({
type: LOAD_USER_REQUEST
......@@ -120,8 +120,8 @@ export const loadUser = () => async dispatch => {
};
// 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({
type: LOAD_USER_SUCCESS,
payload: { ...response.data }
......@@ -404,3 +404,57 @@ export const updateUserApprovalStatus = async ({ status }) => {
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";
import { getSession } from "next-auth/react";
import qs from "qs";
import {
GET_ALL_VENDORS_FAIL,
GET_ALL_VENDORS_REQUEST,
GET_ALL_VENDORS_SUCCESS,
GET_LOGGED_IN_VENDOR_FAIL,
GET_LOGGED_IN_VENDOR_REQUEST,
GET_LOGGED_IN_VENDOR_SUCCESS,
......@@ -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"
export const GET_VENDOR_DETAILS_SUCCESS = "GET_VENDOR_DETAILS_SUCCESS"
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";
\ No newline at end of file
......@@ -4,7 +4,7 @@ import { townshipReducer, townshipsReducer } from "./townshipsReducer";
import { authReducer, forgotPasswordReducer, loadedUserReducer, resetPasswordReducer, userReducer } from "./userReducers";
import { enquiryReducer } from "./enquiryReducer";
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 { getAllCategoriesReducer, getAllSubCategoriesReducer } from "./categoryReducer";
import { getAllTestimonialReducer } from "./testimonialReducer";
......@@ -37,6 +37,7 @@ const reducers = combineReducers({
blogs: blogsReducer,
blog: blogReducer,
homeBanner: getAllHomeBannerReducer,
allVendors: getAllVendorsReducer,
});
export default reducers;
......@@ -52,7 +52,7 @@ export const authReducer = (state = { loading: false, success: false, user: null
};
// 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) {
case LOAD_USER_REQUEST:
return {
......@@ -64,7 +64,7 @@ export const loadedUserReducer = (state = { loading: true, success: false, user:
return {
loading: false,
isAuthenticated: true,
user: action.payload
loadedUser: action.payload
};
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
......@@ -95,3 +95,33 @@ export const getVendorDetailsReducer = (state = { loading: true, success: false,
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
......@@ -1775,8 +1775,8 @@ span.form-error,
}
.btnAdd.btnReject {
background-color: #ececec !important;
color: #161616 !important;
background-color: #e02424 !important;
color: #ffff !important;
}
.btnAdd.btnReject:focus,
......@@ -2823,6 +2823,18 @@ input[type="number"]::-webkit-outer-spin-button {
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) {
.navbar-expand-lg .navbar-nav .nav-link {
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!