Fix: Ensure orgData can be cleared when opening Organization Modal
This commit is contained in:
parent
9b8c8c34ab
commit
a64635cd37
@ -10,13 +10,15 @@ import { useForm } from "react-hook-form";
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
import { spridSchema } from "./OrganizationSchema";
|
||||
import { OrgCardSkeleton } from "./OrganizationSkeleton";
|
||||
import { useQueryClient } from "@tanstack/react-query";
|
||||
|
||||
|
||||
// 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 clientQuery = useQueryClient()
|
||||
const {
|
||||
register,
|
||||
handleSubmit,
|
||||
@ -36,7 +38,10 @@ const OrgPickerFromSPId = ({ title, placeholder }) => {
|
||||
setSPRID(formdata.spridSearchText);
|
||||
};
|
||||
|
||||
const handleOrg = (orgId) => {};
|
||||
const handleCrateOrg = () => {
|
||||
clientQuery.removeQueries({queryKey:["organization"]})
|
||||
onOpen({ startStep: 4,orgData:null })
|
||||
};
|
||||
const SP = watch("spridSearchText");
|
||||
return (
|
||||
<div className="d-block">
|
||||
@ -126,7 +131,7 @@ const OrgPickerFromSPId = ({ title, placeholder }) => {
|
||||
<button
|
||||
type="button"
|
||||
className="btn btn-sm btn-primary mt-3"
|
||||
onClick={() => onOpen({ startStep: 4 })}
|
||||
onClick={handleCrateOrg}
|
||||
>
|
||||
<i className="bx bx-plus-circle me-2"></i>
|
||||
Create New Organization
|
||||
|
@ -24,7 +24,7 @@ export const useOrganizationModal = () => {
|
||||
dispatch(
|
||||
openOrgModal({
|
||||
isOpen: true,
|
||||
orgData: options.orgData ?? orgData ?? null,
|
||||
orgData: options.hasOwnProperty("orgData") ? options.orgData : orgData,
|
||||
startStep: options.startStep ?? startStep ?? 1,
|
||||
prevStep: options.prevStep ?? prevStep ?? 1,
|
||||
flowType: options.flowType ?? flowType ?? "default",
|
||||
|
Loading…
x
Reference in New Issue
Block a user