Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix OrganizationDetails showing wrong data and endlessly loading #587

Merged
merged 1 commit into from
Aug 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions tasks/components/OrganisationInvitationList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ export const OrganisationInvitationList = ({

return (
<LoadingAndErrorComponent
isLoading={isLoading && context.state.organizationID !== undefined}
hasError={isError && context.state.organizationID !== undefined}
isLoading={isLoading && !!context.state.organizationID}
hasError={isError && !!context.state.organizationID}
errorProps={{ classname: tw('border-b-2 border-gray-500 rounded-xl') }}
loadingProps={{ classname: tw('border-2 border-gray-500 rounded-xl') }}
>
Expand Down
101 changes: 52 additions & 49 deletions tasks/components/layout/OrganizationDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,58 +108,61 @@ export const OrganizationDetail = ({
}))

return (
<div className={tw('flex flex-col py-4 px-6')}>
<ConfirmDialog
title={translation.deleteConfirmText}
description={translation.dangerZoneText}
isOpen={isShowingConfirmDialog}
onCancel={() => setIsShowingConfirmDialog(false)}
onBackgroundClick={() => setIsShowingConfirmDialog(false)}
onConfirm={() => {
setIsShowingConfirmDialog(false)
deleteMutation.mutate(contextState.organizationID)
}}
confirmType="negative"
/>
<ColumnTitle title={translation.organizationDetail}/>
<div className={tw('flex flex-col gap-y-4 max-w-[500px]')}>
<OrganizationForm
organizationForm={organizationForm}
isShowingErrorsDirectly={!isCreatingNewOrganization}
onChange={(organizationForm, shouldUpdate) => {
setOrganizationForm(organizationForm)
if (shouldUpdate) {
updateMutation.mutate(organizationForm.organization)
}
<div
key={contextState.organizationID}
className={tw('flex flex-col py-4 px-6')}
>
<ConfirmDialog
title={translation.deleteConfirmText}
description={translation.dangerZoneText}
isOpen={isShowingConfirmDialog}
onCancel={() => setIsShowingConfirmDialog(false)}
onBackgroundClick={() => setIsShowingConfirmDialog(false)}
onConfirm={() => {
setIsShowingConfirmDialog(false)
deleteMutation.mutate(contextState.organizationID)
}}
confirmType="negative"
/>
{!isCreatingNewOrganization && (
<OrganizationMemberList />
)}
<OrganisationInvitationList
onChange={setOrganizationInvites}
invitations={isCreatingNewOrganization ? organizationInvites : undefined}
organizationID={contextState.organizationID}
/>
<div className={tw('flex flex-row justify-end')}>
<Button
className={tw('w-auto')}
onClick={() => isCreatingNewOrganization ? createMutation.mutate(organizationForm.organization) : updateMutation.mutate(organizationForm.organization)}
disabled={!organizationForm.isValid}>
{isCreatingNewOrganization ? translation.create : translation.update}
</Button>
</div>
<div className={tx('flex flex-col justify-start', { hidden: isCreatingNewOrganization })}>
<Span type="subsectionTitle">{translation.dangerZone}</Span>
<Span type="description">{translation.dangerZoneText}</Span>
<button
onClick={() => setIsShowingConfirmDialog(true)}
className={tw('text-hw-negative-400 font-bold text-left')}
>
{translation.deleteOrganization}
</button>
<ColumnTitle title={translation.organizationDetail}/>
<div className={tw('flex flex-col gap-y-4 max-w-[500px]')}>
<OrganizationForm
organizationForm={organizationForm}
isShowingErrorsDirectly={!isCreatingNewOrganization}
onChange={(organizationForm, shouldUpdate) => {
setOrganizationForm(organizationForm)
if (shouldUpdate) {
updateMutation.mutate(organizationForm.organization)
}
}}
/>
{!isCreatingNewOrganization && (
<OrganizationMemberList />
)}
<OrganisationInvitationList
onChange={setOrganizationInvites}
invitations={isCreatingNewOrganization ? organizationInvites : undefined}
organizationID={contextState.organizationID}
/>
<div className={tw('flex flex-row justify-end')}>
<Button
className={tw('w-auto')}
onClick={() => isCreatingNewOrganization ? createMutation.mutate(organizationForm.organization) : updateMutation.mutate(organizationForm.organization)}
disabled={!organizationForm.isValid}>
{isCreatingNewOrganization ? translation.create : translation.update}
</Button>
</div>
<div className={tx('flex flex-col justify-start', { hidden: isCreatingNewOrganization })}>
<Span type="subsectionTitle">{translation.dangerZone}</Span>
<Span type="description">{translation.dangerZoneText}</Span>
<button
onClick={() => setIsShowingConfirmDialog(true)}
className={tw('text-hw-negative-400 font-bold text-left')}
>
{translation.deleteOrganization}
</button>
</div>
</div>
</div>
</div>
)
}
2 changes: 1 addition & 1 deletion tasks/mutations/organization_mutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -345,9 +345,9 @@ export const useInviteMemberMutation = (organizationID: string, callback: (invit
const res = await organizationService.inviteMember(req, getAuthenticatedGrpcMetadata())

if (!res.getId()) {
// TODO some check whether request was successful
console.error('InviteMember failed')
}

callback(res.getId())
return res.toObject()
},
Expand Down