Skip to content

Commit

Permalink
✨ feat: Added to Organizations
Browse files Browse the repository at this point in the history
  • Loading branch information
caioaletroca committed Dec 4, 2024
1 parent 3119951 commit a053c26
Show file tree
Hide file tree
Showing 3 changed files with 124 additions and 104 deletions.
1 change: 1 addition & 0 deletions locales/extracted/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@
"organizations.organizationView.breadcrumbs.settings": "Settings",
"organizations.organizationView.newOrganization.title": "New Organization",
"organizations.organizationView.notFound": "Organization not found.",
"organizations.showing": "Showing {count} {number, plural, =0 {organizations} one {organization} other {organizations}}.",
"organizations.subtitle": "View and manage Organizations.",
"organizations.title": "Settings",
"organizations.toast.create.success": "Organization created!",
Expand Down
3 changes: 2 additions & 1 deletion locales/extracted/pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -286,5 +286,6 @@
"ledgers.products.showing": "Mostrando {count} {number, plural, =0 {produtos} one {produto} other {produtos}}.",
"ledgers.showing": "Mostrando {count} {number, plural, =0 {ledgers} one {ledger} other {ledgers}}.",
"ledgers.accounts.showing": "Mostrando {count} {number, plural, =0 {contas} one {conta} other {contas}}.",
"ledgers.portfolios.showing": "Mostrando {count} {number, plural, =0 {portfólios} one {portfólio} other {portfólios}}."
"ledgers.portfolios.showing": "Mostrando {count} {number, plural, =0 {portfólios} one {portfólio} other {portfólios}}.",
"organizations.showing": "Mostrando {count} {number, plural, =0 {organizações} one {organização} other {organizações}}."
}
224 changes: 121 additions & 103 deletions src/app/(routes)/settings/organizations-tab-content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import { useConfirmDialog } from '@/components/confirmation-dialog/use-confirm-d
import ConfirmationDialog from '@/components/confirmation-dialog'
import { Badge } from '@/components/ui/badge'
import { OrganizationEntity } from '@/core/domain/entities/organization-entity'
import { EntityDataTable } from '@/components/entity-data-table'

export const OrganizationsTabContent = () => {
const intl = useIntl()
Expand Down Expand Up @@ -115,110 +116,127 @@ export const OrganizationsTabContent = () => {
</Button>
</EmptyResource>
)}

{data?.items && data.items.length > 0 && (
<TableContainer>
<Table>
<TableHeader>
<TableRow>
<TableHead>
{intl.formatMessage({
id: 'common.id',
defaultMessage: 'ID'
})}
</TableHead>
<TableHead>
{intl.formatMessage({
id: `entity.organization.legalName`,
defaultMessage: 'Legal Name'
})}
</TableHead>
<TableHead>
{intl.formatMessage({
id: `entity.organization.doingBusinessAs`,
defaultMessage: 'Trade Name'
})}
</TableHead>
<TableHead>
{intl.formatMessage({
id: `entity.organization.legalDocument`,
defaultMessage: 'Document'
})}
</TableHead>
<TableHead>
{intl.formatMessage({
id: `entity.organization.status`,
defaultMessage: 'Status'
})}
</TableHead>
<TableHead>
{intl.formatMessage({
id: 'common.actions',
defaultMessage: 'Actions'
})}
</TableHead>
</TableRow>
</TableHeader>
<TableBody>
{data.items.map((organization) => (
<TableRow key={organization.id}>
<TableCell>{organization.id}</TableCell>
<TableCell>{organization.legalName}</TableCell>
<TableCell>{organization.doingBusinessAs}</TableCell>
<TableCell>{organization.legalDocument}</TableCell>
<TableCell>
<Badge
variant={
organization.status.code === 'ACTIVE'
? 'active'
: 'inactive'
}
>
{organization.status.code === 'ACTIVE'
? intl.formatMessage({
id: 'common.active',
defaultMessage: 'Active'
})
: intl.formatMessage({
id: 'common.inactive',
defaultMessage: 'Inactive'
})}
</Badge>
</TableCell>
<TableCell>
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button variant="secondary">
<MoreVertical size={16} onClick={() => {}} />
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent align="end">
<DropdownMenuItem
onClick={() => handleEdit(organization)}
>
{intl.formatMessage({
id: `common.edit`,
defaultMessage: 'Edit'
})}
</DropdownMenuItem>
<DropdownMenuSeparator />
<DropdownMenuItem
onClick={() => handleDialogOpen(organization.id!)}
>
{intl.formatMessage({
id: `common.delete`,
defaultMessage: 'Delete'
})}
</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
</TableCell>
<EntityDataTable.Root>
{data?.items && data.items.length > 0 && (
<TableContainer>
<Table>
<TableHeader>
<TableRow>
<TableHead>
{intl.formatMessage({
id: 'common.id',
defaultMessage: 'ID'
})}
</TableHead>
<TableHead>
{intl.formatMessage({
id: `entity.organization.legalName`,
defaultMessage: 'Legal Name'
})}
</TableHead>
<TableHead>
{intl.formatMessage({
id: `entity.organization.doingBusinessAs`,
defaultMessage: 'Trade Name'
})}
</TableHead>
<TableHead>
{intl.formatMessage({
id: `entity.organization.legalDocument`,
defaultMessage: 'Document'
})}
</TableHead>
<TableHead>
{intl.formatMessage({
id: `entity.organization.status`,
defaultMessage: 'Status'
})}
</TableHead>
<TableHead>
{intl.formatMessage({
id: 'common.actions',
defaultMessage: 'Actions'
})}
</TableHead>
</TableRow>
))}
</TableBody>
</Table>
</TableContainer>
)}
</TableHeader>
<TableBody>
{data.items.map((organization) => (
<TableRow key={organization.id}>
<TableCell>{organization.id}</TableCell>
<TableCell>{organization.legalName}</TableCell>
<TableCell>{organization.doingBusinessAs}</TableCell>
<TableCell>{organization.legalDocument}</TableCell>
<TableCell>
<Badge
variant={
organization.status.code === 'ACTIVE'
? 'active'
: 'inactive'
}
>
{organization.status.code === 'ACTIVE'
? intl.formatMessage({
id: 'common.active',
defaultMessage: 'Active'
})
: intl.formatMessage({
id: 'common.inactive',
defaultMessage: 'Inactive'
})}
</Badge>
</TableCell>
<TableCell>
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button variant="secondary">
<MoreVertical size={16} onClick={() => {}} />
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent align="end">
<DropdownMenuItem
onClick={() => handleEdit(organization)}
>
{intl.formatMessage({
id: `common.edit`,
defaultMessage: 'Edit'
})}
</DropdownMenuItem>
<DropdownMenuSeparator />
<DropdownMenuItem
onClick={() => handleDialogOpen(organization.id!)}
>
{intl.formatMessage({
id: `common.delete`,
defaultMessage: 'Delete'
})}
</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
</TableCell>
</TableRow>
))}
</TableBody>
</Table>
</TableContainer>
)}

<EntityDataTable.Footer>
<EntityDataTable.FooterText>
{intl.formatMessage(
{
id: 'organizations.showing',
defaultMessage:
'Showing {count} {number, plural, =0 {organizations} one {organization} other {organizations}}.'
},
{
number: data?.items?.length,
count: <span className="font-bold">{data?.items?.length}</span>
}
)}
</EntityDataTable.FooterText>
</EntityDataTable.Footer>
</EntityDataTable.Root>
</div>
)
}

0 comments on commit a053c26

Please sign in to comment.