Blame view

components/vendor/ActivityDetails.js 66.9 KB
1
import Image from "next/image";
Jyotsna committed
2
import { ErrorMessage, FieldArray, Formik } from "formik";
jaymehta committed
3
import { Fragment, useEffect, useRef, useState } from "react";
jaymehta committed
4
import { Button, Form, Modal } from "react-bootstrap";
5
import * as Yup from "yup";
jaymehta committed
6 7 8 9 10 11 12
import { FaTimes } from "react-icons/fa";
import { useDispatch, useSelector } from "react-redux";
import { getAllSubCategories } from "../../redux/actions/categoriesAction";
import { getLoggedInVendor, pincodeSearchByFilter } from "../../redux/actions/vendorActions";
import { AsyncTypeahead } from "react-bootstrap-typeahead";
import Select from "react-select";
import makeAnimated from "react-select/animated";
jaymehta committed
13 14
import { Select as AntSelect, Switch, Upload, Image as AntImage, message } from "antd";
// import { Image as AntSelect, Switch, Upload } from "antd";
jaymehta committed
15 16
// import { getMasterDays } from "../../redux/actions/activityAction";
import axios from "axios";
jaymehta committed
17
import { sanitizeTimeFormat, sanitizeTimeRange } from "../../services/imageHandling";
.  
jaymehta committed
18
import { createActivity, getActivityById, updateActivityById } from "../../redux/actions/activityAction";
jaymehta committed
19
import { toast } from "react-toastify";
jaymehta committed
20 21 22 23
import { DatePicker, Space } from "antd";
import dayjs from "dayjs";
import customParseFormat from "dayjs/plugin/customParseFormat";
import LazyLoad from "react-lazyload";
jaymehta committed
24
import { ArrowLeftOutlined, CheckCircleTwoTone, PlusOutlined } from "@ant-design/icons";
jaymehta committed
25
import { useRouter } from "next/router";
jaymehta committed
26 27
import ImageUploadPopUp from "./ImageUploadPopUp";
import { loadUser } from "../../redux/actions/userActions";
.  
jaymehta committed
28
import UploadImageComponent from "./UploadImageComponent";
jaymehta committed
29
import UploadImageCustom from "./UploadImageCustom";
jaymehta committed
30 31 32 33
dayjs.extend(customParseFormat);

const { RangePicker } = DatePicker;
const dateFormat = "YYYY/MM/DD";
jaymehta committed
34 35 36 37 38 39 40
const getBase64 = file =>
  new Promise((resolve, reject) => {
    const reader = new FileReader();
    reader.readAsDataURL(file);
    reader.onload = () => resolve(reader.result);
    reader.onerror = error => reject(error);
  });
41

jaymehta committed
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137
const format = "HH:mm";
let timeArray = [];

const hoursArray = [
  { value: "01", label: "01" },
  { value: "02", label: "02" },
  { value: "03", label: "03" },
  { value: "04", label: "04" },
  { value: "05", label: "05" },
  { value: "06", label: "06" },
  { value: "07", label: "07" },
  { value: "08", label: "08" },
  { value: "09", label: "09" },
  { value: "10", label: "10" },
  { value: "11", label: "11" },
  { value: "12", label: "12" }
];
const minutesArray = [
  { value: "00", label: "00" },
  { value: "01", label: "01" },
  { value: "02", label: "02" },
  { value: "03", label: "03" },
  { value: "04", label: "04" },
  { value: "05", label: "05" },
  { value: "06", label: "06" },
  { value: "07", label: "07" },
  { value: "08", label: "08" },
  { value: "09", label: "09" },
  { value: "10", label: "10" },
  { value: "11", label: "11" },
  { value: "12", label: "12" },
  { value: "13", label: "13" },
  { value: "14", label: "14" },
  { value: "15", label: "15" },
  { value: "16", label: "16" },
  { value: "17", label: "17" },
  { value: "18", label: "18" },
  { value: "19", label: "19" },
  { value: "20", label: "20" },
  { value: "21", label: "21" },
  { value: "22", label: "22" },
  { value: "23", label: "23" },
  { value: "24", label: "24" },
  { value: "25", label: "25" },
  { value: "26", label: "26" },
  { value: "27", label: "27" },
  { value: "28", label: "28" },
  { value: "29", label: "29" },
  { value: "30", label: "30" },
  { value: "31", label: "31" },
  { value: "32", label: "32" },
  { value: "33", label: "33" },
  { value: "34", label: "34" },
  { value: "35", label: "35" },
  { value: "36", label: "36" },
  { value: "37", label: "37" },
  { value: "38", label: "38" },
  { value: "39", label: "39" },
  { value: "40", label: "40" },
  { value: "41", label: "41" },
  { value: "42", label: "42" },
  { value: "43", label: "43" },
  { value: "44", label: "44" },
  { value: "45", label: "45" },
  { value: "46", label: "46" },
  { value: "47", label: "47" },
  { value: "48", label: "48" },
  { value: "49", label: "49" },
  { value: "50", label: "50" },
  { value: "51", label: "51" },
  { value: "52", label: "52" },
  { value: "53", label: "53" },
  { value: "54", label: "54" },
  { value: "55", label: "55" },
  { value: "56", label: "56" },
  { value: "57", label: "57" },
  { value: "58", label: "58" },
  { value: "59", label: "59" }
];
const monthsArray = [
  { value: "january", label: "January" },
  { value: "february", label: "February" },
  { value: "march", label: "March" },
  { value: "april", label: "April" },
  { value: "may", label: "May" },
  { value: "june", label: "June" },
  { value: "july", label: "July" },
  { value: "august", label: "August" },
  { value: "september", label: "September" },
  { value: "october", label: "October" },
  { value: "november", label: "November" },
  { value: "december", label: "December" }
];

