fixed: added array guards in mergedServices to stop iterable error

This commit is contained in:
pramod.mahajan 2025-12-11 10:25:45 +05:30
parent 23660379c9
commit e755faecdc

View File

@ -33,8 +33,11 @@ const AssignOrg = ({ setStep }) => {
}); });
const isPending = isPendingProject || isPendingTenat; const isPending = isPendingProject || isPendingTenat;
const mergedServices = useMemo(() => { const mergedServices = useMemo(() => {
if (!masterService || !projectServices) return []; const master = Array.isArray(masterService?.data) ? masterService.data : [];
const combined = [...masterService?.data, ...projectServices]; const project = Array.isArray(projectServices) ? projectServices : [];
const combined = [...master, ...project];
return combined.filter( return combined.filter(
(item, index, self) => index === self.findIndex((s) => s.id === item.id) (item, index, self) => index === self.findIndex((s) => s.id === item.id)
); );
@ -100,7 +103,8 @@ const AssignOrg = ({ setStep }) => {
alt="logo" alt="logo"
width={40} width={40}
height={40} height={40}
/> <p className="fw-semibold fs-5 mt-2 m-0">{orgData.name}</p> />{" "}
<p className="fw-semibold fs-5 mt-2 m-0">{orgData.name}</p>
</div> </div>
<div className="text-end"> <div className="text-end">
<button <button
@ -113,7 +117,10 @@ const AssignOrg = ({ setStep }) => {
</div> </div>
</div> </div>
</div> </div>
<div className="d-flex text-secondary mb-3"> <i className="bx bx-sm bx-info-circle me-2" /> Organization Info</div> <div className="d-flex text-secondary mb-3">
{" "}
<i className="bx bx-sm bx-info-circle me-2" /> Organization Info
</div>
{/* Contact Info */} {/* Contact Info */}
<div className="col-md-12 mb-4"> <div className="col-md-12 mb-4">
<div className="d-flex"> <div className="d-flex">
@ -132,7 +139,7 @@ const AssignOrg = ({ setStep }) => {
className="form-label me-2 mb-0 fw-semibold" className="form-label me-2 mb-0 fw-semibold"
style={{ minWidth: "130px" }} style={{ minWidth: "130px" }}
> >
<i className='bx bx-sm me-1 bx-phone'></i> Contact Number : <i className="bx bx-sm me-1 bx-phone"></i> Contact Number :
</label> </label>
<div className="text-muted">{orgData.contactNumber}</div> <div className="text-muted">{orgData.contactNumber}</div>
</div> </div>
@ -143,7 +150,7 @@ const AssignOrg = ({ setStep }) => {
className="form-label me-2 mb-0 fw-semibold" className="form-label me-2 mb-0 fw-semibold"
style={{ minWidth: "130px" }} style={{ minWidth: "130px" }}
> >
<i className='bx bx-sm me-1 bx-envelope'></i> Email Address : <i className="bx bx-sm me-1 bx-envelope"></i> Email Address :
</label> </label>
<div className="text-muted text-wrap">{orgData.email}</div> <div className="text-muted text-wrap">{orgData.email}</div>
</div> </div>
@ -166,7 +173,7 @@ const AssignOrg = ({ setStep }) => {
className="form-label me-1 mb-0 fw-semibold" className="form-label me-1 mb-0 fw-semibold"
style={{ minWidth: "130px" }} style={{ minWidth: "130px" }}
> >
<i className='bx bx-sm me-1 bx-map'></i> Address : <i className="bx bx-sm me-1 bx-map"></i> Address :
</label> </label>
<div className="text-muted text-start">{orgData.address}</div> <div className="text-muted text-start">{orgData.address}</div>
</div> </div>
@ -180,7 +187,11 @@ const AssignOrg = ({ setStep }) => {
<> <>
{/* Organization Type */} {/* Organization Type */}
<div className="mb-3 text-start"> <div className="mb-3 text-start">
<Label htmlFor="organizationTypeId" className="mb-3 fw-semibold" required> <Label
htmlFor="organizationTypeId"
className="mb-3 fw-semibold"
required
>
Organization Type Organization Type
</Label> </Label>
<div className="d-flex flex-wrap gap-3 mt-1"> <div className="d-flex flex-wrap gap-3 mt-1">
@ -214,7 +225,11 @@ const AssignOrg = ({ setStep }) => {
{/* Services */} {/* Services */}
<div className="mb-3"> <div className="mb-3">
<Label htmlFor="serviceIds" className="mb-3 fw-semibold" required> <Label
htmlFor="serviceIds"
className="mb-3 fw-semibold"
required
>
Select Services Select Services
</Label> </Label>
{mergedServices?.map((service) => ( {mergedServices?.map((service) => (
@ -255,8 +270,8 @@ const AssignOrg = ({ setStep }) => {
{isPending {isPending
? "Please wait..." ? "Please wait..."
: flowType === "default" : flowType === "default"
? "Assign to Organization" ? "Assign to Organization"
: "Assign to Project"} : "Assign to Project"}
</button> </button>
</div> </div>
</form> </form>