Commit 64714aa2 by jaymehta

.

1 parent b22736c5
...@@ -137,6 +137,7 @@ const ActivityDetails = ({ isUpdate }) => { ...@@ -137,6 +137,7 @@ const ActivityDetails = ({ isUpdate }) => {
// const [fileList, setFileList] = useState([]); // const [fileList, setFileList] = useState([]);
// const [uploading, setUploading] = useState(false); // const [uploading, setUploading] = useState(false);
const [showImageUploadModal, setshowImageUploadModal] = useState(false); const [showImageUploadModal, setshowImageUploadModal] = useState(false);
const [imagesArrayComponent, setimagesArrayComponent] = useState([]);
useEffect(() => { useEffect(() => {
// dispatch(loadUser()); // dispatch(loadUser());
...@@ -239,6 +240,7 @@ const ActivityDetails = ({ isUpdate }) => { ...@@ -239,6 +240,7 @@ const ActivityDetails = ({ isUpdate }) => {
const { subCategories } = useSelector(state => state.subCategories); const { subCategories } = useSelector(state => state.subCategories);
const { loggedInVendor } = useSelector(state => state.loggedInVendor); const { loggedInVendor } = useSelector(state => state.loggedInVendor);
const { activityById } = useSelector(state => state.activityById); const { activityById } = useSelector(state => state.activityById);
console.log("activityById", activityById); console.log("activityById", activityById);
// console.log("tostring",activityById?.data.attributes.duration.toString()) // console.log("tostring",activityById?.data.attributes.duration.toString())
const currentDate = new Date(); const currentDate = new Date();
...@@ -257,7 +259,7 @@ const ActivityDetails = ({ isUpdate }) => { ...@@ -257,7 +259,7 @@ const ActivityDetails = ({ isUpdate }) => {
addressLine2: Yup.string(), addressLine2: Yup.string(),
pricePerPerson: Yup.string().required("Price Per Person is Required"), pricePerPerson: Yup.string().required("Price Per Person is Required"),
giftingToSomeone: Yup.string().required("Required field"), giftingToSomeone: Yup.string().required("Required field"),
place: Yup.string().required("Place is Required"), place: Yup.string(),
activityType: Yup.string().required("Required field"), activityType: Yup.string().required("Required field"),
contactPersonForActivity: Yup.string().required("Contact Person Name is Required"), contactPersonForActivity: Yup.string().required("Contact Person Name is Required"),
minGroupSize: Yup.string().required("Min Group Size is Required"), minGroupSize: Yup.string().required("Min Group Size is Required"),
...@@ -435,6 +437,7 @@ const ActivityDetails = ({ isUpdate }) => { ...@@ -435,6 +437,7 @@ const ActivityDetails = ({ isUpdate }) => {
daysBoolean, daysBoolean,
contactPersonForActivity: values.contactPersonForActivity, contactPersonForActivity: values.contactPersonForActivity,
duration: values.durationUnit.toString(), duration: values.durationUnit.toString(),
imagesComponent: imagesArrayComponent,
approved: "pending" approved: "pending"
}; };
if (!ref.current.state.selected[0]) { if (!ref.current.state.selected[0]) {
...@@ -1102,20 +1105,23 @@ const ActivityDetails = ({ isUpdate }) => { ...@@ -1102,20 +1105,23 @@ const ActivityDetails = ({ isUpdate }) => {
</div> </div>
</div> </div>
{/* <> {/* const [showImageUploadModal, setshowImageUploadModal] = useState(false); */}
<button {/* <ImageUploadPopUp isUpdate={isUpdate} setimagesArrayComponent={setimagesArrayComponent} />
{console.log("setimagesArrayComponent", imagesArrayComponent)} */}
<br />
<>
{/* <button
onClick={e => { onClick={e => {
e.preventDefault(); e.preventDefault();
setshowImageUploadModal(true); setshowImageUploadModal(true);
}} }}
> >
Open{" "} Open{" "}
</button> </button> */}
<br /> {/* <br />
<br /> <br /> */}
<br /> </>
</> */} {console.log("errors", errors)}
{/* {console.log("previewImage", previewImage)} */}
<div className="row"> <div className="row">
<div className="col-6 col-lg-5"> <div className="col-6 col-lg-5">
<div className="input-group"> <div className="input-group">
...@@ -1144,12 +1150,11 @@ const ActivityDetails = ({ isUpdate }) => { ...@@ -1144,12 +1150,11 @@ const ActivityDetails = ({ isUpdate }) => {
</div> </div>
</div> </div>
</div> </div>
<Modal show={showImageUploadModal} centered onHide={() => setshowImageUploadModal()}> {/* <Modal show={showImageUploadModal} centered onHide={() => setshowImageUploadModal()}>
<Modal.Header closeButton>Add Images</Modal.Header> <Modal.Header closeButton>Add Images</Modal.Header>
<Modal.Body> <Modal.Body>
<ImageUploadPopUp />
</Modal.Body> </Modal.Body>
</Modal> </Modal> */}
<div className="col-12 col-lg-4"> <div className="col-12 col-lg-4">
<div className="content-div help-center"> <div className="content-div help-center">
<h2>Help Center</h2> <h2>Help Center</h2>
......
import { PlusOutlined } from "@ant-design/icons"; import { PlusOutlined } from "@ant-design/icons";
import { Upload, message } from "antd"; import { Upload, message, Image } from "antd";
import axios from "axios"; import axios from "axios";
import { getSession } from "next-auth/react"; import { getSession } from "next-auth/react";
import React, { useEffect, useState } from "react"; import React, { useEffect, useState } from "react";
import { useSelector } from "react-redux"; import { useSelector } from "react-redux";
const getBase64 = file =>
new Promise((resolve, reject) => {
const reader = new FileReader();
reader.readAsDataURL(file);
reader.onload = () => resolve(reader.result);
reader.onerror = error => reject(error);
});
const ImageUploadPopUp = () => { const ImageUploadPopUp = ({ isUpdate, setimagesArrayComponent }) => {
// const { loadedUser } = useSelector(state => state.loadedUser); // const { loadedUser } = useSelector(state => state.loadedUser);
const [session, setSession] = useState(); const [session, setSession] = useState();
const [previewOpen, setPreviewOpen] = useState(false);
const [previewImage, setPreviewImage] = useState("");
useEffect(() => { useEffect(() => {
const fetchSession = async () => { const fetchSession = async () => {
setSession(await getSession()); setSession(await getSession());
...@@ -18,11 +28,11 @@ const ImageUploadPopUp = () => { ...@@ -18,11 +28,11 @@ const ImageUploadPopUp = () => {
const [fileList, setFileList] = useState([]); const [fileList, setFileList] = useState([]);
const [uploading, setUploading] = useState(false); const [uploading, setUploading] = useState(false);
// console.log("session", session); // console.log("session", session);
let formData = new FormData();
const handleUpload = async () => { const handleUpload = async () => {
const formData = new FormData();
fileList.forEach(file => { fileList.forEach(file => {
console.log("file", file); console.log("file", file.originFileObj);
formData.append("files", file); formData.append("files", file.originFileObj);
}); });
console.log("fileList", fileList); console.log("fileList", fileList);
console.log("formData", formData); console.log("formData", formData);
...@@ -37,6 +47,11 @@ const ImageUploadPopUp = () => { ...@@ -37,6 +47,11 @@ const ImageUploadPopUp = () => {
} }
}); });
console.log("response image", response); console.log("response image", response);
setimagesArrayComponent(
response.data.map(item => {
return { imageUrl: `${process.env.NEXT_PUBLIC_BACKEND_API_URL}${item.url}` };
})
);
// eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MywiaWF0IjoxNzE2MzY5MzQyLCJleHAiOjE3MTg5NjEzNDJ9.dHTpIvuUi4r4Eh7n-74WKDXUlSaqvhjppGJ-1G4GvHk // eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MywiaWF0IjoxNzE2MzY5MzQyLCJleHAiOjE3MTg5NjEzNDJ9.dHTpIvuUi4r4Eh7n-74WKDXUlSaqvhjppGJ-1G4GvHk
// if (response.status === 200) { // if (response.status === 200) {
// message.success("upload successfully."); // message.success("upload successfully.");
...@@ -50,20 +65,40 @@ const ImageUploadPopUp = () => { ...@@ -50,20 +65,40 @@ const ImageUploadPopUp = () => {
setUploading(false); setUploading(false);
} }
}; };
const handlePreview = async file => {
if (!file.url && !file.preview) {
file.preview = await getBase64(file.originFileObj);
}
setPreviewImage(file.url || file.preview);
setPreviewOpen(true);
};
const handleImageChange = info => { const handleImageChange = info => {
setFileList(info.fileList); setFileList(info.fileList);
}; };
return ( return (
<div> <div>
<Upload listType="picture-card" fileList={fileList} beforeUpload={() => false} onChange={handleImageChange}> <Upload listType="picture-card" fileList={fileList} onChange={handleImageChange}>
{fileList.length >= 8 ? null : ( {fileList.length >= 5 ? null : (
<div> <div>
<PlusOutlined /> <PlusOutlined />
<div style={{ marginTop: 8 }}>Upload</div> <div style={{ marginTop: 8 }}>Upload</div>
</div> </div>
)} )}
</Upload> </Upload>
{previewImage && (
<Image
wrapperStyle={{
display: "none"
// zIndex: 23
}}
preview={{
visible: previewOpen,
onVisibleChange: visible => setPreviewOpen(visible),
afterOpenChange: visible => !visible && setPreviewImage("")
}}
src={previewImage}
/>
)}
<button type="button" onClick={handleUpload} disabled={fileList.length === 0} loading={uploading} style={{ marginTop: 16 }}> <button type="button" onClick={handleUpload} disabled={fileList.length === 0} loading={uploading} style={{ marginTop: 16 }}>
{uploading ? "Uploading" : "Start Upload"} {uploading ? "Uploading" : "Start Upload"}
</button> </button>
......
...@@ -839,7 +839,16 @@ ansi-styles@^4.1.0: ...@@ -839,7 +839,16 @@ ansi-styles@^4.1.0:
dependencies: dependencies:
color-convert "^2.0.1" color-convert "^2.0.1"
antd@^5.15.3: antd-img-crop@^4.22.0:
version "4.22.0"
resolved "https://registry.npmjs.org/antd-img-crop/-/antd-img-crop-4.22.0.tgz"
integrity sha512-mfGujUUH+rf9L4ENx7yFJPkvtnEjvexWmR1/kycHzVUnMlC1UBtFMKcXgYvtNl/JTAW6jRVRc1asjzGr9idIZA==
dependencies:
compare-versions "6.1.0"
react-easy-crop "^5.0.7"
tslib "^2.6.2"
antd@^5.15.3, antd@>=4.0.0:
version "5.15.3" version "5.15.3"
resolved "https://registry.npmjs.org/antd/-/antd-5.15.3.tgz" resolved "https://registry.npmjs.org/antd/-/antd-5.15.3.tgz"
integrity sha512-53dpdGbfwipHVbqITmppp8N16i+BscMzz8NUNwaJgxwSvO9VQh/NfC/90lqGq3I2oBmxQ8TzRIxzFVKD/9OhlQ== integrity sha512-53dpdGbfwipHVbqITmppp8N16i+BscMzz8NUNwaJgxwSvO9VQh/NfC/90lqGq3I2oBmxQ8TzRIxzFVKD/9OhlQ==
...@@ -1510,6 +1519,11 @@ commondir@^1.0.1: ...@@ -1510,6 +1519,11 @@ commondir@^1.0.1:
resolved "https://registry.npmjs.org/commondir/-/commondir-1.0.1.tgz" resolved "https://registry.npmjs.org/commondir/-/commondir-1.0.1.tgz"
integrity sha512-W9pAhw0ja1Edb5GVdIF1mjZw/ASI0AlShXM83UUGe2DVr5TdAPEA1OA8m/g8zWp9x6On7gqufY+FatDbC3MDQg== integrity sha512-W9pAhw0ja1Edb5GVdIF1mjZw/ASI0AlShXM83UUGe2DVr5TdAPEA1OA8m/g8zWp9x6On7gqufY+FatDbC3MDQg==
compare-versions@6.1.0:
version "6.1.0"
resolved "https://registry.npmjs.org/compare-versions/-/compare-versions-6.1.0.tgz"
integrity sha512-LNZQXhqUvqUTotpZ00qLSaify3b4VFD588aRr8MKFw4CMUr98ytzCW5wDH5qx/DEY5kCDXcbcRuCqL0szEf2tg==
component-emitter@^1.2.1: component-emitter@^1.2.1:
version "1.3.0" version "1.3.0"
resolved "https://registry.npmjs.org/component-emitter/-/component-emitter-1.3.0.tgz" resolved "https://registry.npmjs.org/component-emitter/-/component-emitter-1.3.0.tgz"
...@@ -3825,6 +3839,11 @@ normalize-scroll-left@^0.1.2: ...@@ -3825,6 +3839,11 @@ normalize-scroll-left@^0.1.2:
resolved "https://registry.npmjs.org/normalize-scroll-left/-/normalize-scroll-left-0.1.2.tgz" resolved "https://registry.npmjs.org/normalize-scroll-left/-/normalize-scroll-left-0.1.2.tgz"
integrity sha512-F9YMRls0zCF6BFIE2YnXDRpHPpfd91nOIaNdDgrx5YMoPLo8Wqj+6jNXHQsYBavJeXP4ww8HCt0xQAKc5qk2Fg== integrity sha512-F9YMRls0zCF6BFIE2YnXDRpHPpfd91nOIaNdDgrx5YMoPLo8Wqj+6jNXHQsYBavJeXP4ww8HCt0xQAKc5qk2Fg==
normalize-wheel@^1.0.1:
version "1.0.1"
resolved "https://registry.npmjs.org/normalize-wheel/-/normalize-wheel-1.0.1.tgz"
integrity sha512-1OnlAPZ3zgrk8B91HyRj+eVv+kS5u+Z0SCsak6Xil/kmgEia50ga7zfkumayonZrImffAxPU/5WcyGhzetHNPA==
oauth@^0.9.15: oauth@^0.9.15:
version "0.9.15" version "0.9.15"
resolved "https://registry.npmjs.org/oauth/-/oauth-0.9.15.tgz" resolved "https://registry.npmjs.org/oauth/-/oauth-0.9.15.tgz"
...@@ -4762,7 +4781,7 @@ react-datepicker@^4.8.0: ...@@ -4762,7 +4781,7 @@ react-datepicker@^4.8.0:
react-onclickoutside "^6.12.0" react-onclickoutside "^6.12.0"
react-popper "^2.2.5" react-popper "^2.2.5"
react-dom@*, "react-dom@^0.14.0 || ^15.0.0 || ^16 || ^17 || ^18", "react-dom@^0.14.0 || ^15.0.0 || ^16.0.0 || ^17.0.0 || ^18.0.0", "react-dom@^15.5.x || ^16.x || ^17.x || ^18.x", "react-dom@^16.12.0 || ^17.0.0 || ^18.0.0 || ^19.0.0 || ^20.0.0 || ^21.0.0", "react-dom@^16.8 || ^17.0 || ^18.0", "react-dom@^16.8.0 || ^17 || ^18", "react-dom@^16.8.0 || ^17.0.0 || ^18.0.0", "react-dom@^16.9.0 || ^17 || ^18", "react-dom@^17.0.2 || ^18", "react-dom@^17.0.2 || ^18.0.0-0", react-dom@^18.0.0, react-dom@^18.2.0, react-dom@>=16, react-dom@>=16.0.0, react-dom@>=16.11.0, react-dom@>=16.14.0, react-dom@>=16.3.0, react-dom@>=16.6.0, react-dom@>=16.8.0, "react-dom@>=16.8.6 || ^17.0.0 || ^18.0.0", react-dom@>=16.9.0, react-dom@18.2.0: react-dom@*, "react-dom@^0.14.0 || ^15.0.0 || ^16 || ^17 || ^18", "react-dom@^0.14.0 || ^15.0.0 || ^16.0.0 || ^17.0.0 || ^18.0.0", "react-dom@^15.5.x || ^16.x || ^17.x || ^18.x", "react-dom@^16.12.0 || ^17.0.0 || ^18.0.0 || ^19.0.0 || ^20.0.0 || ^21.0.0", "react-dom@^16.8 || ^17.0 || ^18.0", "react-dom@^16.8.0 || ^17 || ^18", "react-dom@^16.8.0 || ^17.0.0 || ^18.0.0", "react-dom@^16.9.0 || ^17 || ^18", "react-dom@^17.0.2 || ^18", "react-dom@^17.0.2 || ^18.0.0-0", react-dom@^18.0.0, react-dom@^18.2.0, react-dom@>=16, react-dom@>=16.0.0, react-dom@>=16.11.0, react-dom@>=16.14.0, react-dom@>=16.3.0, react-dom@>=16.4.0, react-dom@>=16.6.0, react-dom@>=16.8.0, "react-dom@>=16.8.6 || ^17.0.0 || ^18.0.0", react-dom@>=16.9.0, react-dom@18.2.0:
version "18.2.0" version "18.2.0"
resolved "https://registry.npmjs.org/react-dom/-/react-dom-18.2.0.tgz" resolved "https://registry.npmjs.org/react-dom/-/react-dom-18.2.0.tgz"
integrity sha512-6IMTriUmvsjHUjNtEDudZfuDQUoWXVxKHhlEGSk81n4YFS+r/Kl99wXiwlVXtPBtJenozv2P+hxDsw9eA7Xo6g== integrity sha512-6IMTriUmvsjHUjNtEDudZfuDQUoWXVxKHhlEGSk81n4YFS+r/Kl99wXiwlVXtPBtJenozv2P+hxDsw9eA7Xo6g==
...@@ -4789,6 +4808,14 @@ react-dom@16.14.0: ...@@ -4789,6 +4808,14 @@ react-dom@16.14.0:
prop-types "^15.6.2" prop-types "^15.6.2"
scheduler "^0.19.1" scheduler "^0.19.1"
react-easy-crop@^5.0.7:
version "5.0.7"
resolved "https://registry.npmjs.org/react-easy-crop/-/react-easy-crop-5.0.7.tgz"
integrity sha512-6d5IUt09M3HwdDGwrcjPVgfrOfYWAOku8sCTn/xU7b1vkEg+lExMLwW8UbR39L8ybQi0hJZTU57yprF9h5Q5Ig==
dependencies:
normalize-wheel "^1.0.1"
tslib "^2.0.1"
react-event-listener@^0.6.2: react-event-listener@^0.6.2:
version "0.6.6" version "0.6.6"
resolved "https://registry.npmjs.org/react-event-listener/-/react-event-listener-0.6.6.tgz" resolved "https://registry.npmjs.org/react-event-listener/-/react-event-listener-0.6.6.tgz"
...@@ -5120,7 +5147,7 @@ react-transition-group@^4.3.0, react-transition-group@^4.4.2: ...@@ -5120,7 +5147,7 @@ react-transition-group@^4.3.0, react-transition-group@^4.4.2:
loose-envify "^1.4.0" loose-envify "^1.4.0"
prop-types "^15.6.2" prop-types "^15.6.2"
react@*, "react@^0.14.0 || ^15.0.0 || ^16 || ^17 || ^18", "react@^0.14.0 || ^15.0.0 || ^16.0.0 || ^17.0.0", "react@^0.14.0 || ^15.0.0 || ^16.0.0 || ^17.0.0 || ^18.0.0", "react@^0.14.0 || ^15.0.0 || ^16.0.0-0 || ^17.0.0-0 || ^18.0.0-0", "react@^15.5.x || ^16.x || ^17.x || ^18.x", "react@^16.0.0 || ^17.0.0 || ^18.0.0", "react@^16.12.0 || ^17.0.0 || ^18.0.0 || ^19.0.0 || ^20.0.0 || ^21.0.0", "react@^16.8 || ^17.0 || ^18.0", "react@^16.8.0 || ^17 || ^18", "react@^16.8.0 || ^17.0.0 || ^18.0.0", "react@^16.8.0 || ^17.0.0-rc.1 || ^18.0.0", "react@^16.9.0 || ^17 || ^18", "react@^17.0.2 || ^18", "react@^17.0.2 || ^18.0.0-0", react@^18.0.0, react@^18.2.0, "react@>= 16.8.0 || 17.x.x || ^18.0.0-0", react@>=0.14.0, "react@>=0.14.0 || ^15.6.1 || ^16.0.0", react@>=15, react@>=15.0.0, react@>=16, react@>=16.0.0, react@>=16.11.0, react@>=16.14.0, react@>=16.3.0, react@>=16.6.0, react@>=16.8.0, "react@>=16.8.6 || ^17.0.0 || ^18.0.0", react@>=16.9.0, react@18.2.0: react@*, "react@^0.14.0 || ^15.0.0 || ^16 || ^17 || ^18", "react@^0.14.0 || ^15.0.0 || ^16.0.0 || ^17.0.0", "react@^0.14.0 || ^15.0.0 || ^16.0.0 || ^17.0.0 || ^18.0.0", "react@^0.14.0 || ^15.0.0 || ^16.0.0-0 || ^17.0.0-0 || ^18.0.0-0", "react@^15.5.x || ^16.x || ^17.x || ^18.x", "react@^16.0.0 || ^17.0.0 || ^18.0.0", "react@^16.12.0 || ^17.0.0 || ^18.0.0 || ^19.0.0 || ^20.0.0 || ^21.0.0", "react@^16.8 || ^17.0 || ^18.0", "react@^16.8.0 || ^17 || ^18", "react@^16.8.0 || ^17.0.0 || ^18.0.0", "react@^16.8.0 || ^17.0.0-rc.1 || ^18.0.0", "react@^16.9.0 || ^17 || ^18", "react@^17.0.2 || ^18", "react@^17.0.2 || ^18.0.0-0", react@^18.0.0, react@^18.2.0, "react@>= 16.8.0 || 17.x.x || ^18.0.0-0", react@>=0.14.0, "react@>=0.14.0 || ^15.6.1 || ^16.0.0", react@>=15, react@>=15.0.0, react@>=16, react@>=16.0.0, react@>=16.11.0, react@>=16.14.0, react@>=16.3.0, react@>=16.4.0, react@>=16.6.0, react@>=16.8.0, "react@>=16.8.6 || ^17.0.0 || ^18.0.0", react@>=16.9.0, react@18.2.0:
version "18.2.0" version "18.2.0"
resolved "https://registry.npmjs.org/react/-/react-18.2.0.tgz" resolved "https://registry.npmjs.org/react/-/react-18.2.0.tgz"
integrity sha512-/3IjMdb2L9QbBdWiW5e3P2/npwMBaU9mHCSCUzNln0ZCYbcfTsGbTJrU/kGemdH2IWmB2ioZ+zkxtmq6g09fGQ== integrity sha512-/3IjMdb2L9QbBdWiW5e3P2/npwMBaU9mHCSCUzNln0ZCYbcfTsGbTJrU/kGemdH2IWmB2ioZ+zkxtmq6g09fGQ==
...@@ -5943,10 +5970,10 @@ tslib@^1.9.3: ...@@ -5943,10 +5970,10 @@ tslib@^1.9.3:
resolved "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz" resolved "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz"
integrity sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg== integrity sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==
tslib@^2.4.0: tslib@^2.0.1, tslib@^2.4.0, tslib@^2.6.2:
version "2.4.0" version "2.6.2"
resolved "https://registry.npmjs.org/tslib/-/tslib-2.4.0.tgz" resolved "https://registry.npmjs.org/tslib/-/tslib-2.6.2.tgz"
integrity sha512-d6xOpEDfsi2CZVlPQzGeux8XMwLT9hssAsaPYExaQMuYskwb+x1x7J371tWlbBdWHroy99KnVB6qIkUbs5X3UQ== integrity sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==
tsutils@^3.21.0: tsutils@^3.21.0:
version "3.21.0" version "3.21.0"
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!