-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #94 from LerianStudio/feature/transactions-create
✨ Transaction Create: Front-end Implementation
- Loading branch information
Showing
25 changed files
with
1,743 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
100 changes: 100 additions & 0 deletions
100
src/app/(routes)/ledgers/[id]/transactions/create/basic-information-paper.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
import { useListAssets } from '@/client/assets' | ||
import { InputField, SelectField } from '@/components/form' | ||
import { Paper } from '@/components/ui/paper' | ||
import { SelectItem } from '@/components/ui/select' | ||
import { Separator } from '@/components/ui/separator' | ||
import { useOrganization } from '@/context/organization-provider/organization-provider-client' | ||
import { Control } from 'react-hook-form' | ||
import { useIntl } from 'react-intl' | ||
import DolarSign from '/public/svg/dolar-sign.svg' | ||
import Image from 'next/image' | ||
import { useParams } from 'next/navigation' | ||
|
||
export type BasicInformationPaperProps = { | ||
control: Control<any> | ||
} | ||
|
||
export const BasicInformationPaper = ({ | ||
control | ||
}: BasicInformationPaperProps) => { | ||
const intl = useIntl() | ||
const { id } = useParams<{ id: string }>() | ||
const { currentOrganization } = useOrganization() | ||
|
||
const { data: assets } = useListAssets({ | ||
organizationId: currentOrganization.id!, | ||
ledgerId: id | ||
}) | ||
|
||
return ( | ||
<Paper className="mb-6 flex flex-col"> | ||
<p className="p-6 text-sm font-medium text-shadcn-400"> | ||
{intl.formatMessage({ | ||
id: 'transactions.create.paper.description', | ||
defaultMessage: | ||
'Fill in the details of the Transaction you want to create.' | ||
})} | ||
</p> | ||
<Separator orientation="horizontal" /> | ||
<div className="grid grid-cols-2 gap-5 p-6"> | ||
<InputField | ||
name="description" | ||
label={intl.formatMessage({ | ||
id: 'transactions.field.description', | ||
defaultMessage: 'Transaction description' | ||
})} | ||
description={intl.formatMessage({ | ||
id: 'common.optional', | ||
defaultMessage: 'Optional' | ||
})} | ||
control={control} | ||
rows={1} | ||
textArea | ||
/> | ||
<InputField | ||
name="chartOfAccountsGroupName" | ||
label={intl.formatMessage({ | ||
id: 'transactions.create.field.chartOfAccountsGroupName', | ||
defaultMessage: 'Accounting route group' | ||
})} | ||
description={intl.formatMessage({ | ||
id: 'common.optional', | ||
defaultMessage: 'Optional' | ||
})} | ||
control={control} | ||
/> | ||
</div> | ||
<Separator orientation="horizontal" /> | ||
<div className="grid grid-cols-4 gap-5 p-6"> | ||
<div className="col-span-2"> | ||
<InputField | ||
name="value" | ||
type="number" | ||
label={intl.formatMessage({ | ||
id: 'entity.transaction.value', | ||
defaultMessage: 'Value' | ||
})} | ||
control={control} | ||
/> | ||
</div> | ||
<SelectField | ||
name="asset" | ||
label={intl.formatMessage({ | ||
id: 'entity.transaction.asset', | ||
defaultMessage: 'Asset' | ||
})} | ||
control={control} | ||
> | ||
{assets?.items?.map((asset) => ( | ||
<SelectItem key={asset.code} value={asset.code}> | ||
{asset.code} | ||
</SelectItem> | ||
))} | ||
</SelectField> | ||
<div className="flex items-end justify-end"> | ||
<Image alt="" src={DolarSign} /> | ||
</div> | ||
</div> | ||
</Paper> | ||
) | ||
} |
49 changes: 49 additions & 0 deletions
49
src/app/(routes)/ledgers/[id]/transactions/create/layout.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
'use client' | ||
|
||
import { Breadcrumb } from '@/components/breadcrumb' | ||
import { TransactionProvider } from './transaction-form-provider' | ||
import { PageHeader } from '@/components/page-header' | ||
import { useIntl } from 'react-intl' | ||
|
||
export default function RootLayout({ | ||
children | ||
}: { | ||
children: React.ReactNode | ||
}) { | ||
const intl = useIntl() | ||
|
||
return ( | ||
<TransactionProvider> | ||
<Breadcrumb | ||
paths={[ | ||
{ | ||
name: intl.formatMessage({ | ||
id: `settings.title`, | ||
defaultMessage: 'Settings' | ||
}), | ||
href: '#' | ||
}, | ||
{ | ||
name: intl.formatMessage({ | ||
id: `transactions.tab.create`, | ||
defaultMessage: 'New Transaction' | ||
}) | ||
} | ||
]} | ||
/> | ||
|
||
<PageHeader.Root> | ||
<PageHeader.Wrapper className="border-none"> | ||
<PageHeader.InfoTitle | ||
title={intl.formatMessage({ | ||
id: 'transactions.create.title', | ||
defaultMessage: 'New Transaction' | ||
})} | ||
/> | ||
</PageHeader.Wrapper> | ||
</PageHeader.Root> | ||
|
||
{children} | ||
</TransactionProvider> | ||
) | ||
} |
58 changes: 58 additions & 0 deletions
58
src/app/(routes)/ledgers/[id]/transactions/create/metadata-accordion.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import { Separator } from '@/components/ui/separator' | ||
import { | ||
PaperCollapsible, | ||
PaperCollapsibleBanner, | ||
PaperCollapsibleContent | ||
} from '@/components/transactions/primitives/paper-collapsible' | ||
import { MetadataField } from '@/components/form' | ||
import { Control } from 'react-hook-form' | ||
import { useIntl } from 'react-intl' | ||
import { Metadata } from '@/types/metadata-type' | ||
|
||
export type MetadataAccordionProps = { | ||
name: string | ||
values: Metadata | ||
control: Control<any> | ||
} | ||
|
||
export const MetadataAccordion = ({ | ||
name, | ||
values, | ||
control | ||
}: MetadataAccordionProps) => { | ||
const intl = useIntl() | ||
|
||
return ( | ||
<> | ||
<h6 className="mb-6 text-sm font-medium"> | ||
{intl.formatMessage({ | ||
id: 'transactions.metadata.title', | ||
defaultMessage: 'Transaction Metadata' | ||
})} | ||
</h6> | ||
|
||
<PaperCollapsible className="mb-32"> | ||
<PaperCollapsibleBanner className="flex items-center justify-between"> | ||
<p className="text-xs italic text-shadcn-400"> | ||
{intl.formatMessage( | ||
{ | ||
id: 'organizations.organizationForm.metadataRegisterCountText', | ||
defaultMessage: | ||
'{count} added {count, plural, =0 {records} one {record} other {records}}' | ||
}, | ||
{ | ||
count: Object.entries(values || 0).length | ||
} | ||
)} | ||
</p> | ||
</PaperCollapsibleBanner> | ||
<PaperCollapsibleContent> | ||
<Separator orientation="horizontal" /> | ||
<div className="p-6"> | ||
<MetadataField name={name} control={control} /> | ||
</div> | ||
</PaperCollapsibleContent> | ||
</PaperCollapsible> | ||
</> | ||
) | ||
} |
Oops, something went wrong.