// import { colourOptions } from '../data';
const animatedComponents = makeAnimated();
jaymehta committed
138
const ActivityDetails = ({ isUpdate }) => {
jaymehta committed
139 140 141
  // const [fileList, setFileList] = useState([]);
  // const [uploading, setUploading] = useState(false);
  const [showImageUploadModal, setshowImageUploadModal] = useState(false);
.  
jaymehta committed
142
  const [imagesArrayComponent, setimagesArrayComponent] = useState([]);
jaymehta committed
143
  const [displayImage, setdisplayImage] = useState();
jaymehta committed
144 145
  const [termsConditions, settermsConditions] = useState();
  const [cancellationPolicy, setCancellationPolicy] = useState();
jaymehta committed
146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188

  useEffect(() => {
    // dispatch(loadUser());
    // setFileList([
    //   // {
    //   //   uid: "-1",
    //   //   name: "image.png",
    //   //   status: "done",
    //   //   url: "https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png"
    //   // },
    //   // {
    //   //   uid: "-2",
    //   //   name: "image.png",
    //   //   status: "done",
    //   //   url: "https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png"
    //   // },
    //   // {
    //   //   uid: "-3",
    //   //   name: "image.png",
    //   //   status: "done",
    //   //   url: "https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png"
    //   // },
    //   // {
    //   //   uid: "-4",
    //   //   name: "image.png",
    //   //   status: "done",
    //   //   url: "https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png"
    //   // },
    //   // {
    //   //   uid: "-xxx",
    //   //   percent: 50,
    //   //   name: "image.png",
    //   //   status: "uploading",
    //   //   url: "https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png"
    //   // },
    //   // {
    //   //   uid: "-5",
    //   //   name: "image.png",
    //   //   status: "error"
    //   // }
    // ]);
  }, []);

jaymehta committed
189 190 191
  const ActivityApprovalStatus = ({ status }) => {
    if (status) {
      switch (status) {
jaymehta committed
192
        case "approved":
jaymehta committed
193 194 195 196 197 198 199 200 201 202 203 204
          return (
            <>
              <div className=" ">
                <div className="alert alert-success alert-dismissible fade show text-center" role="alert">
                  <div className="text-center">
                    <span>
                      <p className=" text-center">
                        Activity approved! <CheckCircleTwoTone twoToneColor="#00b33c" />
                      </p>
                    </span>
                    <p className=" text-center">If you make changes, the details will be sent again for approval.</p>
                  </div>
.  
jaymehta committed
205 206
                </div>
              </div>
jaymehta committed
207 208
            </>
          );
.  
jaymehta committed
209

jaymehta committed
210
        case "rejected":
jaymehta committed
211 212 213 214 215 216 217 218
          return (
            <>
              <div className="col-12 offset-lg-2 col-lg-8 ">
                <div className="alert alert-danger alert-dismissible fade show text-center" role="alert">
                  <div className="text-center">
                    <p className="p1 text-center">Your profile has been rejected!</p>
                    <p className="p2 text-center"> Please contact the admin for more details!</p>
                  </div>
.  
jaymehta committed
219 220
                </div>
              </div>
jaymehta committed
221 222
            </>
          );
.  
jaymehta committed
223

jaymehta committed
224 225 226 227 228 229 230 231 232 233 234 235 236
        case "pending":
          return (
            <>
              <div className="col-12 offset-lg-2 col-lg-8 ">
                <div className="alert alert-warning alert-dismissible fade show text-center" role="alert">
                  <div className="text-center">
                    <p className="p1 text-center">Your profile has been sent for approval!</p>
                    <p className="p2 text-center"> Please wait till the vendor takes action!</p>
                  </div>
                </div>
              </div>
            </>
          );
.  
jaymehta committed
237

jaymehta committed
238 239 240
        default:
          break;
      }
.  
jaymehta committed
241
    }
jaymehta committed
242
  };
jaymehta committed
243 244 245 246
  const dispatch = useDispatch();
  const { categories } = useSelector(state => state.categories);
  const { subCategories } = useSelector(state => state.subCategories);
  const { loggedInVendor } = useSelector(state => state.loggedInVendor);
jaymehta committed
247
  const { activityById } = useSelector(state => state.activityById);
.  
jaymehta committed
248

jaymehta committed
249
  console.log("activityById", activityById);
.  
jaymehta committed
250
  // console.log("tostring",activityById?.data.attributes.duration.toString())
jaymehta committed
251 252
  const currentDate = new Date();
  const sanitizedCurrentDate = sanitizeTimeRange({ data: { $d: currentDate } });
jaymehta committed
253
  console.log("subCategories", subCategories);
jaymehta committed
254
  const router = useRouter();
jaymehta committed
255 256 257 258 259 260 261
  let categoryRef = useRef();
  let timeLines;
  const activityDetailsValidationSchema = Yup.object().shape({
    category: Yup.string().required("Category is Required"),
    subCategory: Yup.string().required("Sub Category is Required"),
    activityName: Yup.string().required("Activity Name is Required"),
    activityDescription: Yup.string().required("Activity Description is Required"),
.  
jaymehta committed
262
    location: Yup.string(),
jaymehta committed
263 264 265 266
    addressLine1: Yup.string().required("Address is Required"),
    addressLine2: Yup.string(),
    pricePerPerson: Yup.string().required("Price Per Person is Required"),
    giftingToSomeone: Yup.string().required("Required field"),
.  
jaymehta committed
267
    place: Yup.string(),
jaymehta committed
268 269 270 271 272 273 274
    activityType: Yup.string().required("Required field"),
    contactPersonForActivity: Yup.string().required("Contact Person Name is Required"),
    minGroupSize: Yup.string().required("Min Group Size is Required"),
    maxGroupSize: Yup.string().required("Max Group Size is Required"),
    months: Yup.array(),
    minDuration: Yup.string().required("Min Duration is Required"),
    maxDuration: Yup.string().required("Max Duration is Required"),
jaymehta committed
275
    durationUnit: Yup.string().required("This is a required field"),
jaymehta committed
276 277 278 279 280 281 282
    ageGroup: Yup.string().required("Age Group is Required"),
    linkOfBooking: Yup.string().required("Link of Booking is Required"),
    activityImages: Yup.array(),
    contactPersonForBooking: Yup.string().required("Contact person is a required field"),
    countryCode: Yup.string(),
    contactNumberForBooking: Yup.string().required("Number is a required field"),
    cancellationPolicyFile: Yup.string(),
jaymehta committed
283 284 285
    termsConditionsFile: Yup.string(),
    activityPeriod: Yup.array().required("Please mention both dates!")
    // availableOnMonday: Yup.bool()
jaymehta committed
286 287 288
  });
  const [pincodeData, setPinCodeData] = useState();
  const [activeDays, setActiveDays] = useState();
jaymehta committed
289 290
  // const [minDisabled, setMinDisabled] = useState(true);
  // const [months, setMonths] = useState(true);
jaymehta committed
291
  const [masterDays, setMasterDays] = useState();
jaymehta committed
292 293 294 295 296 297 298 299 300 301 302 303 304
  // const [timeSlotError, setTimeSlotError] = useState();
  const [activityPeriodState, setActivityPeriodState] = useState([]);
  const [startDate, setStartDate] = useState();
  const [endDate, setEndDate] = useState();
  const [daysBoolean, setDaysBoolean] = useState({
    availableOnMonday: false,
    availableOnTuesday: false,
    availableOnWednesday: false,
    availableOnThursday: false,
    availableOnFriday: false,
    availableOnSaturday: false,
    availableOnSunday: false
  });
jaymehta committed
305 306 307 308 309 310 311 312 313 314
  // const [timeArray, setTimeArray] = useState([]);
  console.log("loggedInVendor", loggedInVendor);
  // const [timeLines, setTimeLines] = useState()
  const ref = useRef(null);
  // let
  const handleSearch = async pin => {
    if (isNaN(pin)) {
      return;
    }
    let pincodeDataSet = await pincodeSearchByFilter(pin);
jaymehta committed
315 316 317 318
    console.log("pincodeDataSet.data.data", pincodeDataSet.data.data);
    // if (pincodeDataSet.data.data.length > 0) {
    //   return { label: "no values available" };
    // }
jaymehta committed
319 320
    setPinCodeData(pincodeDataSet.data.data);
  };
.  
jaymehta committed
321

jaymehta committed
322 323 324
  useEffect(() => {
    dispatch(getLoggedInVendor());
  }, []);
jaymehta committed
325 326 327 328
  useEffect(() => {
    if (isUpdate) {
      ref.current.state.selected = [{ id: activityById?.data.attributes?.masterPincode.data.id, name: activityById?.data.attributes?.masterPincode.data.attributes.name }];
      setDaysBoolean({
jaymehta committed
329 330 331 332 333 334 335
        availableOnSunday: activityById?.data.attributes.availableOnSunday ? activityById?.data.attributes.availableOnSunday : false,
        availableOnMonday: activityById?.data.attributes.availableOnMonday ? activityById?.data.attributes.availableOnMonday : false,
        availableOnTuesday: activityById?.data.attributes.availableOnTuesday ? activityById?.data.attributes.availableOnTuesday : false,
        availableOnWednesday: activityById?.data.attributes.availableOnWednesday ? activityById?.data.attributes.availableOnWednesday : false,
        availableOnThursday: activityById?.data.attributes.availableOnThursday ? activityById?.data.attributes.availableOnThursday : false,
        availableOnFriday: activityById?.data.attributes.availableOnFriday ? activityById?.data.attributes.availableOnFriday : false,
        availableOnSaturday: activityById?.data.attributes.availableOnSaturday ? activityById?.data.attributes.availableOnSaturday : false
jaymehta committed
336 337 338
      });
      setStartDate(activityById?.data.attributes.fromDate);
      setEndDate(activityById?.data.attributes.toDate);
jaymehta committed
339
      setimagesArrayComponent(activityById?.data.attributes.imagesComponent.map(item => item.image.data?.id));
340
      setdisplayImage(activityById?.data.attributes.image?.data?.id);
jaymehta committed
341 342
      setCancellationPolicy(activityById?.data.attributes.cancellationPolicy?.data?.id);
      settermsConditions(activityById?.data.attributes.termsConditions?.data?.id);
jaymehta committed
343 344 345 346 347
    }
  }, []);
  // useEffect(() => {
  //   dispatch(updateActivityById(8))
  // }, [])
jaymehta committed
348
  console.log("pincodeData", pincodeData && pincodeData.length > 0);
.  
jaymehta committed
349
  console.log("activityById", activityById);
jaymehta committed
350
  console.log("activityPeriodState", activityPeriodState);
jaymehta committed
351 352 353 354 355 356
  return (
    <Fragment>
      <div className="container p-1">
        <div className="row">
          <div className="col-12 col-lg-8">
            <div className="content-div business-details">
jaymehta committed
357
              {isUpdate ? <h2>{activityById?.data.attributes.name}</h2> : <div>Add Details</div>}
jaymehta committed
358
              {isUpdate && <ActivityApprovalStatus status={activityById?.data.attributes.approved} />}
jaymehta committed
359 360
              <div className="form-container">
                <Formik
jaymehta committed
361
                  enableReinitialize
jaymehta committed
362
                  initialValues={{
jaymehta committed
363 364 365 366 367 368
                    category: activityById?.data.attributes?.subCategory?.data?.attributes?.category?.data?.attributes?.name
                      ? activityById?.data.attributes?.subCategory?.data?.attributes?.category?.data?.attributes?.name
                      : "",
                    subCategory: activityById?.data.attributes?.subCategory?.data?.attributes.name ? activityById?.data.attributes?.subCategory?.data?.attributes.name : "",
                    activityName: activityById?.data.attributes.name ? activityById?.data.attributes.name : "",
                    activityDescription: activityById?.data.attributes?.description ? activityById?.data.attributes?.description : "",
jaymehta committed
369
                    location: "",
jaymehta committed
370
                    addressLine1: activityById?.data.attributes.address ? activityById?.data.attributes.address : "",
jaymehta committed
371
                    addressLine2: "",
jaymehta committed
372 373 374 375 376 377
                    pricePerPerson: activityById?.data.attributes.pricePerPerson ? activityById?.data.attributes.pricePerPerson : "",
                    giftingToSomeone: activityById?.data.attributes.giftSomeone ? activityById?.data.attributes.giftSomeone : "",
                    place: activityById?.data.attributes.activityType ? activityById?.data.attributes.activityType : "",
                    contactPersonForActivity: activityById?.data.attributes.activityType ? activityById?.data.attributes.activityType : "",
                    minGroupSize: activityById?.data.attributes.minGroupSize ? activityById?.data.attributes.minGroupSize : "",
                    maxGroupSize: activityById?.data.attributes.maxGroupSize ? activityById?.data.attributes.maxGroupSize : "",
jaymehta committed
378
                    months: [],
.  
jaymehta committed
379 380 381 382
                    minDuration: activityById?.data.attributes.minimumDuration ? activityById?.data.attributes.minimumDuration.toString() : "",
                    maxDuration: activityById?.data.attributes.maximumDuration ? activityById?.data.attributes.maximumDuration.toString() : "",
                    durationUnit: activityById?.data.attributes.duration ? activityById?.data.attributes.duration.toString() : "",
                    ageGroup: activityById?.data.attributes.ageLowerLimit ? activityById?.data.attributes.ageLowerLimit.toString() : "",
jaymehta committed
383
                    linkOfBooking: activityById?.data.attributes.link ? activityById?.data.attributes.link : "",
jaymehta committed
384
                    activityImages: [],
jaymehta committed
385
                    contactPersonForBooking: activityById?.data.attributes.contactPersonForBooking ? activityById?.data.attributes.contactPersonForBooking : "",
jaymehta committed
386
                    countryCode: "",
.  
jaymehta committed
387
                    contactNumberForBooking: activityById?.data.attributes.phoneNumber ? activityById?.data.attributes.phoneNumber : "",
jaymehta committed
388
                    cancellationPolicyFile: "",
jaymehta committed
389 390 391
                    termsConditionsFile: "",
                    activityPeriod: [],
                    activityType: activityById?.data.attributes.activityType ? activityById?.data.attributes.activityType : ""
jaymehta committed
392 393 394 395 396
                  }}
                  validationSchema={activityDetailsValidationSchema}
                  // enableReinitialize={true}
                  onSubmit={values => {}}
                >
jaymehta committed
397
                  {({ values, errors, touched, handleChange, handleBlur, handleSubmit, setFieldValue, resetForm }) => (
jaymehta committed
398 399 400 401
                    <Form
                      onSubmit={async e => {
                        e.preventDefault();
                        console.log("activity details values", values);
jaymehta committed
402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417
                        if (
                          !(
                            daysBoolean.availableOnMonday ||
                            daysBoolean.availableOnTuesday ||
                            daysBoolean.availableOnWednesday ||
                            daysBoolean.availableOnThursday ||
                            daysBoolean.availableOnFriday ||
                            daysBoolean.availableOnSaturday ||
                            daysBoolean.availableOnSunday
                          )
                        ) {
                          toast.error("Please select days you will be active on");
                          return;
                        }
                        let fromDate;
                        let toDate;
jaymehta committed
418
                        console.log("timeslots", activityPeriodState, startDate, endDate);
jaymehta committed
419 420 421 422 423
                        if (!startDate || !endDate) {
                          fromDate = sanitizeTimeRange({ data: activityPeriodState[0] });
                          toDate = sanitizeTimeRange({ data: activityPeriodState[1] });
                          if (!activityPeriodState || !activityPeriodState.length > 0) {
                            toast.error("Please select time range");
jaymehta committed
424
                            return;
jaymehta committed
425
                          }
jaymehta committed
426 427 428
                        } else if (startDate && endDate) {
                          fromDate = startDate;
                          toDate = endDate;
jaymehta committed
429
                        }
jaymehta committed
430

jaymehta committed
431 432 433 434 435
                        if (imagesArrayComponent.length < 5) {
                          toast.error("You need to upload 5 images!");
                          return;
                        }

.  
jaymehta committed
436 437 438 439
                        if (!displayImage) {
                          toast.error("You need to upload a display image!");
                          return;
                        }
jaymehta committed
440 441 442
                        handleSubmit();
                        values = {
                          ...values,
jaymehta committed
443 444
                          // timeSlots,
                          // months,
jaymehta committed
445 446 447 448
                          pincode: ref.current.state.selected[0],
                          vendor: loggedInVendor,
                          name: values.activityName,
                          description: values.activityDescription,
.  
jaymehta committed
449
                          address: `${values.addressLine1}`,
jaymehta committed
450 451 452 453 454
                          minimumDuration: values.minDuration,
                          maximumDuration: values.maxDuration,
                          ageLowerLimit: values.ageGroup,
                          phoneNumber: values.contactNumberForBooking,
                          link: values.linkOfBooking,
jaymehta committed
455 456 457 458 459
                          giftSomeone: values.giftingToSomeone,
                          fromDate,
                          toDate,
                          daysBoolean,
                          contactPersonForActivity: values.contactPersonForActivity,
.  
jaymehta committed
460
                          duration: values.durationUnit.toString(),
.  
jaymehta committed
461
                          imagesComponent: imagesArrayComponent,
.  
jaymehta committed
462
                          image: displayImage,
463 464 465
                          approved: "pending",
                          termsConditions: termsConditions,
                          cancellationPolicy: cancellationPolicy
jaymehta committed
466
                        };
.  
jaymehta committed
467 468 469
                        if (!ref.current.state.selected[0]) {
                          toast.error("Please select location!");
                        }
jaymehta committed
470
                        console.log("values 123", values);
jaymehta committed
471 472 473 474
                        if (isUpdate) {
                          console.log("router", router);
                          const updateRes = await dispatch(updateActivityById({ activityId: router.query.id, updatedData: values }));
                          console.log("updateRes", updateRes);
.  
jaymehta committed
475
                          toast.success("Activity sent for approval.");
jaymehta committed
476 477 478 479 480 481 482 483 484 485
                        }
                        if (!isUpdate) {
                          const res = await dispatch(createActivity(values));
                          console.log("res", res);
                          if (res.success) {
                            toast.success("Activity added successfully!");
                            resetForm();
                            setActiveDays([]);
                            // setMonths([]);
                          }
jaymehta committed
486
                        }
.  
jaymehta committed
487
                        dispatch(getActivityById(router.query.id));
jaymehta committed
488 489 490 491 492 493 494 495
                      }}
                    >
                      <div className="activityDetails">
                        <div>
                          <div className="mt-4">
                            <div className="d-flex justify-content-between">
                              <p className="textH">Basic Details</p>
                            </div>
496

jaymehta committed
497 498 499 500 501 502 503 504 505 506 507
                            <div className="row">
                              <div className="col-12 col-lg-6">
                                <div className="input-group">
                                  <label>Category</label>
                                  <select
                                    ref={categoryRef}
                                    value={values.category}
                                    name="category"
                                    onChange={async e => {
                                      handleChange(e);
                                      console.log(categoryRef);
jaymehta committed
508
                                      // console.log("subCategories", categoryRef.current.value);
jaymehta committed
509
                                      await dispatch(getAllSubCategories(categoryRef.current.value));
.  
jaymehta committed
510
                                      setFieldValue("subCategory", "");
511
                                    }}
jaymehta committed
512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590
                                    onBlur={handleBlur}
                                  >
                                    <option value="">Select</option>
                                    {categories &&
                                      categories?.data.length > 0 &&
                                      categories.data.map((item, index) => {
                                        return (
                                          <option key={index} value={item.attributes.name}>
                                            {item.attributes.name}
                                          </option>
                                        );
                                      })}
                                  </select>
                                  {touched.category && errors.category && (
                                    <span className="form-error" style={{ color: "red", fontSize: "10px" }}>
                                      {errors.category}
                                    </span>
                                  )}
                                </div>
                              </div>
                              <div className="col-12 col-lg-6">
                                <div className="input-group">
                                  <label>Sub Category</label>
                                  <select id={`subCategory`} value={values.subCategory} name={`subCategory`} onChange={handleChange} onBlur={handleBlur}>
                                    <option value="">Select</option>
                                    {subCategories &&
                                      subCategories?.data.length > 0 &&
                                      subCategories.data.map((item, index) => {
                                        return (
                                          <option key={index} value={item.value}>
                                            {item.attributes.name}
                                          </option>
                                        );
                                      })}
                                  </select>
                                  {touched.subCategory && errors.subCategory && (
                                    <span className="form-error" style={{ color: "red", fontSize: "10px" }}>
                                      {errors.subCategory}
                                    </span>
                                  )}
                                </div>
                              </div>
                            </div>
                            <div className="row">
                              <div className="col-12 col-lg-6">
                                <div className="input-group">
                                  <label>Activity Name</label>
                                  <input type="text" name={`activityName`} onChange={handleChange} onBlur={handleBlur} value={values.activityName} />
                                  {touched.activityName && errors.activityName && (
                                    <span className="form-error" style={{ color: "red", fontSize: "10px" }}>
                                      {errors.activityName}
                                    </span>
                                  )}
                                </div>
                              </div>
                              <div className="col-12 col-lg-6">
                                <div className="input-group">
                                  <label>Activity Description</label>
                                  <textarea rows="4" name={`activityDescription`} onChange={handleChange} onBlur={handleBlur} value={values.activityDescription} />
                                  {touched.activityDescription && errors.activityDescription && (
                                    <span className="form-error" style={{ color: "red", fontSize: "10px" }}>
                                      {errors.activityDescription}
                                    </span>
                                  )}
                                </div>
                              </div>
                            </div>
                            <div className="row">
                              <div className="col-12 col-lg-6">
                                <div className="input-group">
                                  <label>Location</label>
                                  <AsyncTypeahead
                                    type="number"
                                    onSearch={handleSearch}
                                    minLength={3}
                                    value={values.location}
                                    id="basic-behaviors-example"
                                    labelKey="name"
                                    options={
jaymehta committed
591 592 593 594 595
                                      pincodeData && pincodeData.length > 0
                                        ? pincodeData.map(item => {
                                            return { name: item.attributes.name, id: item.id };
                                          })
                                        : [{}]
jaymehta committed
596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635
                                    }
                                    placeholder="Choose a pincode"
                                    ref={ref}
                                    onBlur={() => {
                                      console.log(ref.current);
                                      if (!ref.current.state.selected.length > 0) {
                                        ref.current?.clear();
                                      }
                                    }}
                                    onChange={e => {
                                      console.log("input change", e);
                                      // handleChange(e);
                                    }}
                                  />
                                </div>
                              </div>
                              <div className="col-12 col-lg-6">
                                <div className="input-group">
                                  <label>Price (per person)</label>
                                  <input type="text" name={`pricePerPerson`} onChange={handleChange} onBlur={handleBlur} value={values.pricePerPerson} />
                                  {touched.pricePerPerson && errors.pricePerPerson && (
                                    <span className="form-error" style={{ color: "red", fontSize: "10px" }}>
                                      {errors.pricePerPerson}
                                    </span>
                                  )}
                                </div>
                              </div>
                            </div>
                            <div className="row">
                              <div className="col-12 col-lg-6">
                                <div className="input-group">
                                  <label>Address Line 1</label>
                                  <input type="text" name={`addressLine1`} onChange={handleChange} onBlur={handleBlur} value={values.addressLine1} />
                                  {touched.addressLine1 && errors.addressLine1 && (
                                    <span className="form-error" style={{ color: "red", fontSize: "10px" }}>
                                      {errors.addressLine1}
                                    </span>
                                  )}
                                </div>
                              </div>
.  
jaymehta committed
636
                              {/* <div className="col-12 col-lg-6">
jaymehta committed
637 638 639 640
                                <div className="input-group">
                                  <label>Address Line 2</label>
                                  <input type="text" name={`addressLine2`} onChange={handleChange} onBlur={handleBlur} value={values.addressLine2} />
                                </div>
.  
jaymehta committed
641
                              </div> */}
jaymehta committed
642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660
                            </div>
                            <div className="row">
                              <div className="col-12 col-lg-6">
                                <div className="input-group mb-2">
                                  <label>Gifting to Someone</label>
                                  <div className="row">
                                    <div className="col-12 col-lg-12">
                                      <select id="giftingToSomeone" name="giftingToSomeone" value={values.giftingToSomeone} onChange={handleChange} onBlur={handleBlur}>
                                        {" "}
                                        Gift someone
                                        <option value="">Select</option>
                                        <option value={true}>Yes</option>
                                        <option value={false}>No</option>
                                      </select>
                                    </div>
                                    {touched.giftingToSomeone && errors.giftingToSomeone && (
                                      <span className="form-error" style={{ color: "red", fontSize: "10px" }}>
                                        {errors.giftingToSomeone}
                                      </span>
661
                                    )}
jaymehta committed
662 663 664 665 666
                                  </div>
                                </div>
                              </div>
                              <div className="col-12 col-lg-6">
                                <div className="input-group mb-2">
jaymehta committed
667
                                  <label>Activity Type</label>
jaymehta committed
668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727
                                  <div className="row">
                                    <div className="">
                                      <div className="col-12 col-lg-12">
                                        <select id="activityType" name="activityType" onChange={handleChange} onBlur={handleBlur} value={values.activityType}>
                                          {" "}
                                          Activity Type
                                          <option value="">Select</option>
                                          <option value={"indoor"}>Indoor</option>
                                          <option value={"outdoor"}>Outdoor</option>
                                        </select>
                                      </div>
                                      {touched.activityType && errors.activityType && (
                                        <span className="form-error" style={{ color: "red", fontSize: "10px" }}>
                                          {errors.activityType}
                                        </span>
                                      )}
                                    </div>
                                  </div>
                                </div>
                              </div>
                            </div>
                          </div>
                          <hr />
                          <div className="mt-4">
                            <p className="textH">Group Information</p>
                            <div className="row">
                              <div className="col-12 col-lg-6">
                                <div className="input-group">
                                  <label>Contact Person for the Activity</label>
                                  <input type="text" name={`contactPersonForActivity`} onChange={handleChange} onBlur={handleBlur} value={values.contactPersonForActivity} />
                                  {touched.contactPersonForActivity && errors.contactPersonForActivity && (
                                    <span className="form-error" style={{ color: "red", fontSize: "10px" }}>
                                      {errors.contactPersonForActivity}
                                    </span>
                                  )}
                                </div>
                              </div>
                              <div className="col-12 col-lg-6">
                                <div className="input-group">
                                  <label>Size of the Group</label>
                                  <div className="row">
                                    <div className="col-6 col-lg-5">
                                      <input type="text" placeholder="Min." name={`minGroupSize`} onChange={handleChange} onBlur={handleBlur} value={values.minGroupSize} />
                                      {touched.minGroupSize && errors.minGroupSize && (
                                        <span className="form-error" style={{ color: "red", fontSize: "10px" }}>
                                          {errors.minGroupSize}
                                        </span>
                                      )}
                                    </div>
                                    <div className="col-6 col-lg-5">
                                      <input type="text" placeholder="Max." name={`maxGroupSize`} onChange={handleChange} onBlur={handleBlur} value={values.maxGroupSize} />
                                      {touched.maxGroupSize && errors.maxGroupSize && (
                                        <span className="form-error" style={{ color: "red", fontSize: "10px" }}>
                                          {errors.maxGroupSize}
                                        </span>
                                      )}
                                    </div>
                                  </div>
                                </div>
                              </div>
728
                            </div>
jaymehta committed
729 730 731 732 733
                          </div>
                          <hr />
                          <div className="mt-4">
                            <p className="textH">Availability</p>
                            <div className="row">
jaymehta committed
734
                              <div className="col-md-12 ">
jaymehta committed
735
                                <div className="input-group">
jaymehta committed
736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774
                                  <span className="col-md-12 my-1">Start date and end date of the activity:</span>
                                  <LazyLoad>
                                    {isUpdate ? (
                                      <RangePicker
                                        id="activityPeriod"
                                        name="activityPeriod"
                                        defaultValue={[
                                          dayjs(activityById?.data.attributes.fromDate ? activityById?.data.attributes.fromDate : sanitizedCurrentDate, dateFormat),
                                          dayjs(activityById?.data.attributes.toDate ? activityById?.data.attributes.toDate : sanitizedCurrentDate, dateFormat)
                                        ]}
                                        format={dateFormat}
                                        onBlur={() => {
                                          if (true) {
                                          }
                                        }}
                                        onChange={e => {
                                          console.log("change", e);
                                          setActivityPeriodState(e);
                                          // handleChange(e);
                                        }}
                                      />
                                    ) : (
                                      <RangePicker
                                        id="activityPeriod"
                                        name="activityPeriod"
                                        format={dateFormat}
                                        onBlur={() => {
                                          if (true) {
                                          }
                                        }}
                                        onChange={e => {
                                          console.log("change", e);
                                          setActivityPeriodState(e);
                                          // handleChange(e);
                                        }}
                                      />
                                    )}
                                  </LazyLoad>
                                  {touched.activityPeriod && errors.activityPeriod && (
jaymehta committed
775
                                    <span className="form-error" style={{ color: "red", fontSize: "10px" }}>
jaymehta committed
776
                                      {errors.activityPeriod}
jaymehta committed
777
                                    </span>
jaymehta committed
778
                                  )}
jaymehta committed
779 780 781
                                </div>
                              </div>

jaymehta committed
782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803
                              <div className="col-md-12 ">
                                <div className="row">
                                  <label>Active on days:</label>
                                  <div className="col-6 my-2">
                                    <div className="d-flex">
                                      <span className="col-md-6">Select all:</span>
                                      <Switch
                                        // style={{ backgroundColor: "green" }}
                                        className="col-md-4"
                                        value={
                                          daysBoolean.availableOnMonday &&
                                          daysBoolean.availableOnTuesday &&
                                          daysBoolean.availableOnWednesday &&
                                          daysBoolean.availableOnThursday &&
                                          daysBoolean.availableOnFriday &&
                                          daysBoolean.availableOnSaturday &&
                                          daysBoolean.availableOnSunday
                                        }
                                        id={"availableOnMonday"}
                                        name="availableOnMonday"
                                        onChange={e => {
                                          setDaysBoolean({
jaymehta committed
804 805 806 807 808 809 810
                                            availableOnMonday: e === true ? true : false,
                                            availableOnTuesday: e === true ? true : false,
                                            availableOnWednesday: e === true ? true : false,
                                            availableOnThursday: e === true ? true : false,
                                            availableOnFriday: e === true ? true : false,
                                            availableOnSaturday: e === true ? true : false,
                                            availableOnSunday: e === true ? true : false
jaymehta committed
811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828
                                          });
                                          // setDaysBoolean({ ...daysBoolean, availableOnMonday: e });
                                          // console.log("availableOnMonday", daysBoolean);
                                        }}
                                        checkedChildren="Active"
                                        unCheckedChildren="Not Active"
                                      />
                                    </div>
                                  </div>
                                  <div className="col-6 my-2">
                                    <div className="d-flex">
                                      <span className="col-md-6">Monday:</span>
                                      <Switch
                                        className="col-md-4"
                                        value={daysBoolean.availableOnMonday}
                                        id={"availableOnMonday"}
                                        name="availableOnMonday"
                                        onChange={e => {
jaymehta committed
829
                                          setDaysBoolean({ ...daysBoolean, availableOnMonday: e === true ? true : false });
jaymehta committed
830 831 832 833 834 835 836 837 838 839 840 841 842 843
                                          console.log("availableOnMonday", daysBoolean);
                                        }}
                                        checkedChildren="Active"
                                        unCheckedChildren="Not Active"
                                      />
                                    </div>
                                  </div>
                                  <div className="col-6 my-2">
                                    <div className="d-flex">
                                      <span className="col-md-6">Tuesday:</span>
                                      <Switch
                                        className="col-md-4"
                                        value={daysBoolean.availableOnTuesday}
                                        onChange={e => {
jaymehta committed
844
                                          setDaysBoolean({ ...daysBoolean, availableOnTuesday: e === true ? true : false });
jaymehta committed
845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862
                                          // console.log("availableOnTuesday", daysBoolean);
                                        }}
                                        id={"availableOnTuesday"}
                                        // onChange={handleChange}
                                        checkedChildren="Active"
                                        unCheckedChildren="Not Active"
                                      />
                                    </div>
                                  </div>
                                  <div className="col-6 my-2">
                                    <div className="d-flex">
                                      <span className="col-md-6">Wednesday:</span>
                                      <Switch
                                        className="col-md-4"
                                        value={daysBoolean.availableOnWednesday}
                                        id={"availableOnWednesday"}
                                        // onChange={handleChange}
                                        onChange={e => {
jaymehta committed
863
                                          setDaysBoolean({ ...daysBoolean, availableOnWednesday: e === true ? true : false });
jaymehta committed
864 865 866 867 868 869 870 871 872 873 874 875 876 877 878
                                          // console.log("availableOnTuesday", daysBoolean);
                                        }}
                                        checkedChildren="Active"
                                        unCheckedChildren="Not Active"
                                      />
                                    </div>
                                  </div>
                                  <div className="col-6 my-2">
                                    <div className="d-flex">
                                      <span className="col-md-6">Thursday:</span>
                                      <Switch
                                        className="col-md-4"
                                        value={daysBoolean.availableOnThursday}
                                        id={"availableOnThursday"}
                                        onChange={e => {
jaymehta committed
879
                                          setDaysBoolean({ ...daysBoolean, availableOnThursday: e === true ? true : false });
jaymehta committed
880 881 882 883 884 885 886 887 888 889 890 891 892 893 894
                                          // console.log("availableOnTuesday", daysBoolean);
                                        }}
                                        checkedChildren="Active"
                                        unCheckedChildren="Not Active"
                                      />
                                    </div>
                                  </div>
                                  <div className="col-6 my-2">
                                    <div className="d-flex">
                                      <span className="col-md-6">Friday:</span>
                                      <Switch
                                        className="col-md-4"
                                        value={daysBoolean.availableOnFriday}
                                        id={"availableOnFriday"}
                                        onChange={e => {
jaymehta committed
895
                                          setDaysBoolean({ ...daysBoolean, availableOnFriday: e === true ? true : false });
jaymehta committed
896 897 898 899 900 901 902 903 904 905 906 907 908 909 910
                                          // console.log("availableOnTuesday", daysBoolean);
                                        }}
                                        checkedChildren="Active"
                                        unCheckedChildren="Not Active"
                                      />
                                    </div>
                                  </div>
                                  <div className="col-6 my-2">
                                    <div className="d-flex">
                                      <span className="col-md-6">Saturday:</span>
                                      <Switch
                                        className="col-md-4"
                                        value={daysBoolean.availableOnSaturday}
                                        id={"availableOnSaturday"}
                                        onChange={e => {
jaymehta committed
911
                                          setDaysBoolean({ ...daysBoolean, availableOnSaturday: e === true ? true : false });
jaymehta committed
912 913 914 915 916 917 918 919 920 921 922 923 924 925 926
                                          // console.log("availableOnTuesday", daysBoolean);
                                        }}
                                        checkedChildren="Active"
                                        unCheckedChildren="Not Active"
                                      />
                                    </div>
                                  </div>
                                  <div className="col-6 my-2">
                                    <div className="d-flex">
                                      <span className="col-md-6">Sunday:</span>
                                      <Switch
                                        className="col-md-4"
                                        value={daysBoolean.availableOnSunday}
                                        id={"availableOnSunday"}
                                        onChange={e => {
jaymehta committed
927
                                          setDaysBoolean({ ...daysBoolean, availableOnSunday: e === true ? true : false });
jaymehta committed
928 929 930 931 932 933
                                          // console.log("availableOnTuesday", daysBoolean);
                                        }}
                                        checkedChildren="Active"
                                        unCheckedChildren="Not Active"
                                      />
                                    </div>
jaymehta committed
934 935 936 937
                                  </div>
                                </div>
                              </div>
                            </div>
jaymehta committed
938 939

                            <div className="row mt-5">
jaymehta committed
940 941 942
                              <div className="col-12 col-lg-6">
                                <div className="input-group">
                                  <div className="row">
jaymehta committed
943 944
                                    <div className="col-2 col-lg-4">
                                      <label>Total duration (in Mins)</label>
.  
jaymehta committed
945 946 947 948 949 950 951 952 953
                                      <input
                                        value={values.durationUnit}
                                        type="number"
                                        id="durationUnit"
                                        name="durationUnit"
                                        onChange={handleChange}
                                        onBlur={handleBlur}
                                        style={{ width: "100%" }}
                                      ></input>
jaymehta committed
954 955
                                      {errors.durationUnit && touched.durationUnit && <span className="form-error">{errors.durationUnit}</span>}
                                    </div>
jaymehta committed
956
                                    <div className="col-5 col-lg-4">
jaymehta committed
957
                                      <label>Minimum duration</label>
.  
jaymehta committed
958
                                      <input value={values.minDuration} id="minDuration" name="minDuration" onChange={handleChange} onBlur={handleBlur}></input>
jaymehta committed
959 960 961 962 963 964
                                      {touched.minDuration && errors.minDuration && (
                                        <span className="form-error" style={{ color: "red", fontSize: "10px" }}>
                                          {errors.minDuration}
                                        </span>
                                      )}
                                    </div>
jaymehta committed
965

jaymehta committed
966
                                    <div className="col-2 col-lg-4">
jaymehta committed
967
                                      <label>Maximum duration</label>
.  
jaymehta committed
968 969 970 971 972 973 974 975
                                      <input
                                        value={values.maxDuration}
                                        id="maxDuration"
                                        name="maxDuration"
                                        onChange={handleChange}
                                        onBlur={handleBlur}
                                        style={{ width: "100%" }}
                                      ></input>
jaymehta committed
976
                                      {errors.maxDuration && touched.maxDuration && <span className="form-error">{errors.maxDuration}</span>}
jaymehta committed
977 978 979 980 981 982 983
                                    </div>
                                  </div>
                                </div>
                              </div>
                              <div className="col-12 col-lg-6">
                                <div className="input-group">
                                  <label>Age Group</label>
.  
jaymehta committed
984
                                  <select value={values.ageGroup} id={"ageGroup"} name={"ageGroup"} onChange={handleChange} onBlur={handleBlur}>
jaymehta committed
985
                                    <option value="">Select</option>
jaymehta committed
986 987 988 989 990
                                    <option value="5">5+</option>
                                    <option value="10">10+</option>
                                    <option value="15">15+</option>
                                    <option value="20">20+</option>
                                    <option value="25">25+</option>
jaymehta committed
991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055
                                  </select>
                                  {touched.ageGroup && errors.ageGroup && (
                                    <span className="form-error" style={{ color: "red", fontSize: "10px" }}>
                                      {errors.ageGroup}
                                    </span>
                                  )}
                                </div>
                              </div>
                            </div>
                          </div>
                          <hr />
                          <div className="mt-4">
                            <p className="textH">Booking & Activity Information</p>
                            <div className="row">
                              <div className="col-12 col-lg-6">
                                <div className="input-group">
                                  <label>Link of Booking</label>
                                  <input type="text" name={`linkOfBooking`} onChange={handleChange} onBlur={handleBlur} value={values.linkOfBooking} />
                                  {touched.linkOfBooking && errors.linkOfBooking && (
                                    <span className="form-error" style={{ color: "red", fontSize: "10px" }}>
                                      {errors.linkOfBooking}
                                    </span>
                                  )}
                                </div>
                              </div>
                            </div>
                            <div className="row">
                              <div className="col-12 col-lg-6">
                                <div className="input-group">
                                  <label>Contact Person Name</label>
                                  <input type="text" name={`contactPersonForBooking`} onChange={handleChange} onBlur={handleBlur} value={values.contactPersonForBooking} />
                                  {touched.contactPersonForBooking && errors.contactPersonForBooking && (
                                    <span className="form-error" style={{ color: "red", fontSize: "10px" }}>
                                      {errors.contactPersonForBooking}
                                    </span>
                                  )}
                                </div>
                              </div>
                              <div className="col-12 col-lg-6">
                                <div className="input-group">
                                  <label>Contact Person Number</label>
                                  <div className="contact-number">
                                    <select id={`countryCode`} name={`countryCode`} onChange={handleChange} onBlur={handleBlur} style={{ width: "80px" }}>
                                      <option value="+91">+91</option>
                                      <option value="+44">+44</option>
                                    </select>
                                    <input type="text" name={`contactNumberForBooking`} onChange={handleChange} onBlur={handleBlur} value={values.contactNumberForBooking} />
                                  </div>
                                  {touched.contactNumberForBooking && errors.contactNumberForBooking && (
                                    <span className="form-error" style={{ color: "red", fontSize: "10px" }}>
                                      {errors.contactNumberForBooking}
                                    </span>
                                  )}
                                </div>
                              </div>
                            </div>
                          </div>
                          <hr />
                          <div className="mt-4">
                            <p className="textH">Policy & Terms</p>
                            <div className="row">
                              <div className="col-12 col-lg-6">
                                <div className="input-group">
                                  <label>Cancellation Policy</label>
                                  <div className="custom-file">
.  
jaymehta committed
1056 1057 1058 1059 1060 1061 1062
                                    <UploadImageCustom
                                      isUpdate={isUpdate}
                                      setImage={setCancellationPolicy}
                                      populatedImages={activityById?.data.attributes.termsConditions}
                                      isPdf={true}
                                    />
                                    {console.log("cancellationPolicy", cancellationPolicy, termsConditions)}
jaymehta committed
1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080
                                  </div>
                                  {values.cancellationPolicyFile && (
                                    <div className="d-flex align-items-center justify-content-between p-1" style={{ width: "100%" }}>
                                      <p className="textS m-0">{values.cancellationPolicyFile.name}</p>
                                      <FaTimes
                                        style={{ cursor: "pointer" }}
                                        onClick={() => {
                                          setFieldValue(`cancellationPolicyFile`, "");
                                        }}
                                      />
                                    </div>
                                  )}
                                </div>
                              </div>
                              <div className="col-12 col-lg-6">
                                <div className="input-group">
                                  <label>Terms & Conditions</label>
                                  <div className="custom-file">
.  
jaymehta committed
1081 1082 1083 1084 1085 1086
                                    <UploadImageCustom
                                      isUpdate={isUpdate}
                                      setImage={settermsConditions}
                                      populatedImages={activityById?.data.attributes.cancellationPolicy}
                                      isPdf={true}
                                    />
jaymehta committed
1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102
                                  </div>
                                  {values.termsConditionsFile && (
                                    <div className="d-flex align-items-center justify-content-between p-1" style={{ width: "100%" }}>
                                      <p className="textS m-0">{values.termsConditionsFile.name}</p>
                                      <FaTimes
                                        style={{ cursor: "pointer" }}
                                        onClick={() => {
                                          setFieldValue(`termsConditionsFile`, "");
                                        }}
                                      />
                                    </div>
                                  )}
                                </div>
                              </div>
                            </div>
                          </div>
jaymehta committed
1103 1104 1105 1106
                          <hr />
                        </div>
                        <div className="row d-flex mt-4">
                          <p className="textH">Add display image</p>
jaymehta committed
1107 1108
                          {/* {console.log(displayImage)} */}
                          <UploadImageCustom isUpdate={isUpdate} setImage={setdisplayImage} populatedImages={activityById?.data.attributes.image} />
jaymehta committed
1109
                          <hr />
1110
                        </div>
jaymehta committed
1111
                        <div className="row d-flex ">
jaymehta committed
1112
                          <p className="textH">Add other images</p>
jaymehta committed
1113 1114 1115 1116 1117
                          <div className="col-2">
                            <ImageUploadPopUp
                              isUpdate={isUpdate}
                              setimagesArrayComponent={setimagesArrayComponent}
                              imagesArrayComponent={imagesArrayComponent}
jaymehta committed
1118
                              populatedImages={activityById?.data.attributes.imagesComponent[0]}
jaymehta committed
1119 1120 1121 1122 1123 1124 1125
                            />
                          </div>
                          <div className="col-2">
                            <ImageUploadPopUp
                              isUpdate={isUpdate}
                              setimagesArrayComponent={setimagesArrayComponent}
                              imagesArrayComponent={imagesArrayComponent}
jaymehta committed
1126
                              populatedImages={activityById?.data.attributes.imagesComponent[1]}
jaymehta committed
1127 1128 1129 1130 1131 1132 1133
                            />
                          </div>
                          <div className="col-2">
                            <ImageUploadPopUp
                              isUpdate={isUpdate}
                              setimagesArrayComponent={setimagesArrayComponent}
                              imagesArrayComponent={imagesArrayComponent}
jaymehta committed
1134
                              populatedImages={activityById?.data.attributes.imagesComponent[2]}
jaymehta committed
1135 1136 1137 1138 1139 1140 1141
                            />
                          </div>
                          <div className="col-2">
                            <ImageUploadPopUp
                              isUpdate={isUpdate}
                              setimagesArrayComponent={setimagesArrayComponent}
                              imagesArrayComponent={imagesArrayComponent}
jaymehta committed
1142
                              populatedImages={activityById?.data.attributes.imagesComponent[3]}
jaymehta committed
1143 1144 1145 1146 1147 1148 1149
                            />
                          </div>
                          <div className="col-2">
                            <ImageUploadPopUp
                              isUpdate={isUpdate}
                              setimagesArrayComponent={setimagesArrayComponent}
                              imagesArrayComponent={imagesArrayComponent}
jaymehta committed
1150
                              populatedImages={activityById?.data.attributes.imagesComponent[4]}
jaymehta committed
1151 1152 1153
                            />
                          </div>
                        </div>
.  
jaymehta committed
1154
                        {console.log("setimagesArrayComponent", imagesArrayComponent)}
.  
jaymehta committed
1155 1156 1157
                        <br />
                        <>
                          {/* <button
jaymehta committed
1158 1159 1160 1161 1162 1163
                            onClick={e => {
                              e.preventDefault();
                              setshowImageUploadModal(true);
                            }}
                          >
                            Open{" "}
.  
jaymehta committed
1164 1165 1166 1167 1168
                          </button> */}
                          {/* <br />
                          <br /> */}
                        </>
                        {console.log("errors", errors)}
jaymehta committed
1169
                        <div className="row">
.  
jaymehta committed
1170
                          <div className="col-6 col-lg-5">
jaymehta committed
1171
                            <div className="input-group">
.  
jaymehta committed
1172
                              <Button type="submit" className="btn btn-primary btn-submit" disabled={Object.keys(errors).length > 0}>
jaymehta committed
1173 1174
                                Submit
                              </Button>
.  
jaymehta committed
1175 1176 1177 1178
                            </div>
                          </div>
                          <div className="col-6 col-lg-5">
                            <div className="input-group">
jaymehta committed
1179 1180 1181 1182 1183 1184
                              <Button
                                onClick={() => {
                                  router.push("/vendor/activities");
                                }}
                                className="btn btn-primary btn-submit"
                              >
.  
jaymehta committed
1185 1186
                                See all activities
                              </Button>
jaymehta committed
1187 1188
                            </div>
                          </div>
1189
                        </div>
jaymehta committed
1190 1191 1192 1193 1194 1195 1196
                      </div>
                    </Form>
                  )}
                </Formik>
              </div>
            </div>
          </div>
.  
jaymehta committed
1197
          {/* <Modal show={showImageUploadModal} centered onHide={() => setshowImageUploadModal()}>
jaymehta committed
1198 1199 1200
            <Modal.Header closeButton>Add Images</Modal.Header>
            <Modal.Body>
            </Modal.Body>
.  
jaymehta committed
1201
          </Modal> */}
jaymehta committed
1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226
          <div className="col-12 col-lg-4">
            <div className="content-div help-center">
              <h2>Help Center</h2>
              <ul className="helplist">
                <li>
                  <img src="/images/vendor/question.svg" className="img-fluid" />
                  <p>Lorem Ipsum Dolor Sit?</p>
                </li>
                <li>
                  <img src="/images/vendor/question.svg" className="img-fluid" />
                  <p>Lorem Ipsum Dolor Sit?</p>
                </li>
                <li>
                  <img src="/images/vendor/question.svg" className="img-fluid" />
                  <p>Lorem Ipsum Dolor Sit?</p>
                </li>
                <li>
                  <img src="/images/vendor/question.svg" className="img-fluid" />
                  <p>Lorem Ipsum Dolor Sit?</p>
                </li>
                <li>
                  <img src="/images/vendor/call.svg" className="img-fluid" />
                  <p>+1 (407) 8798 789</p>
                </li>
              </ul>
1227
            </div>
jaymehta committed
1228 1229 1230 1231 1232 1233
          </div>
        </div>
      </div>
    </Fragment>
  );
};
1234

Jyotsna committed
1235
const AccordionItem = ({ index, expanded, toggleAccordion, remove, children }) => {
jaymehta committed
1236 1237 1238 1239 1240 1241
  return (
    <div>
      <div className="d-flex align-items-center justify-content-between" onClick={toggleAccordion} style={{ cursor: "pointer" }}>
        <p className="textH mb-0">Activity Name {index + 1}</p>
        <div>{expanded ? <Image alt="" width="24" height="24" src="/images/vendor/minus.svg" /> : <Image alt="" width="24" height="24" src="/images/vendor/plus.svg" />}</div>
      </div>
Jyotsna committed
1242

jaymehta committed
1243 1244 1245
      <div style={{ display: expanded ? "block" : "none" }}>{children}</div>
    </div>
  );
Jyotsna committed
1246 1247
};

jaymehta committed
1248
export default ActivityDetails;