Commit 7db3c4ce by jaymehta

.

1 parent 90695a54
import React from 'react'
import { EyeTwoTone } from "@ant-design/icons";
import { Space, Table, Tag } from "antd";
import React, { useEffect, useState } from "react";
import { Modal } from "react-bootstrap";
import { useDispatch, useSelector } from "react-redux";
import { getEnquiriesByAdmin } from "../../redux/actions/enquiryAction";
import EnquiryDetailModal from "./EnquiryDetailModal";
const Enquiries = () => {
return (
<div>Enquiries</div>
const { enquiriesByAdmin } = useSelector(state => state.enquiriesByAdmin);
const dispatch = useDispatch();
const [data, setdata] = useState();
const [columns, setcolumns] = useState();
const [details, setdetails] = useState();
const [detailsModal, setdetailsModal] = useState(false);
useEffect(() => {
dispatch(getEnquiriesByAdmin());
}, []);
useEffect(() => {
setcolumns([
{
title: "Name",
dataIndex: "name",
key: "name"
},
{
title: "Date",
dataIndex: "date",
key: "date"
},
{
title: "Quantity",
dataIndex: "quantity",
key: "quantity"
},
{
title: "Status",
dataIndex: "status",
key: "status",
render: tag => (
<span>
{tag == "pending" ? (
<Tag color={"red"} key={tag}>
{tag.toUpperCase()}
</Tag>
) : (
<Tag color={"blue"} key={tag}>
{tag === "closed" ? "closed" : tag.toUpperCase()}
</Tag>
)}
</span>
)
}
},
{
title: "Activity Name",
dataIndex: "experienceName",
key: "experienceName"
},
{
title: "Vendor name",
dataIndex: "vendorName",
key: "vendorName"
},
{
title: "See details",
render: (_, record) => (
<Space size="middle">
{/* <a>Invite {record.name}</a> */}
<EyeTwoTone
style={{ fontSize: "22px" }}
onClick={() => {
setdetailsModal(true);
// setactivityId(record.key);
setdetails({ experience: record.experience, vendor: record.vendor, endUser: record.endUser });
// router.push(`/vendor/activities/${record.key}`);
// console.log(record);
}}
/>
</Space>
),
width: "10%"
}
]);
if (enquiriesByAdmin && enquiriesByAdmin.data.length > 0) {
setdata(
enquiriesByAdmin.data.map(item => {
return {
key: item.id,
date: item.attributes.date,
quantity: item.attributes.quantity,
status: item.attributes.status,
endUser: item.attributes.end_user,
experience: item.attributes.experience,
name: item.attributes.end_user.data.attributes.name,
experienceName: item.attributes.experience.data?.attributes.name,
vendorName: item.attributes.vendor.data.attributes.name,
vendor: item.attributes.vendor
};
})
);
}
// const dataSource = [
// {
// key: "1",
// name: "Mike",
// age: 32,
// address: "10 Downing Street"
// },
// {
// key: "2",
// name: "John",
// age: 42,
// address: "10 Downing Street"
// }
// ];
// const columns = [
// {
// title: "Name",
// dataIndex: "name",
// key: "name"
// },
// {
// title: "Age",
// dataIndex: "age",
// key: "age"
// },
// {
// title: "Address",
// dataIndex: "address",
// key: "address"
// }
// ];
}, [enquiriesByAdmin]);
console.log("enquiriesByAdmin", enquiriesByAdmin);
console.log("data", details)
return (
<div>
<Table dataSource={data} columns={columns} />
<Modal show={detailsModal} onHide={() => setdetailsModal(false)}>
<Modal.Header>Enquiry details</Modal.Header>
<Modal.Body>
<EnquiryDetailModal data={details} setdetailsModal={setdetailsModal} />
</Modal.Body>
</Modal>
</div>
);
};
export default Enquiries
\ No newline at end of file
export default Enquiries;
import React, { Fragment } from "react";
import { FaAngleLeft } from "react-icons/fa";
const EnquiryDetailModal = ({ data, setdetailsModal }) => {
return (
<div>
<Fragment>
<div className="vendorDetails">
<div className="row">
<div className="col-12 col-lg-12">
<div className="d-flex align-items-center justify-content-between">
<div className="backDiv">
<span className="backArrow">
<FaAngleLeft
onClick={() => {
setdetailsModal(false);
}}
/>
</span>
<span>Vendors List</span>
</div>
</div>
</div>
<div className="col-8 col-lg-8 mt-4">
{/* <h4>End user</h4> */}
<div className="row">
<div className="col-12 col-lg-5">
<p className="phead">User details</p>
{/* <div className="row">
<p className="col-12 col-lg-6">Business PAN No.</p>
<p className="col-12 col-lg-6">{detail[0].attributes.pan}</p>
</div> */}
{/* <div className="row">
<p className="col-12 col-lg-6">PAN</p>
<p className="col-12 col-lg-6 pview">View</p>
</div> */}
<div className="row">
<p className="col-12 col-lg-6">Name</p>
<p className="col-12 col-lg-6">{data.endUser.data.attributes.name}</p>
</div>
{/* <div className="row">
<p className="col-12 col-lg-6">GST Certificate</p>
<p className="col-12 col-lg-6 pview">View</p>
</div> */}
<div className="row">
<p className="col-12 col-lg-6">Email</p>
<p className="col-12 col-lg-6">{data.endUser.data.attributes.email}</p>
</div>
<div className="row">
<p className="col-12 col-lg-6">Phone</p>
<p className="col-12 col-lg-6">{data.endUser.data.attributes.phone}</p>
</div>
{/* <div className="row">
<p className="col-12 col-lg-6">Vendor website:</p>
<p className="col-12 col-lg-6">{detail[0].attributes.businessName}</p>
</div> */}
</div>
<div className="col-12 col-lg-7 borderLeft">
<p className="phead">Activity</p>
<div className="row">
<p className="col-12 col-lg-4">Activity Name</p>
<p className="col-12 col-lg-8">{data.experience.data.attributes.name}</p>
</div>
<div className="row">
<p className="col-12 col-lg-4">Link</p>
<p className="col-12 col-lg-8">
<a href={data.experience.data.attributes.link} target="_blank">
{data.experience.data.attributes.link}
</a>
</p>
</div>
<div className="row">
<p className="col-12 col-lg-4">Activity Name</p>
<p className="col-12 col-lg-8">{data.experience.data.attributes.name}</p>
</div>
<div className="row">
<p className="col-12 col-lg-4">Country</p>
<p className="col-12 col-lg-8">United States</p>
</div>
</div>
<div className="col-12 col-lg-7 borderLeft">
<p className="phead">Vendor Details</p>
<div className="row">
<p className="col-12 col-lg-4">Vendor Name</p>
<p className="col-12 col-lg-8">{data.vendor.data.attributes.name}</p>
</div>
{/* <div className="row">
<p className="col-12 col-lg-4">Link</p>
<p className="col-12 col-lg-8">
<a href={data.experience.data.attributes.link} target="_blank">
{data.experience.data.attributes.link}
</a>
</p>
</div> */}
<div className="row">
<p className="col-12 col-lg-4">Vendor email</p>
<p className="col-12 col-lg-8">{data.vendor.data.attributes.email}</p>
</div>
<div className="row">
<p className="col-12 col-lg-4">Vendor Phone</p>
<p className="col-12 col-lg-8">{data.vendor.data.attributes.phone}</p>
</div>
</div>
</div>
</div>
</div>
</div>
{/* {showActivityDetailsModal && <ActivityDetailsModal show={showActivityDetailsModal} handleClose={handleCloseActivityDetails} activityDetailInfo={activityDetailInfo} />}
{showRejectModal && <RejectModal show={showRejectModal} handleClose={handleCloseRejectModal} detail={detail} setShowDetail={setShowDetail} />} */}
</Fragment>
</div>
);
};
export default EnquiryDetailModal;
......@@ -6,8 +6,8 @@ import { DownCircleOutlined, MoreOutlined } from "@ant-design/icons";
import { getSession } from "next-auth/react";
import { toast } from "react-toastify";
const GiftcardListing = () => {
const [session, setSession] = useState()
const [update, setupdate] = useState(false)
const [session, setSession] = useState();
const [update, setupdate] = useState(false);
useEffect(() => {
const fetchSession = async () => {
setSession(await getSession());
......@@ -17,41 +17,46 @@ const GiftcardListing = () => {
}, []);
const [giftData, setGiftData] = useState([]);
useEffect(() => {
axios.get(`${process.env.NEXT_PUBLIC_BACKEND_API_URL}/api/gift-cards`).then((res) => {
axios
.get(`${process.env.NEXT_PUBLIC_BACKEND_API_URL}/api/gift-cards`)
.then(res => {
let giftDatas =
res.data &&
res.data.data.map((data) => {
res.data.data.map(data => {
return {
key: data.id,
amount: data?.attributes?.amount,
senderEmail: data?.attributes?.senderEmail,
receiverEmail: data?.attributes?.receiverEmail,
status: data?.attributes?.status,
}
})
setGiftData(giftDatas)
}).catch((err) => {
console.log(err)
senderName: data?.attributes?.senderName,
receiverName: data?.attributes?.receiverName
};
});
setGiftData(giftDatas);
})
}, [update])
.catch(err => {
console.log(err);
});
}, [update]);
const changeStatusFn = async ({ id, data }) => {
const config = {
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${session.jwt}`
}
}
};
const giftdata = {
data
}
};
const response = await axios.put(`${process.env.NEXT_PUBLIC_BACKEND_API_URL}/api/gift-cards/${id}`, giftdata, config)
const response = await axios.put(`${process.env.NEXT_PUBLIC_BACKEND_API_URL}/api/gift-cards/${id}`, giftdata, config);
if (response.status == 200) {
toast.success("Status changed")
setupdate(!update)
toast.success("Status changed");
setupdate(!update);
}
console.log("response gift card", response);
}
};
const columns = [
{
title: "Sender Email Address",
......@@ -60,93 +65,105 @@ const GiftcardListing = () => {
render: text => <a>{text}</a>
},
{
title: "Sender Name",
dataIndex: "senderName",
key: "senderName",
render: text => <a>{text}</a>
},
{
title: "Receiver Email Address",
dataIndex: "receiverEmail",
key: "receiverEmail",
render: text => <a>{text}</a>
},
{
title: "Receiver Name",
dataIndex: "receiverName",
key: "receiverName",
render: text => <a>{text}</a>
},
{
title: "Amount",
dataIndex: "amount",
key: "amount",
render: text => <a>{text}</a>
},
{
title: "Status",
dataIndex: "status",
key: "status",
render: tag => (
<span>
{tag == "rejected" ? (
<Tag color={"red"} key={tag}>
{tag.toUpperCase()}
</Tag>
) : (
<Tag color={"blue"} key={tag}>
{tag === "fulfilled" ? "APPROVED" : tag.toUpperCase()}
</Tag>
)}
</span>
)
},
{
title: 'Actions',
width: 100,
dataIndex: 'key',
key: 'key',
render: (_, record) => (
<Space size="middle">
{/* <a>Invite {record.name}</a> */}
<Dropdown
menu={{
items: [
{
key: "1",
label: (
<a
rel="noopener noreferrer"
onClick={async () => {
console.log("record", record);
await changeStatusFn({ id: record.key, data: { status: "fulfilled" } })
// setrejectionId(record.key);
// adminActions({ type: "reject", activityId: record.key });
}}
>
Approve
</a>
)
},
{
key: "2",
label: (
<a
target="_blank"
rel="noopener noreferrer"
onClick={async () => {
console.log("record", record);
await changeStatusFn({ id: record.key, data: { status: "rejected" } })
// setrejectionId(record.key);
// adminActions({ type: "reject", activityId: record.key });
}}
>
Reject
</a>
)
}
]
}}
placement="bottomLeft"
trigger={['click']}
>
<button className="btn border-0">
<DownCircleOutlined style={{ fontSize: "20px", color: "#08c" }} onClick={() => { }} />
</button>
</Dropdown>
</Space>
)
}
]
// {
// title: "Status",
// dataIndex: "status",
// key: "status",
// render: tag => (
// <span>
// {tag == "rejected" ? (
// <Tag color={"red"} key={tag}>
// {tag.toUpperCase()}
// </Tag>
// ) : (
// <Tag color={"blue"} key={tag}>
// {tag === "fulfilled" ? "APPROVED" : tag.toUpperCase()}
// </Tag>
// )}
// </span>
// )
// },
// {
// title: "Actions",
// width: 100,
// dataIndex: "key",
// key: "key",
// render: (_, record) => (
// <Space size="middle">
// {/* <a>Invite {record.name}</a> */}
// <Dropdown
// menu={{
// items: [
// {
// key: "1",
// label: (
// <a
// rel="noopener noreferrer"
// onClick={async () => {
// console.log("record", record);
// await changeStatusFn({ id: record.key, data: { status: "fulfilled" } });
// // setrejectionId(record.key);
// // adminActions({ type: "reject", activityId: record.key });
// }}
// >
// Approve
// </a>
// )
// },
// {
// key: "2",
// label: (
// <a
// target="_blank"
// rel="noopener noreferrer"
// onClick={async () => {
// console.log("record", record);
// await changeStatusFn({ id: record.key, data: { status: "rejected" } });
// // setrejectionId(record.key);
// // adminActions({ type: "reject", activityId: record.key });
// }}
// >
// Reject
// </a>
// )
// }
// ]
// }}
// placement="bottomLeft"
// trigger={["click"]}
// >
// <button className="btn border-0">
// <DownCircleOutlined style={{ fontSize: "20px", color: "#08c" }} onClick={() => {}} />
// </button>
// </Dropdown>
// </Space>
// )
// }
];
console.log("giftData", giftData);
return (
<Fragment>
<div className="p-5 h-100">
......
......@@ -5,7 +5,6 @@ import { Loader } from "react-bootstrap-typeahead";
import { FaAngleLeft } from "react-icons/fa";
import { useDispatch, useSelector } from "react-redux";
import { toast } from "react-toastify";
// import { getActivitiesByFilters } from "../../redux/actions/activityAction";
import { deleteReview, getReviewsAction } from "../../redux/actions/reviewsAction";
const ReviewsListing = ({ activityId, setshowReviews, isVendor }) => {
......
......@@ -119,6 +119,10 @@ const VendorDetails = ({ id, backClick, setShowDetail, showDetail, detail }) =>
<p className="col-12 col-lg-6">Business Name</p>
<p className="col-12 col-lg-6">{detail[0].attributes.businessName}</p>
</div>
{/* <div className="row">
<p className="col-12 col-lg-6">Vendor website:</p>
<p className="col-12 col-lg-6">{detail[0].attributes.businessName}</p>
</div> */}
</div>
<div className="col-12 col-lg-7 borderLeft">
<p className="phead">Business Address</p>
......
import { CheckOutlined, DeleteTwoTone, EyeTwoTone, StopOutlined, StopTwoTone } from "@ant-design/icons";
import { Space, Table, Tag } from "antd";
import { CheckOutlined, DeleteTwoTone, EyeTwoTone, SearchOutlined, StopOutlined, StopTwoTone } from "@ant-design/icons";
import { Input, Space, Table, Tag } from "antd";
import { getSession } from "next-auth/react";
import { useRouter } from "next/router";
import { Fragment, useEffect, useState } from "react";
import { Fragment, useEffect, useRef, useState } from "react";
import { Button, Image } from "react-bootstrap";
import Highlighter from "react-highlight-words";
import { useDispatch, useSelector } from "react-redux";
import { loadUser } from "../../redux/actions/userActions";
import { getAllVendors } from "../../redux/actions/vendorActions";
......@@ -12,6 +13,8 @@ import VendorDetails from "./VendorDetails";
const VendorListing = () => {
// Hooks
const searchInput = useRef(null);
const dispatch = useDispatch();
const router = useRouter();
// useState
......@@ -22,13 +25,125 @@ const VendorListing = () => {
const [data, setData] = useState([]);
const [showDetail, setShowDetail] = useState(false);
const [detail, setDetail] = useState();
const [searchedColumn, setSearchedColumn] = useState("");
const [searchText, setSearchText] = useState("");
const handleReset = clearFilters => {
clearFilters();
setSearchText("");
};
// selectors
const { loadedUser } = useSelector(state => state.loadedUser);
const { allVendors, loading: vendorLoading, totalCount } = useSelector(state => state.allVendors);
const toggleMenu = index => {
setShowMenuIndex(index === showMenuIndex ? null : index);
};
const handleSearch = (selectedKeys, confirm, dataIndex) => {
console.log("selectedKeys", selectedKeys);
if (!loadedUser) return;
dispatch(getAllVendors({ pageNumber: 1, pageSize: 10, str: selectedKeys[0] }));
confirm();
setSearchText(selectedKeys[0]);
setSearchedColumn(dataIndex);
};
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 => {
console.log("jere", e.target.value);
if (e.target.value == "") {
handleReset(clearFilters);
}
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>
),
filterIcon: filtered => (
<SearchOutlined
style={{
color: filtered ? "#1677ff" : undefined
}}
/>
),
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() : ""}
/>
) : (
text
)
});
// Session
// useEffect(() => {
......@@ -61,11 +176,6 @@ const VendorListing = () => {
}, []);
// console.log("session", loadedUser);
useEffect(() => {
if (!loadedUser) return;
dispatch(getAllVendors({ pageNumber: 1, pageSize: 10 }));
}, [loadedUser]);
const [tableCurrentPage, settableCurrentPage] = useState(1);
const [tableItemsPerPage, settableItemsPerPage] = useState(10);
......@@ -73,7 +183,7 @@ const VendorListing = () => {
console.log("params", pagination, filters, sorter, extra);
settableCurrentPage(pagination.current);
settableItemsPerPage(pagination.pageSize);
dispatch(getAllVendors({ pageNumber: pagination.current, pageSize: pagination.pageSize }));
dispatch(getAllVendors({ pageNumber: pagination.current, pageSize: pagination.pageSize, str: searchText }));
};
console.log("allVendors", allVendors);
......@@ -89,30 +199,40 @@ const VendorListing = () => {
// useEffect
useEffect(() => {
setLoading(true);
// setLoading(true);
let initialData =
allVendors &&
allVendors.map(item => {
console.log("item", item.attributes.user.data);
// console.log("item", item.attributes.user.data);
return {
key: item.id,
name: item.attributes.name,
businessName: item.attributes.businessName,
status: [item.attributes.user.data?.attributes.approved],
confirmed: item.attributes.user.data?.attributes.confirmed
confirmed: item.attributes.user.data?.attributes.confirmed,
email: item.attributes.email,
phone: item.attributes.phone
};
});
console.log("initialData", initialData);
setData(initialData);
setLoading(false);
// setLoading(false);
}, [allVendors]);
const columns = [
// {
// title: "Vendor ID",
// dataIndex: "vendorId",
// key: "vendorId",
// render: text => <a>{text}</a>,
// ...getColumnSearchProps("vendorId")
// },
{
title: "Name",
dataIndex: "name",
key: "name",
render: text => <a>{text}</a>
render: text => <a>{text}</a>,
...getColumnSearchProps("name")
},
{
title: "Business Name",
......@@ -120,15 +240,25 @@ const VendorListing = () => {
key: "businessName"
},
{
title: "OTP verified",
dataIndex: "confirmed",
key: "confirmed",
render: (_, { confirmed }) => (
<>
<>{confirmed ? <CheckOutlined /> : <StopOutlined />}</>
</>
)
title: "Phone",
dataIndex: "phone",
key: "phone"
},
{
title: "Email",
dataIndex: "email",
key: "email"
},
// {
// title: "OTP verified",
// dataIndex: "confirmed",
// key: "confirmed",
// render: (_, { confirmed }) => (
// <>
// <>{confirmed ? <CheckOutlined /> : <StopOutlined />}</>
// </>
// )
// },
{
title: "Approved",
key: "status",
......
......@@ -100,7 +100,7 @@ const ListingInner = ({ allActivitiesData, loading, totalCount }) => {
dispatch(
getActivitiesByFilters({
subCategory: filters.subCategory,
category: filters.category ? filters.category : router.query.category,
category: filters.category,
activityType: filters.activityType,
fromDate: filters.fromDate,
toDate: filters.toDate,
......
......@@ -117,7 +117,7 @@ const ListingItems = ({ allActivitiesData, loading, gridClass, totalCount }) =>
};
console.log("page", page);
useEffect(() => {
dispatch(getActivitiesByFilters({ currentPage: page }));
dispatch(getActivitiesByFilters({ category: router.query.category }));
}, []);
const calculateRating = data => {
......
......@@ -4,7 +4,7 @@ import { useDispatch, useSelector } from "react-redux";
import Highlighter from "react-highlight-words";
import { DeleteTwoTone, DownCircleOutlined, EditTwoTone, SearchOutlined } from "@ant-design/icons";
import { useRouter } from "next/router";
import { getActivitiesByVendor } from "../../redux/actions/activityAction";
import { getActivitiesByVendor, getActivitiesForAdmin } from "../../redux/actions/activityAction";
import { loadUser, updateActivityStatusAdmin } from "../../redux/actions/userActions";
import { Modal } from "react-bootstrap";
import { toast } from "react-toastify";
......@@ -185,9 +185,8 @@ export const ActivityListingRBAC = ({ setactivityDetailInfo, setShowActivityDeta
filters: categoryFilterArray,
filterMode: "tree",
filterSearch: true,
onFilter: (value, record) => {
console.log(value);
},
onFilter: (value, record) => record.category.startsWith(value),
// onFilter: (value, record) => record.category.startsWith(value),
width: "15%"
},
{
......
......@@ -28,7 +28,6 @@ export const getServerSideProps = wrapper.getServerSideProps(store => async ({ r
await store.dispatch(getActivityById(query.id));
await store.dispatch(getFaqs());
await store.dispatch(getReviewsAction({activityId: query.id}))
// await store.dispatch(getActivitiesByFilters({category: query.category}))
return {
props: {}
......
import React, { useEffect, useState } from "react";
import Enquiries from "../../../components/admin/Enquiries";
import { GenericLayout } from "../../../components/layout/Generics/GenericLayout";
import { wrapper } from "../../../redux/store";
export default function Enquiries() {
export default function EnquiriesPage() {
return (
<GenericLayout>
<Enquiries />
</GenericLayout>
);
}
......
import React from "react";
import React, { useEffect } from "react";
import Layout from "../../../components/layout/Layout";
import Sidebar from "../../../components/layout/AdminDashboardSidebar";
import VendorListing from "../../../components/admin/VendorListing";
......@@ -6,8 +6,14 @@ import { wrapper } from "../../../redux/store";
import { loadUser } from "../../../redux/actions/userActions";
import { getAllCategories, getAllSubCategories } from "../../../redux/actions/categoriesAction";
import { GenericLayout } from "../../../components/layout/Generics/GenericLayout";
import { getAllVendors } from "../../../redux/actions/vendorActions";
import { useDispatch } from "react-redux";
export default function VendorListingPage() {
const dispatch = useDispatch();
useEffect(() => {
dispatch(getAllVendors({ pageNumber: 1, pageSize: 10 }));
}, []);
return (
// <Layout>
// <div className="sidebarContainer">
......
......@@ -23,12 +23,9 @@ export default function ListingPage() {
export const getServerSideProps = wrapper.getServerSideProps(store => async ({ req, query }) => {
try {
console.log("query", query);
await store.dispatch(getActivitiesByFilters({ currentPage: query.page }));
// await store.dispatch(getActivitiesByFilters({ currentPage: query.page }));
await store.dispatch(getAllCategories());
await store.dispatch(getSubCategoriesByCategoryId());
// if (query.category) {
// await store.dispatch(getActivitiesByFilters({ currentPage: query.page, category: query.category }));
// }
return {
props: {}
// Next.js will attempt to re-generate the page:
......
......@@ -61,9 +61,7 @@ export const createActivity = data => async dispatch => {
}
};
export const getActivitiesByVendor =
() =>
async dispatch => {
export const getActivitiesByVendor = () => async dispatch => {
// console.log("data", data);
const session = await getSession();
console.log("session", session);
......@@ -115,7 +113,7 @@ export const getActivitiesByVendor =
}
},
pagination: {
pageSize: 1000,
pageSize: 1000
// page: pageNumber
},
populate: [
......@@ -156,7 +154,7 @@ export const getActivitiesByVendor =
payload: error.response.data
});
}
};
};
export const getActivityById = id => async dispatch => {
try {
......@@ -253,7 +251,7 @@ export const updateActivityById =
};
export const getActivitiesForAdmin =
({ vendorId, pageNumber = 1, pageSize = 10 }) =>
({ vendorId, pageNumber = 1, pageSize = 10, category }) =>
async dispatch => {
try {
dispatch({
......@@ -296,7 +294,9 @@ export const getActivitiesForAdmin =
"reviews"
]
};
if (category) {
// query.filters["category"] = { name: { $eq: category } };
}
const queryString = qs.stringify(query, {
encodeValuesOnly: true
});
......
......@@ -5,6 +5,9 @@ import {
ENQUIRY_SUBMIT_FAIL,
ENQUIRY_SUBMIT_REQUEST,
ENQUIRY_SUBMIT_SUCCESS,
GET_ENQUIRIES_BY_ADMIN_FAIL,
GET_ENQUIRIES_BY_ADMIN_REQUEST,
GET_ENQUIRIES_BY_ADMIN_SUCCESS,
GET_ENQUIRIES_BY_VENDOR_FAIL,
GET_ENQUIRIES_BY_VENDOR_REQUEST,
GET_ENQUIRIES_BY_VENDOR_SUCCESS
......@@ -104,6 +107,47 @@ export const getEnquiriesByVendor = () => async dispatch => {
}
};
export const getEnquiriesByAdmin = () => async dispatch => {
try {
dispatch({
type: GET_ENQUIRIES_BY_ADMIN_REQUEST,
loading: true
});
const session = await getSession();
if (!session) {
return;
}
const config = {
headers: {
"Content-type": "application/json",
Authorization: `Bearer ${session.jwt}`
}
};
const query = {
filters: {},
populate: ["vendor", "experience", "end_user"]
};
const queryString = qs.stringify(query, {
encodeValuesOnly: true
});
const response = await axios.get(`${process.env.NEXT_PUBLIC_BACKEND_API_URL}/api/enquires/?${queryString}`, config);
dispatch({
type: GET_ENQUIRIES_BY_ADMIN_SUCCESS,
payload: response.data,
loading: false
});
} catch (error) {
dispatch({
type: GET_ENQUIRIES_BY_ADMIN_FAIL,
payload: error.response.data
});
}
};
export const changeEnquiryStatus = async ({ status, id }) => {
try {
const session = await getSession();
......
......@@ -188,7 +188,7 @@ export const getVendorDetails = () => async dispatch => {
};
export const getAllVendors =
({ pageNumber = 1, pageSize = 10 }) =>
({ pageNumber = 1, pageSize = 10, str }) =>
async dispatch => {
const session = await getSession();
try {
......@@ -207,13 +207,13 @@ export const getAllVendors =
return;
}
const query = {
// filters: {
filters: {
// user: {
// id: {
// $eq: session.id
// }
// }
// },
},
populate: ["user", "experiences", "brandLogo"],
sort: ["createdAt:desc"],
pagination: {
......@@ -221,6 +221,10 @@ export const getAllVendors =
page: pageNumber
}
};
if (str) {
query.filters["name"] = { $contains: str };
}
// console.log("here 3", query);
const queryString = qs.stringify(query, {
......
......@@ -6,6 +6,10 @@ export const GET_ENQUIRIES_BY_VENDOR_REQUEST = "GET_ENQUIRIES_BY_VENDOR_REQUEST"
export const GET_ENQUIRIES_BY_VENDOR_SUCCESS = "GET_ENQUIRIES_BY_VENDOR_SUCCESS";
export const GET_ENQUIRIES_BY_VENDOR_FAIL = "GET_ENQUIRIES_BY_VENDOR_FAIL";
export const GET_ENQUIRIES_BY_ADMIN_REQUEST = "GET_ENQUIRIES_BY_ADMIN_REQUEST";
export const GET_ENQUIRIES_BY_ADMIN_SUCCESS = "GET_ENQUIRIES_BY_ADMIN_SUCCESS";
export const GET_ENQUIRIES_BY_ADMIN_FAIL = "GET_ENQUIRIES_BY_ADMIN_FAIL";
export const CLEAR_ERRORS = "CLEAR_ERRORS";
// export const TOGGLE_SUCCESS
\ No newline at end of file
......@@ -2,6 +2,9 @@ import {
ENQUIRY_SUBMIT_FAIL,
ENQUIRY_SUBMIT_REQUEST,
ENQUIRY_SUBMIT_SUCCESS,
GET_ENQUIRIES_BY_ADMIN_FAIL,
GET_ENQUIRIES_BY_ADMIN_REQUEST,
GET_ENQUIRIES_BY_ADMIN_SUCCESS,
GET_ENQUIRIES_BY_VENDOR_FAIL,
GET_ENQUIRIES_BY_VENDOR_REQUEST,
GET_ENQUIRIES_BY_VENDOR_SUCCESS
......@@ -36,7 +39,7 @@ export const getEnquiriesReducer = (state = { enquiriesByVendor: null }, action)
switch (action.type) {
case GET_ENQUIRIES_BY_VENDOR_REQUEST:
return {
loading: true,
loading: true
};
case GET_ENQUIRIES_BY_VENDOR_SUCCESS:
return {
......@@ -53,3 +56,25 @@ export const getEnquiriesReducer = (state = { enquiriesByVendor: null }, action)
return state;
}
};
export const getEnquiriesByVendorReducer = (state = { enquiriesByAdmin: null }, action) => {
switch (action.type) {
case GET_ENQUIRIES_BY_ADMIN_REQUEST:
return {
loading: true
};
case GET_ENQUIRIES_BY_ADMIN_SUCCESS:
return {
loading: false,
enquiriesByAdmin: action.payload
};
case GET_ENQUIRIES_BY_ADMIN_FAIL:
return {
loading: false,
error: action.payload.error.message
};
default:
return state;
}
};
......@@ -2,7 +2,7 @@ import { combineReducers } from "redux";
import { projectReducer, projectsReducer, similarProjectsReducer } from "./projectsReducer";
import { townshipReducer, townshipsReducer } from "./townshipsReducer";
import { authReducer, forgotPasswordReducer, getEndUserReducer, loadedUserReducer, resetPasswordReducer, userReducer } from "./userReducers";
import { enquiryReducer, getEnquiriesReducer } from "./enquiryReducer";
import { enquiryReducer, getEnquiriesByVendorReducer, getEnquiriesReducer } from "./enquiryReducer";
import { displayEnquireNowReducer } from "./enquireNowModalReducer";
import { getAllVendorsReducer, getVendorDetailsReducer, loggedInVendorReducer, updateVendorReducer } from "./vendorReducers";
import { createActivityReducer, getActivitiesReducer, getActivityByIdReducer, getWishlistsReducer, setActivityFilterReducer, updateActivityByIdReducer } from "./activitiesReducer";
......@@ -48,6 +48,7 @@ const reducers = combineReducers({
faqs: getAllFaqsReducer,
reviews: reviewsReducer,
giftCard: giftCardReducer,
enquiriesByAdmin: getEnquiriesByVendorReducer,
});
export default reducers;
......@@ -189,7 +189,7 @@ export const resetPasswordReducer = (state = {}, action) => {
// Load user reducer
export const getEndUserReducer = (state = { loading: true, success: false, endUser: null }, action) => {
export const getEndUserReducer = (state = { loading: false, success: false, endUser: null }, action) => {
switch (action.type) {
case GET_END_USER_REQUEST:
return {
......
......@@ -109,7 +109,7 @@ export const getVendorDetailsReducer = (state = { loading: true, success: false,
}
};
export const getAllVendorsReducer = (state = { loading: true, success: false, allVendors: null }, action) => {
export const getAllVendorsReducer = (state = { loading: false, success: false, allVendors: null }, action) => {
switch (action.type) {
case GET_ALL_VENDORS_REQUEST:
return {
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!