Skip to content

properties on organization details view #981

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
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
33 changes: 30 additions & 3 deletions tasks/components/layout/OrganizationDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { useContext, useEffect, useState } from 'react'
import { Button } from '@helpwave/common/components/Button'
import { ConfirmDialog } from '@helpwave/common/components/modals/ConfirmDialog'
import { Span } from '@helpwave/common/components/Span'
import Link from 'next/link'
import {
useInviteMemberMutation,
useOrganizationCreateMutation,
Expand All @@ -14,6 +15,8 @@ import {
} from '@helpwave/api-services/mutations/users/organization_mutations'
import type { OrganizationMinimalDTO } from '@helpwave/api-services/types/users/organizations'
import { useAuth } from '@helpwave/api-services/authentication/useAuth'
import { DescriptionWithAction } from '@helpwave/common/components/DescriptionWithAction'
import { usePropertyListQuery } from '@helpwave/api-services/mutations/properties/property_mutations'
import { emptyOrganizationForm, OrganizationForm, type OrganizationFormType } from '../OrganizationForm'
import { OrganizationMemberList } from '../OrganizationMemberList'
import { ColumnTitle } from '../ColumnTitle'
Expand All @@ -28,7 +31,10 @@ type OrganizationDetailTranslation = {
deleteConfirmText: string,
deleteOrganization: string,
create: string,
update: string
update: string,
properties: string,
propertiesDescription: string,
manageProperties: string
}

const defaultOrganizationDetailTranslations: Record<Languages, OrganizationDetailTranslation> = {
Expand All @@ -39,7 +45,10 @@ const defaultOrganizationDetailTranslations: Record<Languages, OrganizationDetai
deleteConfirmText: 'Do you really want to delete this organization?',
deleteOrganization: 'Delete Organization',
create: 'Create',
update: 'Update'
update: 'Update',
properties: 'Properties',
propertiesDescription: 'With properties you can add custom fields to different entities you patients or beds.',
manageProperties: 'Manage Properties'
},
de: {
organizationDetail: 'Organisations Details',
Expand All @@ -48,7 +57,10 @@ const defaultOrganizationDetailTranslations: Record<Languages, OrganizationDetai
deleteConfirmText: 'Wollen Sie wirklich diese Organisation löschen?',
deleteOrganization: 'Organisation löschen',
create: 'Erstellen',
update: 'Ändern'
update: 'Ändern',
properties: 'Eigenschaften',
propertiesDescription: 'Mit Eigenschaften können Sie verschiedenen Entitäten wie Patienten oder Betten benutzerdefinierte Felder hinzufügen.',
manageProperties: 'Eigenschaften Verwalten'
}
}

Expand All @@ -72,6 +84,7 @@ export const OrganizationDetail = ({
const { signOut } = useAuth()
const isCreatingNewOrganization = contextState.organizationId === ''
const { data } = useOrganizationQuery(contextState.organizationId)
const { data: propertyData } = usePropertyListQuery()
const [isShowingConfirmDialog, setIsShowingConfirmDialog] = useState(false)
const [isShowingReSignInDialog, setIsShowingReSignInDialog] = useState<string>()
const [organizationForm, setOrganizationForm] = useState<OrganizationFormType>(emptyOrganizationForm)
Expand Down Expand Up @@ -192,6 +205,20 @@ export const OrganizationDetail = ({
invitations={isCreatingNewOrganization ? organizationInvites : undefined}
organizationId={contextState.organizationId}
/>
{propertyData && !isCreatingNewOrganization && (
<DescriptionWithAction
title={`${translation.properties} (${propertyData.length})`}
description={translation.propertiesDescription}
trailing={(
<div className={tw('flex flex-row justify-end items-center')}>
<Link href="/properties">
<Button className="h-fit">{translation.manageProperties}</Button>
</Link>
</div>
)}
leadingIcon="label"
/>
)}
<div className={tw('flex flex-row justify-end')}>
<Button
className={tw('w-auto')}
Expand Down
Loading