Commit eac818da by jaymehta

admin

1 parent 1f8452e1
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);
return ( const handleCloseActivityDetails = () => {
<Layout> setShowActivityDetailsModal(false);
<div className="sidebarContainer"> };
<Sidebar />
<div className="content"> const dispatch = useDispatch();
<ActivityListing /> useEffect(() => {
</div> dispatch(getActivitiesForAdmin({}));
</div> }, []);
</Layout> return (
); <Layout>
}; <div className="sidebarContainer">
<Sidebar />
<div className="content">
{/* <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,17 +2,46 @@ import React from "react"; ...@@ -2,17 +2,46 @@ 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 (
<Layout>
<div className="sidebarContainer">
<Sidebar />
<div className="content">
<VendorListing />
</div>
</div>
</Layout>
);
}
return ( /** For server side rendering */
<Layout> // export const getServerSideProps = wrapper.getServerSideProps(store => async ({ req, query }) => {
<div className="sidebarContainer"> // // Get the menu data.
<Sidebar />
<div className="content"> // // get the locations data.
<VendorListing /> // await store.dispatch(loadUser());
</div> // await store.dispatch(getAllVendors());
</div>
</Layout> // 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,29 +8,27 @@ import { wrapper } from "../../../redux/store"; ...@@ -8,29 +8,27 @@ 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 }) => {
// Get the menu data.
// get the locations data.
await store.dispatch(loadUser());
return {
props: {}
};
});
\ No newline at end of file \ No newline at end of file
// Get the menu data.
// get the locations data.
await store.dispatch(loadUser());
return {
props: {}
};
});
...@@ -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
...@@ -94,4 +94,34 @@ export const getVendorDetailsReducer = (state = { loading: true, success: false, ...@@ -94,4 +94,34 @@ export const getVendorDetailsReducer = (state = { loading: true, success: false,
default: default:
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!