Refactor invitation system

Signed-off-by: Sacha Al Himdani <sacha@getprobo.com>
This commit is contained in:
Sacha Al Himdani
2025-10-10 01:11:09 +02:00
parent 0f96b8518f
commit 165eb267f2
39 changed files with 2730 additions and 1194 deletions

View File

@@ -45,14 +45,15 @@ const schema = z.object({
type Props = PropsWithChildren & {
connectionId?: string;
onRefetch: () => void;
};
export function InviteUserDialog({ children, connectionId }: Props) {
export function InviteUserDialog({ children, connectionId, onRefetch }: Props) {
const { __ } = useTranslate();
const organizationId = useOrganizationId();
const [inviteUser, isInviting] = useMutationWithToasts(inviteMutation, {
successMessage: __("User invited successfully"),
errorMessage: __("Failed to invite user"),
successMessage: __("Invitation sent successfully"),
errorMessage: __("Failed to send invitation"),
});
const { register, handleSubmit, formState, reset, control } = useFormWithSchema(
schema,
@@ -72,9 +73,10 @@ export function InviteUserDialog({ children, connectionId }: Props) {
},
connections: connectionId ? [connectionId] : ["SettingsPageInvitations_invitations"],
},
onSuccess: () => {
onCompleted: () => {
reset();
dialogRef.current?.close();
onRefetch();
},
});
});