misc: added neat check all condition

This commit is contained in:
Sheen Capadngan
2025-03-14 03:50:17 +08:00
parent 430f8458cb
commit 2149c0a9d1

View File

@@ -32,10 +32,21 @@ export const UpgradePrivilegeSystemModal = ({ isOpen, onOpenChange }: Props) =>
const {
handleSubmit,
control,
watch,
formState: { isSubmitting }
} = useForm({ resolver: zodResolver(formSchema) });
const { mutateAsync: upgradePrivilegeSystem } = useUpgradePrivilegeSystem();
const isProjectPrivilegesUpdated = watch("isProjectPrivilegesUpdated");
const isOrgPrivilegesUpdated = watch("isOrgPrivilegesUpdated");
const isInfrastructureUpdated = watch("isInfrastructureUpdated");
const acknowledgesPermanentChange = watch("acknowledgesPermanentChange");
const isAllChecksCompleted =
isProjectPrivilegesUpdated &&
isOrgPrivilegesUpdated &&
isInfrastructureUpdated &&
acknowledgesPermanentChange;
const handlePrivilegeSystemUpgrade = async () => {
try {
await upgradePrivilegeSystem();
@@ -231,7 +242,7 @@ export const UpgradePrivilegeSystemModal = ({ isOpen, onOpenChange }: Props) =>
</div>
<Button
type="submit"
isDisabled={!isAdmin}
isDisabled={!isAdmin || !isAllChecksCompleted}
isLoading={isSubmitting}
className="mt-5 w-full"
>