Commit e483780f by jaymehta

.

1 parent 62a89dce
......@@ -74,7 +74,7 @@ const VendorDetails = ({ id, backClick, setShowDetail, showDetail, detail }) =>
default:
break;
}
return <Tag color={color}>{message.toUpperCase()}</Tag>;
return <Tag color={color}>{message?.toUpperCase()}</Tag>;
};
return (
<Fragment>
......@@ -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 pview">View</p>
</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">
<p className="col-12 col-lg-6">EIN Number</p>
<p className="col-12 col-lg-6">{detail[0].attributes.einNumber}</p>
......
......@@ -40,7 +40,9 @@ const VendorListing = () => {
const handleSearch = (selectedKeys, confirm, dataIndex) => {
console.log("selectedKeys", selectedKeys);
if (!loadedUser) return;
setTimeout(() => {
dispatch(getAllVendors({ pageNumber: 1, pageSize: 10, str: selectedKeys[0] }));
}, 500);
confirm();
setSearchText(selectedKeys[0]);
setSearchedColumn(dataIndex);
......@@ -91,7 +93,7 @@ const VendorListing = () => {
>
Reset
</Button>
<Button
{/* <Button
type="link"
size="small"
onClick={() => {
......@@ -103,7 +105,7 @@ const VendorListing = () => {
}}
>
Filter
</Button>
</Button> */}
<Button
type="link"
size="small"
......@@ -211,7 +213,8 @@ const VendorListing = () => {
status: [item.attributes.user.data?.attributes.approved],
confirmed: item.attributes.user.data?.attributes.confirmed,
email: item.attributes.email,
phone: item.attributes.phone
phone: item.attributes.phone,
vendorId: item.attributes.uniqueVendorId
};
});
console.log("initialData", initialData);
......@@ -228,11 +231,11 @@ const VendorListing = () => {
// ...getColumnSearchProps("vendorId")
// },
{
title: "Name",
dataIndex: "name",
key: "name",
title: "Vendor ID",
dataIndex: "vendorId",
key: "vendorId",
render: text => <a>{text}</a>,
...getColumnSearchProps("name")
...getColumnSearchProps("vendorId")
},
{
title: "Business Name",
......
......@@ -75,6 +75,7 @@ const ListingFilter = () => {
dispatch(setActivityFilters({ filters: { priceLowerLimit: 0, priceUpperLimit: 5000 } }));
setsliderLowerValue(0);
setsliderUpperValue(5000);
window.location.reload();
}}
>
Reset
......
......@@ -234,7 +234,7 @@ const ActivityDetails = ({ isUpdate, loadedUser }) => {
console.log("activityPeriodState", activityPeriodState);
return (
<Fragment>
{loadedUser && loadedUser.approved == "approved" ? (
{true ? (
<div className="container p-5">
<div className="row">
<div className="col-12 col-lg-8">
......
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 Highlighter from "react-highlight-words";
import { DeleteTwoTone, DownCircleOutlined, EditTwoTone, SearchOutlined } from "@ant-design/icons";
......@@ -8,12 +8,14 @@ import { getActivitiesByVendor, getActivitiesForAdmin } from "../../redux/action
import { loadUser, updateActivityStatusAdmin } from "../../redux/actions/userActions";
import { Modal } from "react-bootstrap";
import { toast } from "react-toastify";
import { getSession } from "next-auth/react";
import axios from "axios";
// const onChange = (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 dispatch = useDispatch();
// let columns = []
......@@ -22,7 +24,6 @@ export const ActivityListingRBAC = ({ setactivityDetailInfo, setShowActivityDeta
const { loadedUser } = useSelector(state => state.loadedUser);
const { categories } = useSelector(state => state.categories);
const { subCategories } = useSelector(state => state.subCategories);
// console.log("loadedUser", loadedUser);
// useStates
const [selectedRowKeys, setSelectedRowKeys] = useState([]);
const [columns, setcolumns] = useState([]);
......@@ -32,15 +33,28 @@ export const ActivityListingRBAC = ({ setactivityDetailInfo, setShowActivityDeta
const [searchedColumn, setSearchedColumn] = useState("");
const [rejectionReasonText, setrejectionReasonText] = useState("");
const [rejectionId, setrejectionId] = useState("");
const [session, setSession] = useState();
// functions
const onSelectChange = newSelectedRowKeys => {
console.log("selectedRowKeys changed: ", newSelectedRowKeys);
setSelectedRowKeys(newSelectedRowKeys);
};
useEffect(() => {
const fetchSession = async () => {
setSession(await getSession());
};
fetchSession();
// dispatch(getLoggedInVendor());
}, []);
// console.log("session", session);
const searchInput = useRef(null);
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();
setSearchText(selectedKeys[0]);
setSearchedColumn(dataIndex);
......@@ -89,7 +103,7 @@ export const ActivityListingRBAC = ({ setactivityDetailInfo, setShowActivityDeta
>
Reset
</Button>
<Button
{/* <Button
type="link"
size="small"
onClick={() => {
......@@ -101,7 +115,7 @@ export const ActivityListingRBAC = ({ setactivityDetailInfo, setShowActivityDeta
}}
>
Filter
</Button>
</Button> */}
<Button
type="link"
size="small"
......@@ -165,6 +179,7 @@ export const ActivityListingRBAC = ({ setactivityDetailInfo, setShowActivityDeta
location: item.attributes.masterPincode.data.attributes.name,
price: item.attributes.pricePerPerson,
place: item.attributes.activityType,
mostBooked: item.attributes.mostBooked,
gift: item.attributes.giftSomeone ? "Yes" : "No",
status: [item.attributes.approved]
};
......@@ -205,9 +220,34 @@ export const ActivityListingRBAC = ({ setactivityDetailInfo, setShowActivityDeta
width: "15%"
},
{
title: "Location",
dataIndex: "location",
width: "15%"
title: "Most popular",
dataIndex: "mostBooked",
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",
......@@ -276,42 +316,42 @@ export const ActivityListingRBAC = ({ setactivityDetailInfo, setShowActivityDeta
View Details
</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"
>
<Button style={{ border: "none" }}>
<DownCircleOutlined style={{ fontSize: "20px", color: "#08c" }} onClick={() => { }} />
<DownCircleOutlined style={{ fontSize: "20px", color: "#08c" }} onClick={() => {}} />
</Button>
</Dropdown>
</Space>
......@@ -346,9 +386,28 @@ export const ActivityListingRBAC = ({ setactivityDetailInfo, setShowActivityDeta
width: "15%"
},
{
title: "Location",
title: "Most popular",
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",
......@@ -469,7 +528,6 @@ export const ActivityListingRBAC = ({ setactivityDetailInfo, setShowActivityDeta
<div className="p-5">
<Table
loading={loading}
rowSelection={rowSelection}
columns={columns}
dataSource={data}
onChange={onChange}
......
......@@ -26,12 +26,13 @@ export default function ActivityListingPage() {
const [tableCurrentPage, settableCurrentPage] = useState(1);
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);
settableCurrentPage(pagination.current);
settableItemsPerPage(pagination.pageSize);
dispatch(getActivitiesForAdmin({ pageNumber: pagination.current, pageSize: pagination.pageSize }));
dispatch(getActivitiesForAdmin({ pageNumber: pagination.current, pageSize: pagination.pageSize, vendorName: filterValue }));
};
return (
......@@ -42,6 +43,7 @@ export default function ActivityListingPage() {
{/* <div className="content"> */}
{/* <ActivityListing /> */}
<ActivityListingRBAC
setfilterValue={setfilterValue}
setactivityDetailInfo={setactivityDetailInfo}
setShowActivityDetailsModal={setShowActivityDetailsModal}
onChange={onChange}
......
......@@ -251,7 +251,7 @@ export const updateActivityById =
};
export const getActivitiesForAdmin =
({ vendorId, pageNumber = 1, pageSize = 10, category }) =>
({ vendorId, pageNumber = 1, pageSize = 10, category, vendorName }) =>
async dispatch => {
try {
dispatch({
......@@ -272,6 +272,9 @@ export const getActivitiesForAdmin =
id: {
$eq: vendorId
}
},
name: {
$contains: vendorName
}
},
pagination: {
......@@ -337,7 +340,8 @@ export const getActivitiesForEndUser = () => async dispatch => {
const query = {
filters: {
approved: { $eq: "approved" }
approved: { $eq: "approved" },
mostBooked: { $eq: true }
},
sort: [{ createdAt: "asc" }],
pagination: {
......
......@@ -223,7 +223,7 @@ export const getAllVendors =
};
if (str) {
query.filters["name"] = { $contains: str };
query.filters["uniqueVendorId"] = { $contains: str };
}
// 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!