Skip to content

Commit

Permalink
Adding withdrawnAmount in Admin Campaign Grid (#1305)
Browse files Browse the repository at this point in the history
* fixed scroll in admin campaign grid

* allow edit of public donor name for all donations - #1206

* fixed: misleading names for bank upload

* fixed typos valt vs vault

* moved: vault grid actions as first column

* fixed: editing of withdrawals and status change to successfully approved

* added: withdrawnAmount column in Admin Campaign grid

* forbid changes on succeeded withdrawal

---------

Co-authored-by: quantum-grit <[email protected]>
  • Loading branch information
quantum-grit and quantum-grit authored Jan 29, 2023
1 parent ce4d538 commit 3374ff3
Show file tree
Hide file tree
Showing 16 changed files with 138 additions and 51 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
"@types/react-gtm-module": "2.0.0",
"@types/react-slick": "^0.23.10",
"@types/tryghost__content-api": "^1.3.11",
"@types/uuid": "^9.0.0",
"@types/yup": "0.29.11",
"@typescript-eslint/eslint-plugin": "4.26.0",
"@typescript-eslint/parser": "4.26.0",
Expand Down
2 changes: 2 additions & 0 deletions public/locales/bg/campaigns.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
"targetAmount": "Целева сума",
"donationsAmount": "Събрани средства",
"blockedAmount": "Блокирани средства",
"withdrawnAmount": "Преведени средства",

"startDate": "Стартова дата",
"endDate": "Крайна дата",
"createDate": "Съдадена на",
Expand Down
4 changes: 2 additions & 2 deletions public/locales/bg/donations.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
"deleteAllContent": "Това действие ще изтрие избраните елементи завинаги!",
"actions": "Действия",
"createdAt": "Направено на",
"bankTransactionsFileId": "Номер на файла с банкови транзакции",
"addFiles": "Добави файлове",
"bankTransactionsFileId": "Име на файла с банкови транзакции",
"addFiles": "Избери файл",
"noOptions": "Няма резултати",
"alerts": {
"selectRow": "Моля изберете ред",
Expand Down
13 changes: 11 additions & 2 deletions public/locales/bg/withdrawals.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"amount-unavailable": "Недостатъчна наличност в трезора!",
"documentId": "ID на документа",
"documentId": "Номер на документа",
"amount-available": "Налична сума",
"amount-input": "Въведете сума",
"form-heading": "Създай нов превод",
Expand Down Expand Up @@ -30,7 +30,16 @@
"edit": "Преводът беше редактиран успешно!",
"delete": "Преводът беше преместен в кошчето!",
"deleteAll": "Преводите бяха преместени в кошчето!",
"error": "Възникна грешка! Моля опитайте отново по-късно."
"error": "Възникна грешка! Моля опитайте отново по-късно.",
"no-edit": "Превода е приключен успешно и не може да се променя."
},
"statuses": {
"initial": "нов",
"invalid": "невалиден",
"incomplete": "непълен",
"declined": "отказан",
"cancelled": "оттеглен",
"succeeded": "успешен"
},
"cta": {
"add": "Добави",
Expand Down
1 change: 1 addition & 0 deletions public/locales/en/campaigns.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"targetAmount": "Target amount",
"donationsAmount": "Donations amount",
"blockedAmount": "Blocked amount",
"withdrawnAmount": "Withdrawn amount",
"startDate": "Start date",
"endDate": "End date",
"createDate": "Created at",
Expand Down
4 changes: 2 additions & 2 deletions public/locales/en/donations.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
"deleteTitle": "Are you sure?",
"deleteContent": "This action will delete this item permanently!",
"deleteAllContent": "This action will delete selected items permanently!",
"bankTransactionsFileId": "Number of bank transactions file",
"addFiles": "Add files",
"bankTransactionsFileId": "Name of bank transactions file",
"addFiles": "Select file",
"actions": "Actions",
"createdAt": "Created at",
"noOptions": "No results",
Expand Down
11 changes: 10 additions & 1 deletion public/locales/en/withdrawals.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,16 @@
"edit": "Withdrawal has been edited successfully!",
"delete": "Withdrawal has been deleted successfully!",
"deleteAll": "Withdrawals have been deleted successfully!",
"error": "An error has occured! Please try again later."
"error": "An error has occured! Please try again later.",
"no-edit": "This withdrawal is completed successfully and cannot be changed."
},
"statuses": {
"initial": "initial",
"invalid": "invalid",
"incomplete": "incomplete",
"declined": "declined",
"cancelled": "cancelled",
"succeeded": "succeeded"
},
"cta": {
"add": "Add",
Expand Down
36 changes: 24 additions & 12 deletions src/components/campaigns/grid/CampaignGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ export const DisplayCurrentAmount = ({ params }: CampaignCellProps) => {
return <>{money(params.row.summary.currentAmount ?? 0, params.row.currency)}</>
}

export const DisplayWithdrawnAmount = ({ params }: CampaignCellProps) => {
return <>{money(params.row.summary.withdrawnAmount ?? 0, params.row.currency)}</>
}

export default function CampaignGrid() {
const { t, i18n } = useTranslation()
const { data = [], refetch }: UseQueryResult<AdminCampaignResponse[]> = useCampaignAdminList()
Expand Down Expand Up @@ -149,6 +153,16 @@ export default function CampaignGrid() {
width: 250,
renderCell: (cellValues: GridRenderCellParams) => <>{cellValues.row.campaignType.name}</>,
},
{
field: 'targetAmount',
headerName: t('campaigns:targetAmount'),
...commonProps,
align: 'right',
width: 150,
renderCell: (cellValues: GridRenderCellParams) => (
<>{money(cellValues.row.targetAmount, cellValues.row.currency)}</>
),
},
{
field: 'reachedAmount',
headerName: t('campaigns:donationsAmount'),
Expand All @@ -162,33 +176,33 @@ export default function CampaignGrid() {
),
},
{
field: 'blockedAmount',
headerName: t('campaigns:blockedAmount'),
field: 'currentAmount',
headerName: t('campaigns:amount'),
...commonProps,
align: 'right',
width: 200,
renderCell: (cellValues: GridRenderCellParams) => (
<DisplayBlockedAmount params={cellValues} />
<DisplayCurrentAmount params={cellValues} />
),
},
{
field: 'currentAmount',
headerName: t('campaigns:amount'),
field: 'blockedAmount',
headerName: t('campaigns:blockedAmount'),
...commonProps,
align: 'right',
width: 200,
renderCell: (cellValues: GridRenderCellParams) => (
<DisplayCurrentAmount params={cellValues} />
<DisplayBlockedAmount params={cellValues} />
),
},
{
field: 'targetAmount',
headerName: t('campaigns:targetAmount'),
field: 'withdrawnAmount',
headerName: t('campaigns:withdrawnAmount'),
...commonProps,
align: 'right',
width: 150,
width: 200,
renderCell: (cellValues: GridRenderCellParams) => (
<>{money(cellValues.row.targetAmount, cellValues.row.currency)}</>
<DisplayWithdrawnAmount params={cellValues} />
),
},
{
Expand Down Expand Up @@ -292,8 +306,6 @@ export default function CampaignGrid() {
columns={columns}
pageSize={10}
editMode="row"
autoHeight
autoPageSize
/>
<Box>
{selectedCampaign && (
Expand Down
2 changes: 1 addition & 1 deletion src/components/donations/grid/Grid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ export default observer(function Grid() {
paginationMode="server"
rowCount={all_rows}
disableSelectionOnClick
isCellEditable={(params) => params.row.provider.includes('bank')}
isCellEditable={() => true}
/>
</Box>

Expand Down
5 changes: 3 additions & 2 deletions src/components/expenses/Form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,9 @@ export default function Form() {
params: {},
message: t('fields-error.amount-unavailable'),
test: function (value) {
const currentValt = vaults?.find((curr) => curr.id == this.parent.vaultId)
const currentAmount = Number(currentValt?.amount) - Number(currentValt?.blockedAmount)
const currentVault = vaults?.find((curr) => curr.id == this.parent.vaultId)
const currentAmount =
Number(currentVault?.amount) - Number(currentVault?.blockedAmount)
return value! < Number(currentAmount)
},
}),
Expand Down
4 changes: 2 additions & 2 deletions src/components/transfers/CreateForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ export default function CreateForm({ campaigns }: Props) {
params: {},
message: t('amount-unavailable'),
test: function (value) {
const currentValt = vaults?.find((curr) => curr.id == this.parent.sourceVaultId)
const currentAmount = Number(currentValt?.amount) - Number(currentValt?.blockedAmount)
const currentVault = vaults?.find((curr) => curr.id == this.parent.sourceVaultId)
const currentAmount = Number(currentVault?.amount) - Number(currentVault?.blockedAmount)
return value ? value < Number(fromMoney(currentAmount)) : false
},
}),
Expand Down
37 changes: 19 additions & 18 deletions src/components/vaults/grid/Grid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,34 @@ export default observer(function Grid() {
}

const columns: GridColumns = [
{
field: 'actions',
headerName: t('actions'),
width: 120,
type: 'actions',
headerAlign: 'left',
renderCell: (params: GridRenderCellParams): React.ReactNode => {
return (
<GridActions
modalStore={ModalStore}
id={params.row.id}
name={params.row.name}
editLink={routes.admin.vaults.edit(params.row.id)}
/>
)
},
},
{
field: 'name',
headerName: t('name'),
flex: 1,
...commonProps,
width: 200,
},
{
field: 'currency',
headerName: t('currency'),
...commonProps,
width: 80,
},
{
field: 'amount',
Expand Down Expand Up @@ -79,23 +97,6 @@ export default observer(function Grid() {
...commonProps,
width: 450,
},
{
field: 'actions',
headerName: t('actions'),
width: 120,
type: 'actions',
headerAlign: 'left',
renderCell: (params: GridRenderCellParams): React.ReactNode => {
return (
<GridActions
modalStore={ModalStore}
id={params.row.id}
name={params.row.name}
editLink={routes.admin.vaults.edit(params.row.id)}
/>
)
},
},
]

return (
Expand Down
3 changes: 2 additions & 1 deletion src/components/withdrawals/CreateForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import VaultSelect from 'components/vaults/VaultSelect'
import PersonSelect from 'components/person/PersonSelect'
import { Currency } from 'gql/currency'
import { fromMoney, toMoney } from 'common/util/money'
import { v4 as uuidv4 } from 'uuid'

export default function CreateForm() {
const router = useRouter()
Expand Down Expand Up @@ -72,7 +73,7 @@ export default function CreateForm() {
sourceVaultId: '',
sourceCampaignId: '',
bankAccountId: '',
documentId: '',
documentId: uuidv4(), //this will be the id of the uploaded doc when attachments are implemented
approvedById: '',
}

Expand Down
Loading

0 comments on commit 3374ff3

Please sign in to comment.