Commit 3ddd0dc9 by Ravindra Kanojiya
2 parents 6ddb1e0d 7ac5e063
...@@ -74,7 +74,7 @@ const VendorDetails = ({ id, backClick, setShowDetail, showDetail, detail }) => ...@@ -74,7 +74,7 @@ const VendorDetails = ({ id, backClick, setShowDetail, showDetail, detail }) =>
default: default:
break; break;
} }
return <Tag color={color}>{message.toUpperCase()}</Tag>; return <Tag color={color}>{message?.toUpperCase()}</Tag>;
}; };
return ( return (
<Fragment> <Fragment>
...@@ -107,6 +107,12 @@ const VendorDetails = ({ id, backClick, setShowDetail, showDetail, detail }) => ...@@ -107,6 +107,12 @@ const VendorDetails = ({ id, backClick, setShowDetail, showDetail, detail }) =>
<p className="col-12 col-lg-6">PAN</p> <p className="col-12 col-lg-6">PAN</p>
<p className="col-12 col-lg-6 pview">View</p> <p className="col-12 col-lg-6 pview">View</p>
</div> */} </div> */}
{detail[0].attributes.uniqueVendorId && (
<div className="row">
<p className="col-12 col-lg-6">Vendor ID</p>
<p className="col-12 col-lg-6">{detail[0].attributes.uniqueVendorId}</p>
</div>
)}
<div className="row"> <div className="row">
<p className="col-12 col-lg-6">EIN Number</p> <p className="col-12 col-lg-6">EIN Number</p>
<p className="col-12 col-lg-6">{detail[0].attributes.einNumber}</p> <p className="col-12 col-lg-6">{detail[0].attributes.einNumber}</p>
......
...@@ -40,7 +40,9 @@ const VendorListing = () => { ...@@ -40,7 +40,9 @@ const VendorListing = () => {
const handleSearch = (selectedKeys, confirm, dataIndex) => { const handleSearch = (selectedKeys, confirm, dataIndex) => {
console.log("selectedKeys", selectedKeys); console.log("selectedKeys", selectedKeys);
if (!loadedUser) return; if (!loadedUser) return;
dispatch(getAllVendors({ pageNumber: 1, pageSize: 10, str: selectedKeys[0] })); setTimeout(() => {
dispatch(getAllVendors({ pageNumber: 1, pageSize: 10, str: selectedKeys[0] }));
}, 500);
confirm(); confirm();
setSearchText(selectedKeys[0]); setSearchText(selectedKeys[0]);
setSearchedColumn(dataIndex); setSearchedColumn(dataIndex);
...@@ -91,7 +93,7 @@ const VendorListing = () => { ...@@ -91,7 +93,7 @@ const VendorListing = () => {
> >
Reset Reset
</Button> </Button>
<Button {/* <Button
type="link" type="link"
size="small" size="small"
onClick={() => { onClick={() => {
...@@ -103,7 +105,7 @@ const VendorListing = () => { ...@@ -103,7 +105,7 @@ const VendorListing = () => {
}} }}
> >
Filter Filter
</Button> </Button> */}
<Button <Button
type="link" type="link"
size="small" size="small"
...@@ -211,7 +213,8 @@ const VendorListing = () => { ...@@ -211,7 +213,8 @@ const VendorListing = () => {
status: [item.attributes.user.data?.attributes.approved], 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, email: item.attributes.email,
phone: item.attributes.phone phone: item.attributes.phone,
vendorId: item.attributes.uniqueVendorId
}; };
}); });
console.log("initialData", initialData); console.log("initialData", initialData);
...@@ -228,11 +231,11 @@ const VendorListing = () => { ...@@ -228,11 +231,11 @@ const VendorListing = () => {
// ...getColumnSearchProps("vendorId") // ...getColumnSearchProps("vendorId")
// }, // },
{ {
title: "Name", title: "Vendor ID",
dataIndex: "name", dataIndex: "vendorId",
key: "name", key: "vendorId",
render: text => <a>{text}</a>, render: text => <a>{text}</a>,
...getColumnSearchProps("name") ...getColumnSearchProps("vendorId")
}, },
{ {
title: "Business Name", title: "Business Name",
......
...@@ -299,6 +299,7 @@ const GiftCard = () => { ...@@ -299,6 +299,7 @@ const GiftCard = () => {
onClick={async () => { onClick={async () => {
setloading(true); setloading(true);
if (!session) { if (!session) {
setloading(false);
toast.warning("Please log in to buy a gift card."); toast.warning("Please log in to buy a gift card.");
return; return;
} }
......
...@@ -75,6 +75,7 @@ const ListingFilter = () => { ...@@ -75,6 +75,7 @@ const ListingFilter = () => {
dispatch(setActivityFilters({ filters: { priceLowerLimit: 0, priceUpperLimit: 5000 } })); dispatch(setActivityFilters({ filters: { priceLowerLimit: 0, priceUpperLimit: 5000 } }));
setsliderLowerValue(0); setsliderLowerValue(0);
setsliderUpperValue(5000); setsliderUpperValue(5000);
window.location.reload();
}} }}
> >
Reset Reset
......
...@@ -234,7 +234,7 @@ const ActivityDetails = ({ isUpdate, loadedUser }) => { ...@@ -234,7 +234,7 @@ const ActivityDetails = ({ isUpdate, loadedUser }) => {
console.log("activityPeriodState", activityPeriodState); console.log("activityPeriodState", activityPeriodState);
return ( return (
<Fragment> <Fragment>
{loadedUser && loadedUser.approved == "approved" ? ( {true ? (
<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, { useEffect, useRef, useState } from "react"; import React, { useEffect, useRef, useState } from "react";
import { Button, Dropdown, Input, Space, Table, Tag } from "antd"; import { Button, Dropdown, Input, Space, Switch, Table, Tag } from "antd";
import { useDispatch, useSelector } from "react-redux"; import { useDispatch, useSelector } from "react-redux";
import Highlighter from "react-highlight-words"; import Highlighter from "react-highlight-words";
import { DeleteTwoTone, DownCircleOutlined, EditTwoTone, SearchOutlined } from "@ant-design/icons"; import { DeleteTwoTone, DownCircleOutlined, EditTwoTone, SearchOutlined } from "@ant-design/icons";
...@@ -8,12 +8,14 @@ import { getActivitiesByVendor, getActivitiesForAdmin } from "../../redux/action ...@@ -8,12 +8,14 @@ import { getActivitiesByVendor, getActivitiesForAdmin } from "../../redux/action
import { loadUser, updateActivityStatusAdmin } from "../../redux/actions/userActions"; import { loadUser, updateActivityStatusAdmin } from "../../redux/actions/userActions";
import { Modal } from "react-bootstrap"; import { Modal } from "react-bootstrap";
import { toast } from "react-toastify"; import { toast } from "react-toastify";
import { getSession } from "next-auth/react";
import axios from "axios";
// const onChange = (pagination, filters, sorter, extra) => { // const onChange = (pagination, filters, sorter, extra) => {
// console.log("params", pagination, filters, sorter, extra); // console.log("params", pagination, filters, sorter, extra);
// }; // };
export const ActivityListingRBAC = ({ setactivityDetailInfo, setShowActivityDetailsModal, onChange, tableCurrentPage, tableItemsPerPage }) => { export const ActivityListingRBAC = ({ setactivityDetailInfo, setShowActivityDetailsModal, onChange, tableCurrentPage, tableItemsPerPage, setfilterValue }) => {
const router = useRouter(); const router = useRouter();
const dispatch = useDispatch(); const dispatch = useDispatch();
// let columns = [] // let columns = []
...@@ -22,7 +24,6 @@ export const ActivityListingRBAC = ({ setactivityDetailInfo, setShowActivityDeta ...@@ -22,7 +24,6 @@ export const ActivityListingRBAC = ({ setactivityDetailInfo, setShowActivityDeta
const { loadedUser } = useSelector(state => state.loadedUser); const { loadedUser } = useSelector(state => state.loadedUser);
const { categories } = useSelector(state => state.categories); const { categories } = useSelector(state => state.categories);
const { subCategories } = useSelector(state => state.subCategories); const { subCategories } = useSelector(state => state.subCategories);
// console.log("loadedUser", loadedUser);
// useStates // useStates
const [selectedRowKeys, setSelectedRowKeys] = useState([]); const [selectedRowKeys, setSelectedRowKeys] = useState([]);
const [columns, setcolumns] = useState([]); const [columns, setcolumns] = useState([]);
...@@ -32,15 +33,28 @@ export const ActivityListingRBAC = ({ setactivityDetailInfo, setShowActivityDeta ...@@ -32,15 +33,28 @@ export const ActivityListingRBAC = ({ setactivityDetailInfo, setShowActivityDeta
const [searchedColumn, setSearchedColumn] = useState(""); const [searchedColumn, setSearchedColumn] = useState("");
const [rejectionReasonText, setrejectionReasonText] = useState(""); const [rejectionReasonText, setrejectionReasonText] = useState("");
const [rejectionId, setrejectionId] = useState(""); const [rejectionId, setrejectionId] = useState("");
const [session, setSession] = useState();
// functions // functions
const onSelectChange = newSelectedRowKeys => { const onSelectChange = newSelectedRowKeys => {
console.log("selectedRowKeys changed: ", newSelectedRowKeys); console.log("selectedRowKeys changed: ", newSelectedRowKeys);
setSelectedRowKeys(newSelectedRowKeys); setSelectedRowKeys(newSelectedRowKeys);
}; };
useEffect(() => {
const fetchSession = async () => {
setSession(await getSession());
};
fetchSession();
// dispatch(getLoggedInVendor());
}, []);
// console.log("session", session);
const searchInput = useRef(null); const searchInput = useRef(null);
const handleSearch = (selectedKeys, confirm, dataIndex) => { const handleSearch = (selectedKeys, confirm, dataIndex) => {
console.log("dataIndex", selectedKeys[0]);
setfilterValue(selectedKeys[0]);
setTimeout(() => {
dispatch(getActivitiesForAdmin({ vendorName: selectedKeys[0], pageNumber: tableCurrentPage, pageSize: tableItemsPerPage }));
}, 500);
confirm(); confirm();
setSearchText(selectedKeys[0]); setSearchText(selectedKeys[0]);
setSearchedColumn(dataIndex); setSearchedColumn(dataIndex);
...@@ -89,7 +103,7 @@ export const ActivityListingRBAC = ({ setactivityDetailInfo, setShowActivityDeta ...@@ -89,7 +103,7 @@ export const ActivityListingRBAC = ({ setactivityDetailInfo, setShowActivityDeta
> >
Reset Reset
</Button> </Button>
<Button {/* <Button
type="link" type="link"
size="small" size="small"
onClick={() => { onClick={() => {
...@@ -101,7 +115,7 @@ export const ActivityListingRBAC = ({ setactivityDetailInfo, setShowActivityDeta ...@@ -101,7 +115,7 @@ export const ActivityListingRBAC = ({ setactivityDetailInfo, setShowActivityDeta
}} }}
> >
Filter Filter
</Button> </Button> */}
<Button <Button
type="link" type="link"
size="small" size="small"
...@@ -165,6 +179,7 @@ export const ActivityListingRBAC = ({ setactivityDetailInfo, setShowActivityDeta ...@@ -165,6 +179,7 @@ export const ActivityListingRBAC = ({ setactivityDetailInfo, setShowActivityDeta
location: item.attributes.masterPincode.data.attributes.name, location: item.attributes.masterPincode.data.attributes.name,
price: item.attributes.pricePerPerson, price: item.attributes.pricePerPerson,
place: item.attributes.activityType, place: item.attributes.activityType,
mostBooked: item.attributes.mostBooked,
gift: item.attributes.giftSomeone ? "Yes" : "No", gift: item.attributes.giftSomeone ? "Yes" : "No",
status: [item.attributes.approved] status: [item.attributes.approved]
}; };
...@@ -205,9 +220,34 @@ export const ActivityListingRBAC = ({ setactivityDetailInfo, setShowActivityDeta ...@@ -205,9 +220,34 @@ export const ActivityListingRBAC = ({ setactivityDetailInfo, setShowActivityDeta
width: "15%" width: "15%"
}, },
{ {
title: "Location", title: "Most popular",
dataIndex: "location", dataIndex: "mostBooked",
width: "15%" width: "15%",
render: (_, item) => (
<>
{
<Switch
checked={item.mostBooked}
onClick={()=> {
console.log("here");
}}
onChange={async e => {
// /api/experience/update-most-booked
const config = {
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${session.jwt}`
}
};
const response = await axios.post(`${process.env.NEXT_PUBLIC_BACKEND_API_URL}/api/experience/update-most-booked`, { mostBooked: e, id: item.key }, config);
dispatch(getActivitiesForAdmin({ pageNumber: tableCurrentPage, pageSize: tableItemsPerPage }));
// console.log("response", response);
}}
/>
}
</>
)
}, },
{ {
title: "Price", title: "Price",
...@@ -276,42 +316,42 @@ export const ActivityListingRBAC = ({ setactivityDetailInfo, setShowActivityDeta ...@@ -276,42 +316,42 @@ export const ActivityListingRBAC = ({ setactivityDetailInfo, setShowActivityDeta
View Details View Details
</a> </a>
) )
},
{
key: "2",
label: (
<a
rel="noopener noreferrer"
onClick={() => {
setrejectionId(record.key);
adminActions({ type: "reject", activityId: record.key });
}}
>
Reject
</a>
)
},
{
key: "3",
label: (
<a
target="_blank"
rel="noopener noreferrer"
onClick={() => {
// setrejectionId(record.key);
adminActions({ type: "approve", activityId: record.key });
}}
>
Approve
</a>
)
} }
// {
// key: "2",
// label: (
// <a
// rel="noopener noreferrer"
// onClick={() => {
// setrejectionId(record.key);
// adminActions({ type: "reject", activityId: record.key });
// }}
// >
// Reject
// </a>
// )
// },
// {
// key: "3",
// label: (
// <a
// target="_blank"
// rel="noopener noreferrer"
// onClick={() => {
// // setrejectionId(record.key);
// adminActions({ type: "approve", activityId: record.key });
// }}
// >
// Approve
// </a>
// )
// }
] ]
}} }}
placement="bottomLeft" placement="bottomLeft"
> >
<Button style={{ border: "none" }}> <Button style={{ border: "none" }}>
<DownCircleOutlined style={{ fontSize: "20px", color: "#08c" }} onClick={() => { }} /> <DownCircleOutlined style={{ fontSize: "20px", color: "#08c" }} onClick={() => {}} />
</Button> </Button>
</Dropdown> </Dropdown>
</Space> </Space>
...@@ -346,9 +386,28 @@ export const ActivityListingRBAC = ({ setactivityDetailInfo, setShowActivityDeta ...@@ -346,9 +386,28 @@ export const ActivityListingRBAC = ({ setactivityDetailInfo, setShowActivityDeta
width: "15%" width: "15%"
}, },
{ {
title: "Location", title: "Most popular",
dataIndex: "location", dataIndex: "location",
width: "15%" width: "15%",
render: (_, { status }) => (
<>
{status == "approved" && (
<Tag color={"green"} key={1}>
Approved
</Tag>
)}
{status == "pending" && (
<Tag color={"orange"} key={1}>
Pending
</Tag>
)}
{status == "rejected" && (
<Tag color={"red"} key={1}>
Rejected
</Tag>
)}
</>
)
}, },
{ {
title: "Price", title: "Price",
...@@ -469,7 +528,6 @@ export const ActivityListingRBAC = ({ setactivityDetailInfo, setShowActivityDeta ...@@ -469,7 +528,6 @@ export const ActivityListingRBAC = ({ setactivityDetailInfo, setShowActivityDeta
<div className="p-5"> <div className="p-5">
<Table <Table
loading={loading} loading={loading}
rowSelection={rowSelection}
columns={columns} columns={columns}
dataSource={data} dataSource={data}
onChange={onChange} onChange={onChange}
......
...@@ -26,12 +26,13 @@ export default function ActivityListingPage() { ...@@ -26,12 +26,13 @@ export default function ActivityListingPage() {
const [tableCurrentPage, settableCurrentPage] = useState(1); const [tableCurrentPage, settableCurrentPage] = useState(1);
const [tableItemsPerPage, settableItemsPerPage] = useState(10); const [tableItemsPerPage, settableItemsPerPage] = useState(10);
const [filterValue, setfilterValue] = useState();
const onChange = (pagination, filters, sorter, extra) => { const onChange = (pagination, filters, sorter, extra, searchText) => {
console.log("params", pagination, filters, sorter, extra); console.log("params", pagination, filters, sorter, extra);
settableCurrentPage(pagination.current); settableCurrentPage(pagination.current);
settableItemsPerPage(pagination.pageSize); settableItemsPerPage(pagination.pageSize);
dispatch(getActivitiesForAdmin({ pageNumber: pagination.current, pageSize: pagination.pageSize })); dispatch(getActivitiesForAdmin({ pageNumber: pagination.current, pageSize: pagination.pageSize, vendorName: filterValue }));
}; };
return ( return (
...@@ -42,6 +43,7 @@ export default function ActivityListingPage() { ...@@ -42,6 +43,7 @@ export default function ActivityListingPage() {
{/* <div className="content"> */} {/* <div className="content"> */}
{/* <ActivityListing /> */} {/* <ActivityListing /> */}
<ActivityListingRBAC <ActivityListingRBAC
setfilterValue={setfilterValue}
setactivityDetailInfo={setactivityDetailInfo} setactivityDetailInfo={setactivityDetailInfo}
setShowActivityDetailsModal={setShowActivityDetailsModal} setShowActivityDetailsModal={setShowActivityDetailsModal}
onChange={onChange} onChange={onChange}
......
...@@ -251,7 +251,7 @@ export const updateActivityById = ...@@ -251,7 +251,7 @@ export const updateActivityById =
}; };
export const getActivitiesForAdmin = export const getActivitiesForAdmin =
({ vendorId, pageNumber = 1, pageSize = 10, category }) => ({ vendorId, pageNumber = 1, pageSize = 10, category, vendorName }) =>
async dispatch => { async dispatch => {
try { try {
dispatch({ dispatch({
...@@ -272,6 +272,9 @@ export const getActivitiesForAdmin = ...@@ -272,6 +272,9 @@ export const getActivitiesForAdmin =
id: { id: {
$eq: vendorId $eq: vendorId
} }
},
name: {
$contains: vendorName
} }
}, },
pagination: { pagination: {
...@@ -337,7 +340,8 @@ export const getActivitiesForEndUser = () => async dispatch => { ...@@ -337,7 +340,8 @@ export const getActivitiesForEndUser = () => async dispatch => {
const query = { const query = {
filters: { filters: {
approved: { $eq: "approved" } approved: { $eq: "approved" },
mostBooked: { $eq: true }
}, },
sort: [{ createdAt: "asc" }], sort: [{ createdAt: "asc" }],
pagination: { pagination: {
......
...@@ -223,7 +223,7 @@ export const getAllVendors = ...@@ -223,7 +223,7 @@ export const getAllVendors =
}; };
if (str) { if (str) {
query.filters["name"] = { $contains: str }; query.filters["uniqueVendorId"] = { $contains: str };
} }
// console.log("here 3", query); // console.log("here 3", query);
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!