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 { zodResolver } from "@hookform/resolvers/zod";
|
||||||
import { spridSchema } from "./OrganizationSchema";
|
import { spridSchema } from "./OrganizationSchema";
|
||||||
import { OrgCardSkeleton } from "./OrganizationSkeleton";
|
import { OrgCardSkeleton } from "./OrganizationSkeleton";
|
||||||
|
import { useQueryClient } from "@tanstack/react-query";
|
||||||
|
|
||||||
|
|
||||||
// Zod schema: only allow exactly 4 digits
|
// Zod schema: only allow exactly 4 digits
|
||||||
|
|
||||||
const OrgPickerFromSPId = ({ title, placeholder }) => {
|
const OrgPickerFromSPId = ({ title, placeholder }) => {
|
||||||
const { onClose, startStep, flowType, onOpen, prevStep } =
|
const { onClose, startStep, flowType, onOpen, prevStep,orgData } =
|
||||||
useOrganizationModal();
|
useOrganizationModal();
|
||||||
|
const clientQuery = useQueryClient()
|
||||||
const {
|
const {
|
||||||
register,
|
register,
|
||||||
handleSubmit,
|
handleSubmit,
|
||||||
@ -35,8 +37,11 @@ const OrgPickerFromSPId = ({ title, placeholder }) => {
|
|||||||
const onSubmit = (formdata) => {
|
const onSubmit = (formdata) => {
|
||||||
setSPRID(formdata.spridSearchText);
|
setSPRID(formdata.spridSearchText);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleOrg = (orgId) => {};
|
const handleCrateOrg = () => {
|
||||||
|
clientQuery.removeQueries({queryKey:["organization"]})
|
||||||
|
onOpen({ startStep: 4,orgData:null })
|
||||||
|
};
|
||||||
const SP = watch("spridSearchText");
|
const SP = watch("spridSearchText");
|
||||||
return (
|
return (
|
||||||
<div className="d-block">
|
<div className="d-block">
|
||||||
@ -126,7 +131,7 @@ const OrgPickerFromSPId = ({ title, placeholder }) => {
|
|||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
className="btn btn-sm btn-primary mt-3"
|
className="btn btn-sm btn-primary mt-3"
|
||||||
onClick={() => onOpen({ startStep: 4 })}
|
onClick={handleCrateOrg}
|
||||||
>
|
>
|
||||||
<i className="bx bx-plus-circle me-2"></i>
|
<i className="bx bx-plus-circle me-2"></i>
|
||||||
Create New Organization
|
Create New Organization
|
||||||
|
@ -24,7 +24,7 @@ export const useOrganizationModal = () => {
|
|||||||
dispatch(
|
dispatch(
|
||||||
openOrgModal({
|
openOrgModal({
|
||||||
isOpen: true,
|
isOpen: true,
|
||||||
orgData: options.orgData ?? orgData ?? null,
|
orgData: options.hasOwnProperty("orgData") ? options.orgData : orgData,
|
||||||
startStep: options.startStep ?? startStep ?? 1,
|
startStep: options.startStep ?? startStep ?? 1,
|
||||||
prevStep: options.prevStep ?? prevStep ?? 1,
|
prevStep: options.prevStep ?? prevStep ?? 1,
|
||||||
flowType: options.flowType ?? flowType ?? "default",
|
flowType: options.flowType ?? flowType ?? "default",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user