Commit c74737b0 by Chetan

vendor and admin side changes admin giftcard status update, user experiences rat…

…ing , read more and % off remove
1 parent 4fe9d397
import { Fragment, useEffect, useState } from "react"; import { Fragment, useEffect, useState } from "react";
import { Button, Image } from "react-bootstrap"; import { Button, Image } from "react-bootstrap";
import { getGiftCard } from "../../redux/actions/giftCardAction"; import { Dropdown, Menu, Space, Table, Tag } from "antd";
import { useDispatch, useSelector } from "react-redux";
import { Empty, Table } from "antd";
import axios from "axios"; import axios from "axios";
import { DownCircleOutlined, MoreOutlined } from "@ant-design/icons";
import { getSession } from "next-auth/react";
import { toast } from "react-toastify";
const GiftcardListing = () => { const GiftcardListing = () => {
const [giftData, setGiftData] = useState([]); const [session, setSession] = useState()
useEffect(() => { const [update, setupdate] = useState(false)
axios.get(`${process.env.NEXT_PUBLIC_BACKEND_API_URL}/api/gift-cards`).then((res) => { useEffect(() => {
let giftDatas = const fetchSession = async () => {
res.data && setSession(await getSession());
res.data.data.map((data) => { };
return { fetchSession();
key: data.id, // dispatch(getLoggedInVendor());
amount: data?.attributes?.amount, }, []);
senderEmail: data?.attributes?.senderEmail, const [giftData, setGiftData] = useState([]);
receiverEmail: data?.attributes?.receiverEmail, useEffect(() => {
status: data?.attributes?.status, axios.get(`${process.env.NEXT_PUBLIC_BACKEND_API_URL}/api/gift-cards`).then((res) => {
} let giftDatas =
}) res.data &&
setGiftData(giftDatas) res.data.data.map((data) => {
}).catch((err) => { return {
console.log(err) key: data.id,
amount: data?.attributes?.amount,
senderEmail: data?.attributes?.senderEmail,
receiverEmail: data?.attributes?.receiverEmail,
status: data?.attributes?.status,
}
}) })
}, []) setGiftData(giftDatas)
const columns = [ }).catch((err) => {
{ console.log(err)
title: "Sender Email Address", })
dataIndex: "senderEmail", }, [update])
key: "senderEmail", const changeStatusFn = async ({ id, data }) => {
render: text => <a>{text}</a> const config = {
}, headers: {
{ "Content-Type": "application/json",
title: "Receiver Email Address", Authorization: `Bearer ${session.jwt}`
dataIndex: "receiverEmail", }
key: "receiverEmail", }
render: text => <a>{text}</a> const giftdata = {
}, data
{ }
title: "Amount",
dataIndex: "amount", const response = await axios.put(`${process.env.NEXT_PUBLIC_BACKEND_API_URL}/api/gift-cards/${id}`, giftdata, config)
key: "amount", if (response.status == 200) {
render: text => <a>{text}</a> toast.success("Status changed")
}, setupdate(!update)
{ }
title: "Status", console.log("response gift card", response);
dataIndex: "status", }
key: "status", const columns = [
render: text => <a>{text}</a> {
}, title: "Sender Email Address",
] dataIndex: "senderEmail",
return ( key: "senderEmail",
<Fragment> render: text => <a>{text}</a>
<div className="p-5 h-100"> },
<div className="d-flex align-items-center justify-content-between px-2 mb-2"> {
<div> title: "Receiver Email Address",
<h2 style={{ fontSize: 28 }}>Gift Card Requests</h2> dataIndex: "receiverEmail",
<p>View all the gift cards</p> key: "receiverEmail",
</div> render: text => <a>{text}</a>
<div> },
<Button type="button" variant="" className="btnAdd m-0"> {
<Image alt="" width="16" height="16" src="/images/vendor/icon-filter.svg" className="me-2" /> Filter title: "Amount",
</Button> dataIndex: "amount",
</div> key: "amount",
</div> render: text => <a>{text}</a>
<Table columns={columns} dataSource={giftData} /> },
</div> {
</Fragment> 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>
)
}
]
return (
<Fragment>
<div className="p-5 h-100">
<div className="d-flex align-items-center justify-content-between px-2 mb-2">
<div>
<h2 style={{ fontSize: 28 }}>Gift Card Requests</h2>
<p>View all the gift cards</p>
</div>
<div>
<Button type="button" variant="" className="btnAdd m-0">
<Image alt="" width="16" height="16" src="/images/vendor/icon-filter.svg" className="me-2" /> Filter
</Button>
</div>
</div>
<Table columns={columns} dataSource={giftData} />
</div>
</Fragment>
);
}; };
export default GiftcardListing; export default GiftcardListing;
...@@ -13,7 +13,7 @@ const WishlistComponent = ({ activityId, userId }) => { ...@@ -13,7 +13,7 @@ const WishlistComponent = ({ activityId, userId }) => {
wishlists && wishlists &&
wishlists.length > 0 && wishlists.length > 0 &&
wishlists.map(item => { wishlists.map(item => {
if (item.attributes.experience.data.id == activityId) { if (item?.attributes?.experience?.data?.id == activityId) {
setisActive(true); setisActive(true);
setwishlistId(item.id); setwishlistId(item.id);
} }
......
...@@ -93,12 +93,12 @@ const BrowseExperiences = ({ allActivitiesData }) => { ...@@ -93,12 +93,12 @@ const BrowseExperiences = ({ allActivitiesData }) => {
<div className="top-name"> <div className="top-name">
<div className="title">{data?.attributes?.name}</div> <div className="title">{data?.attributes?.name}</div>
<div className="rating-wishlist"> <div className="rating-wishlist">
<div className="rating"> {/* <div className="rating">
<span className="number">{data?.attributes?.rating}</span> <span className="number">{data?.attributes?.rating}</span>
<span className="image-container"> <span className="image-container">
<Image layout="fill" alt="" className="image img-fluid" src="/images/icons/star.svg" /> <Image layout="fill" alt="" className="image img-fluid" src="/images/icons/star.svg" />
</span> </span>
</div> </div> */}
<div className="wishlist"> <div className="wishlist">
{endUser && <WishlistComponent activityId={data.id} userId={endUser.id} />} {endUser && <WishlistComponent activityId={data.id} userId={endUser.id} />}
{/* <span className="image-container"> {/* <span className="image-container">
...@@ -108,10 +108,12 @@ const BrowseExperiences = ({ allActivitiesData }) => { ...@@ -108,10 +108,12 @@ const BrowseExperiences = ({ allActivitiesData }) => {
</div> </div>
</div> </div>
<div className="discription"> <div className="discription">
<span>{data?.attributes?.description}</span> <a href="/detail">Read More</a> <span>{data?.attributes?.description}</span>
{/* <a href="/detail">Read More</a> */}
</div> </div>
<div className="price"> <div className="price">
${data?.attributes?.pricePerPerson} <span className="off">{data?.attributes?.off}% OFF</span> ${data?.attributes?.pricePerPerson}
{/* <span className="off">{data?.attributes?.off}% OFF</span> */}
</div> </div>
<div className="detail"> <div className="detail">
<div className="">For 1 Night</div> <div className="">For 1 Night</div>
......
...@@ -3,6 +3,7 @@ import Image from "next/image" ...@@ -3,6 +3,7 @@ import Image from "next/image"
import { useRouter } from "next/router"; import { useRouter } from "next/router";
import { signOut } from "next-auth/react"; import { signOut } from "next-auth/react";
import { UserOutlined } from '@ant-design/icons'; import { UserOutlined } from '@ant-design/icons';
import { ToastContainer } from "react-toastify";
export const GenericHeader = ({ venderBusiness, venderEmail, businessLogo, adminName, adminEmail, isRoute }) => { export const GenericHeader = ({ venderBusiness, venderEmail, businessLogo, adminName, adminEmail, isRoute }) => {
const router = useRouter(); const router = useRouter();
const VenderDetails = () => { const VenderDetails = () => {
...@@ -14,7 +15,7 @@ export const GenericHeader = ({ venderBusiness, venderEmail, businessLogo, admin ...@@ -14,7 +15,7 @@ export const GenericHeader = ({ venderBusiness, venderEmail, businessLogo, admin
</div> </div>
: :
<div className="d-flex align-items-center gap-3"> <div className="d-flex align-items-center gap-3">
<Image src={businessLogo} height={50} width={70} objectFit="contain"/> <Image src={businessLogo} height={50} width={70} objectFit="contain" />
<div className="d-flex flex-column"> <div className="d-flex flex-column">
<p className="m-0">{venderBusiness}</p> <p className="m-0">{venderBusiness}</p>
<p className="m-0">{venderEmail}</p> <p className="m-0">{venderEmail}</p>
...@@ -51,6 +52,7 @@ export const GenericHeader = ({ venderBusiness, venderEmail, businessLogo, admin ...@@ -51,6 +52,7 @@ export const GenericHeader = ({ venderBusiness, venderEmail, businessLogo, admin
'-moz-box-shadow': '0px 4px 1px -3px rgba(0,0,0,0.56)' '-moz-box-shadow': '0px 4px 1px -3px rgba(0,0,0,0.56)'
}} }}
> >
<Image loading="lazy" objectFit="contain" height={50} width={100} alt="" className="" src="/images/main-logo.svg" /> <Image loading="lazy" objectFit="contain" height={50} width={100} alt="" className="" src="/images/main-logo.svg" />
<div className="d-flex align-items-center gap-5"> <div className="d-flex align-items-center gap-5">
{isRoute === 'vendor' && <VenderDetails />} {isRoute === 'vendor' && <VenderDetails />}
......
...@@ -6,7 +6,7 @@ import { GenericHeader } from "./GenericHeader"; ...@@ -6,7 +6,7 @@ import { GenericHeader } from "./GenericHeader";
import { GenericSidebar } from "./GenericSidebar"; import { GenericSidebar } from "./GenericSidebar";
import { getActivitiesForAdmin } from "../../../redux/actions/activityAction"; import { getActivitiesForAdmin } from "../../../redux/actions/activityAction";
import { useRouter } from "next/router"; import { useRouter } from "next/router";
import { ToastContainer } from "react-bootstrap"; import { ToastContainer } from "react-toastify";
export const GenericLayout = ({ children }) => { export const GenericLayout = ({ children }) => {
const dispatch = useDispatch(); const dispatch = useDispatch();
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!