Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 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 138 139 140 141 142 143 144 145 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 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 | 45x 45x 45x 45x 45x 45x 45x 45x 45x 45x 45x 45x 45x 161x 161x 161x 161x 45x 133x 133x 133x 6x 6x 6x 6x 6x 6x 127x 127x 127x 133x 30x 30x 103x 103x 9x 9x 94x 94x 133x | import CheckoutStep from "@sections/PayBuilder/Checkout/CheckoutStep";
import About from "@sections/PayBuilder/Forms/About/About";
import { Styling } from "@sections/PayBuilder/Forms/Styling/Styling";
import PaymentFormItems from "@sections/PayBuilder/items/PaymentFormItems";
import { CampaignMapperValues } from "features/Minibuilders/PaymentFormMinibuilder/useCreateCampaignFn";
import LaunchStep from "@sections/PayBuilder/LaunchStep/LaunchStep";
import { views } from "./views";
import FundraiserAbout from "@sections/PayBuilder/Forms/About/FundraiserAbout";
import FundraiserCheckoutStep from "@sections/PayBuilder/Checkout/FundraisersCheckoutStep";
import {
endsAtValidationSchema,
locationURLValidationSchema,
startsAtValidationSchema,
} from "@sections/PayBuilder/provider/useManagePayFormProvider";
import { SweepstakeAbout } from "@sections/PayBuilder/Forms/About/SweepstakeAbout";
import InvoiceAbout from "@sections/PayBuilder/Forms/About/Invoice/InvoiceAbout";
import { FormType } from "@sections/PayBuilder/utils";
import InvoiceSendStep from "@sections/PayBuilder/LaunchStep/InvoiceSendStep";
const standardSteps = [
{ label: "Details", id: "product_creation" },
{ label: "Items", id: "variants_creation" },
{ label: "Style", id: "style_configuration" },
{ label: "Checkout", id: "checkout_configuration" },
];
const fundraiserSteps = [
{ label: "Details", id: "product_creation" },
{ label: "Style", id: "style_configuration" },
{ label: "Donation", id: "checkout_configuration" },
];
const eventsSteps = [
{ label: "Details", id: "product_creation" },
{ label: "Tickets", id: "variants_creation" },
{ label: "Style", id: "style_configuration" },
{ label: "Checkout", id: "checkout_configuration" },
];
const membershipSteps = [
{ label: "Details", id: "product_creation" },
{ label: "Memberships", id: "variants_creation" },
{ label: "Style", id: "style_configuration" },
{ label: "Checkout", id: "checkout_configuration" },
];
const sweepstakeSteps = [
{ label: "Details", id: "product_creation" },
{ label: "Style", id: "style_configuration" },
{ label: "Entries", id: "checkout_configuration" },
];
const invoiceSteps = [
{ label: "Details", id: "product_creation" },
{ label: "Style", id: "style_configuration" },
];
const standardFormStep = [About, PaymentFormItems, Styling, CheckoutStep];
const eventFormStep = [About, PaymentFormItems, Styling, CheckoutStep];
const fundraiserFormStep = [FundraiserAbout, Styling, FundraiserCheckoutStep];
const membershipFormStep = [About, PaymentFormItems, Styling, CheckoutStep];
const invoiceFormStep = [InvoiceAbout, Styling];
const steps: Record<
CampaignMapperValues | "standard",
{
steps: { label: string; id: string }[];
formStep: any[];
}
> = {
standard: {
steps: standardSteps,
formStep: standardFormStep,
},
product: {
steps: standardSteps,
formStep: standardFormStep,
},
fundraiser: {
steps: fundraiserSteps,
formStep: fundraiserFormStep,
},
event: {
steps: eventsSteps,
formStep: eventFormStep,
},
invoice: {
steps: invoiceSteps,
formStep: invoiceFormStep,
},
membership: {
steps: membershipSteps,
formStep: membershipFormStep,
},
sweepstake: {
steps: sweepstakeSteps,
formStep: [SweepstakeAbout, Styling, FundraiserCheckoutStep],
},
};
export const generateStepsArray = (
isLaunchVisible = true,
type: CampaignMapperValues = "product",
) => {
const isInvoice = type === FormType.INVOICES;
const formType = type || "product";
const currentSteps = steps[formType] || steps["product"];
return {
steps: [
...(currentSteps?.steps || []),
...(isLaunchVisible
? [{ label: isInvoice ? "Send" : "Publish", id: "launch" }]
: []),
],
formStep: [
...(currentSteps?.formStep || []),
isInvoice ? InvoiceSendStep : LaunchStep,
],
previewStep: (views as any)[formType] ?? "standard", //for jest
};
};
export const isEventNextDisabled = ({
values,
errors,
isEdit,
}: {
values: any;
errors: any;
isEdit: boolean;
}) => {
let isNextDisabled = false;
let isNextDisbaledBecauseOfLocation = false;
// check timeActiveTab validations
if (values.DateLocation.timeActiveTab === "range") {
//we have a change request that on edit we should be able to edit the event even if the start date is in the past
const isStartValidDate = isEdit
? true
: startsAtValidationSchema().isValidSync(values.DateLocation?.startsAt);
const isEndValidDate = endsAtValidationSchema.isValidSync(
values.DateLocation?.endsAt,
);
const isInvalidStartTime = Boolean(
values.DateLocation?.includeTime && errors.DateLocation?.startsAtTime,
);
const isInvalidEndTime = Boolean(
values.DateLocation?.includeTime && errors.DateLocation?.endsAtTime,
);
const isInvalidTime = isInvalidStartTime || isInvalidEndTime;
isNextDisabled =
!isStartValidDate ||
Boolean(errors.DateLocation?.startsAt) ||
!isEndValidDate ||
Boolean(errors.DateLocation?.endsAt) ||
isInvalidTime;
} else {
const isValidDate = startsAtValidationSchema().isValidSync(
values.DateLocation?.startsAt,
);
const isInvalidTime = Boolean(
values.DateLocation?.includeTime && errors.DateLocation?.startsAtTime,
);
isNextDisabled =
!isValidDate || !!errors.DateLocation?.startsAt || isInvalidTime;
}
if (values.DateLocation.locationPosition === "online") {
const isValidLocationURL = locationURLValidationSchema.isValidSync(
values.DateLocation.locationURL,
);
isNextDisbaledBecauseOfLocation =
!isValidLocationURL ||
!!errors.DateLocation?.locationURL ||
!values.DateLocation?.locationURL?.length;
} else Eif (values.DateLocation.locationPosition === "onsite") {
if (values.DateLocation?.isManualAddress) {
// const isValidLocation = locationAddressSchema.isValidSync(
// values.DateLocation?.locationAddress,
// { recursive: true },
// );
//using YUP doesn work
const isValidLocation =
values.DateLocation?.locationAddress.line1 &&
values.DateLocation?.locationAddress.city &&
(values.DateLocation?.locationAddress.state ||
values.DateLocation?.locationAddress.country !== "US") && //for country's outside US the state is nullable
values.DateLocation?.locationAddress.zip &&
values.DateLocation?.locationAddress.country;
isNextDisbaledBecauseOfLocation =
!isValidLocation || !!errors.DateLocation?.locationAddress;
} else {
const isValidLocationShort = Boolean(
values.DateLocation.locationShortAddress,
);
isNextDisbaledBecauseOfLocation =
!isValidLocationShort || !!errors.DateLocation?.locationShortAddress;
}
}
return isNextDisabled || isNextDisbaledBecauseOfLocation;
};
|