Selected organization should remain visible after navigating back

This commit is contained in:
Kartik Sharma 2025-10-07 14:34:10 +05:30
parent 9886fac03e
commit 30144695f9

View File

@ -1,4 +1,4 @@
import { useState } from "react";
import { useEffect, useState } from "react";
import {
useAssignOrgToTenant,
useOrganizationBySPRID,
@ -14,12 +14,14 @@ import { OrgCardSkeleton } from "./OrganizationSkeleton";
// Zod schema: only allow exactly 4 digits
const OrgPickerFromSPId = ({ title, placeholder }) => {
const { onClose, startStep, flowType, onOpen, prevStep } =
const { onClose, startStep, flowType, onOpen, prevStep, orgData } =
useOrganizationModal();
const {
register,
handleSubmit,
setValue,
formState: { errors },
watch,
} = useForm({
@ -36,7 +38,15 @@ const OrgPickerFromSPId = ({ title, placeholder }) => {
setSPRID(formdata.spridSearchText);
};
const handleOrg = (orgId) => {};
// Add this..
useEffect(() => {
if (orgData?.sprid) {
setValue("spridSearchText", orgData.sprid);
setSPRID(orgData.sprid);
}
}, [orgData, setValue]);
const handleOrg = (orgId) => { };
const SP = watch("spridSearchText");
return (
<div className="d-block">