Skip to content

Commit

Permalink
chore(ui): add withdrawal and deposit references (#485)
Browse files Browse the repository at this point in the history
* chore(ui): add withdrawal and deposit references

* fix: check-code
  • Loading branch information
sandipndev authored Sep 4, 2024
1 parent 17c9a57 commit 061fdf9
Show file tree
Hide file tree
Showing 13 changed files with 67 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ gql`
customerId
withdrawals {
status
reference
customerId
withdrawalId
amount
Expand Down
8 changes: 8 additions & 0 deletions apps/admin-panel/app/deposits/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ gql`
customerId
depositId
amount
reference
customer {
customerId
email
Expand All @@ -47,6 +48,7 @@ gql`
customerId
depositId
amount
reference
customer {
customerId
email
Expand Down Expand Up @@ -165,6 +167,7 @@ function DepositsTable() {
<TableRow>
<TableHead>Customer</TableHead>
<TableHead>Deposit ID</TableHead>
<TableHead>Reference</TableHead>
<TableHead className="text-right">Deposit Amount</TableHead>
</TableRow>
</TableHeader>
Expand All @@ -178,6 +181,11 @@ function DepositsTable() {
</Link>
</TableCell>
<TableCell>{deposit.depositId}</TableCell>
<TableCell>
{deposit.reference === deposit.depositId
? "n/a"
: deposit.reference}
</TableCell>
<TableCell>
<Balance amount={deposit.amount} currency="usd" align="end" />
</TableCell>
Expand Down
1 change: 1 addition & 0 deletions apps/admin-panel/app/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ type WithdrawalWithCustomer = {
status: WithdrawalStatus
customerId: string
withdrawalId: string
reference: string
amount: number
customer?: {
__typename?: "Customer"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ gql`
withdrawalId
amount
status
reference
customer {
email
customerId
Expand Down Expand Up @@ -89,6 +90,15 @@ const WithdrawalDetailsCard: React.FC<LoanDetailsProps> = ({ withdrawalId }) =>
/>
}
/>
<DetailItem
label="Withdrawal Reference"
value={
withdrawalDetails.withdrawal.reference ===
withdrawalDetails.withdrawal.withdrawalId
? "n/a"
: withdrawalDetails.withdrawal.reference
}
/>
</div>
<Separator className="my-6" />
<div className="flex items-center justify-between">
Expand Down
2 changes: 2 additions & 0 deletions apps/admin-panel/app/withdrawals/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ gql`
withdrawalId
amount
status
reference
customer {
customerId
email
Expand All @@ -55,6 +56,7 @@ gql`
withdrawalId
amount
status
reference
customer {
customerId
email
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ gql`
withdrawal {
withdrawalId
amount
reference
customer {
customerId
email
Expand Down Expand Up @@ -126,6 +127,15 @@ export function WithdrawalConfirmDialog({
/>
}
/>
<DetailItem
className="text-sm"
label="Withdrawal Reference"
value={
withdrawalData.reference === withdrawalData.withdrawalId
? "n/a"
: withdrawalData.reference
}
/>
</DetailsGroup>
{error && <p className="text-destructive">{error}</p>}
<DialogFooter>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,14 @@ export function WithdrawalCancelDialog({
/>
}
/>
<DetailItem
label="Withdrawal Reference"
value={
withdrawalData.reference === withdrawalData.withdrawalId
? "n/a"
: withdrawalData.reference
}
/>
</DetailsGroup>
{error && <p className="text-destructive">{error}</p>}
<DialogFooter>
Expand Down
23 changes: 16 additions & 7 deletions apps/admin-panel/lib/graphql/generated/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ export type Deposit = {
customer?: Maybe<Customer>;
customerId: Scalars['UUID']['output'];
depositId: Scalars['UUID']['output'];
reference: Scalars['String']['output'];
};

export type DepositConnection = {
Expand Down Expand Up @@ -856,6 +857,7 @@ export type Withdrawal = {
amount: Scalars['UsdCents']['output'];
customer?: Maybe<Customer>;
customerId: Scalars['UUID']['output'];
reference: Scalars['String']['output'];
status: WithdrawalStatus;
withdrawalId: Scalars['UUID']['output'];
};
Expand Down Expand Up @@ -977,7 +979,7 @@ export type GetWithdrawalsForCustomerQueryVariables = Exact<{
}>;


export type GetWithdrawalsForCustomerQuery = { __typename?: 'Query', customer?: { __typename?: 'Customer', customerId: string, withdrawals: Array<{ __typename?: 'Withdrawal', status: WithdrawalStatus, customerId: string, withdrawalId: string, amount: any, customer?: { __typename?: 'Customer', customerId: string, email: string } | null }> } | null };
export type GetWithdrawalsForCustomerQuery = { __typename?: 'Query', customer?: { __typename?: 'Customer', customerId: string, withdrawals: Array<{ __typename?: 'Withdrawal', status: WithdrawalStatus, reference: string, customerId: string, withdrawalId: string, amount: any, customer?: { __typename?: 'Customer', customerId: string, email: string } | null }> } | null };

export type GetCustomerByCustomerEmailQueryVariables = Exact<{
email: Scalars['String']['input'];
Expand All @@ -992,14 +994,14 @@ export type DepositsQueryVariables = Exact<{
}>;


export type DepositsQuery = { __typename?: 'Query', deposits: { __typename?: 'DepositConnection', pageInfo: { __typename?: 'PageInfo', hasPreviousPage: boolean, hasNextPage: boolean, startCursor?: string | null, endCursor?: string | null }, nodes: Array<{ __typename?: 'Deposit', customerId: string, depositId: string, amount: any, customer?: { __typename?: 'Customer', customerId: string, email: string } | null }> } };
export type DepositsQuery = { __typename?: 'Query', deposits: { __typename?: 'DepositConnection', pageInfo: { __typename?: 'PageInfo', hasPreviousPage: boolean, hasNextPage: boolean, startCursor?: string | null, endCursor?: string | null }, nodes: Array<{ __typename?: 'Deposit', customerId: string, depositId: string, amount: any, reference: string, customer?: { __typename?: 'Customer', customerId: string, email: string } | null }> } };

export type DepositQueryVariables = Exact<{
id: Scalars['UUID']['input'];
}>;


export type DepositQuery = { __typename?: 'Query', deposit?: { __typename?: 'Deposit', customerId: string, depositId: string, amount: any, customer?: { __typename?: 'Customer', customerId: string, email: string, applicantId?: string | null } | null } | null };
export type DepositQuery = { __typename?: 'Query', deposit?: { __typename?: 'Deposit', customerId: string, depositId: string, amount: any, reference: string, customer?: { __typename?: 'Customer', customerId: string, email: string, applicantId?: string | null } | null } | null };

export type GetLoanDetailsQueryVariables = Exact<{
id: Scalars['UUID']['input'];
Expand Down Expand Up @@ -1097,22 +1099,22 @@ export type GetWithdrawalDetailsQueryVariables = Exact<{
}>;


export type GetWithdrawalDetailsQuery = { __typename?: 'Query', withdrawal?: { __typename?: 'Withdrawal', customerId: string, withdrawalId: string, amount: any, status: WithdrawalStatus, customer?: { __typename?: 'Customer', email: string, customerId: string, applicantId?: string | null } | null } | null };
export type GetWithdrawalDetailsQuery = { __typename?: 'Query', withdrawal?: { __typename?: 'Withdrawal', customerId: string, withdrawalId: string, amount: any, status: WithdrawalStatus, reference: string, customer?: { __typename?: 'Customer', email: string, customerId: string, applicantId?: string | null } | null } | null };

export type WithdrawalsQueryVariables = Exact<{
first: Scalars['Int']['input'];
after?: InputMaybe<Scalars['String']['input']>;
}>;


export type WithdrawalsQuery = { __typename?: 'Query', withdrawals: { __typename?: 'WithdrawalConnection', pageInfo: { __typename?: 'PageInfo', hasPreviousPage: boolean, hasNextPage: boolean, startCursor?: string | null, endCursor?: string | null }, nodes: Array<{ __typename?: 'Withdrawal', customerId: string, withdrawalId: string, amount: any, status: WithdrawalStatus, customer?: { __typename?: 'Customer', customerId: string, email: string } | null }> } };
export type WithdrawalsQuery = { __typename?: 'Query', withdrawals: { __typename?: 'WithdrawalConnection', pageInfo: { __typename?: 'PageInfo', hasPreviousPage: boolean, hasNextPage: boolean, startCursor?: string | null, endCursor?: string | null }, nodes: Array<{ __typename?: 'Withdrawal', customerId: string, withdrawalId: string, amount: any, status: WithdrawalStatus, reference: string, customer?: { __typename?: 'Customer', customerId: string, email: string } | null }> } };

export type WithdrawalQueryVariables = Exact<{
id: Scalars['UUID']['input'];
}>;


export type WithdrawalQuery = { __typename?: 'Query', withdrawal?: { __typename?: 'Withdrawal', customerId: string, withdrawalId: string, amount: any, status: WithdrawalStatus, customer?: { __typename?: 'Customer', customerId: string, email: string, applicantId?: string | null } | null } | null };
export type WithdrawalQuery = { __typename?: 'Query', withdrawal?: { __typename?: 'Withdrawal', customerId: string, withdrawalId: string, amount: any, status: WithdrawalStatus, reference: string, customer?: { __typename?: 'Customer', customerId: string, email: string, applicantId?: string | null } | null } | null };

export type CustomerCreateMutationVariables = Exact<{
input: CustomerCreateInput;
Expand All @@ -1133,7 +1135,7 @@ export type WithdrawalConfirmMutationVariables = Exact<{
}>;


export type WithdrawalConfirmMutation = { __typename?: 'Mutation', withdrawalConfirm: { __typename?: 'WithdrawalConfirmPayload', withdrawal: { __typename?: 'Withdrawal', withdrawalId: string, amount: any, customer?: { __typename?: 'Customer', customerId: string, email: string, balance: { __typename?: 'CustomerBalance', checking: { __typename?: 'Checking', settled: any, pending: any } } } | null } } };
export type WithdrawalConfirmMutation = { __typename?: 'Mutation', withdrawalConfirm: { __typename?: 'WithdrawalConfirmPayload', withdrawal: { __typename?: 'Withdrawal', withdrawalId: string, amount: any, reference: string, customer?: { __typename?: 'Customer', customerId: string, email: string, balance: { __typename?: 'CustomerBalance', checking: { __typename?: 'Checking', settled: any, pending: any } } } | null } } };

export type WithdrawalInitiateMutationVariables = Exact<{
input: WithdrawalInitiateInput;
Expand Down Expand Up @@ -1730,6 +1732,7 @@ export const GetWithdrawalsForCustomerDocument = gql`
customerId
withdrawals {
status
reference
customerId
withdrawalId
amount
Expand Down Expand Up @@ -1827,6 +1830,7 @@ export const DepositsDocument = gql`
customerId
depositId
amount
reference
customer {
customerId
email
Expand Down Expand Up @@ -1870,6 +1874,7 @@ export const DepositDocument = gql`
customerId
depositId
amount
reference
customer {
customerId
email
Expand Down Expand Up @@ -2512,6 +2517,7 @@ export const GetWithdrawalDetailsDocument = gql`
withdrawalId
amount
status
reference
customer {
email
customerId
Expand Down Expand Up @@ -2562,6 +2568,7 @@ export const WithdrawalsDocument = gql`
withdrawalId
amount
status
reference
customer {
customerId
email
Expand Down Expand Up @@ -2606,6 +2613,7 @@ export const WithdrawalDocument = gql`
withdrawalId
amount
status
reference
customer {
customerId
email
Expand Down Expand Up @@ -2732,6 +2740,7 @@ export const WithdrawalConfirmDocument = gql`
withdrawal {
withdrawalId
amount
reference
customer {
customerId
email
Expand Down
2 changes: 2 additions & 0 deletions core/src/server/admin/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ type Deposit {
customerId: UUID!
depositId: UUID!
amount: UsdCents!
reference: String!
customer: Customer
}

Expand Down Expand Up @@ -669,6 +670,7 @@ type Withdrawal {
withdrawalId: UUID!
amount: UsdCents!
status: WithdrawalStatus!
reference: String!
customer: Customer
}

Expand Down
2 changes: 2 additions & 0 deletions core/src/server/public/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ type Deposit {
customerId: UUID!
depositId: UUID!
amount: UsdCents!
reference: String!
customer: Customer
}

Expand Down Expand Up @@ -227,6 +228,7 @@ type Withdrawal {
withdrawalId: UUID!
amount: UsdCents!
status: WithdrawalStatus!
reference: String!
customer: Customer
}

Expand Down
2 changes: 2 additions & 0 deletions core/src/server/shared_graphql/deposit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ pub struct Deposit {
customer_id: UUID,
deposit_id: UUID,
amount: UsdCents,
reference: String,
}

#[ComplexObject]
Expand All @@ -35,6 +36,7 @@ impl From<crate::deposit::Deposit> for Deposit {
deposit_id: UUID::from(deposit.id),
customer_id: UUID::from(deposit.customer_id),
amount: deposit.amount,
reference: deposit.reference,
}
}
}
2 changes: 2 additions & 0 deletions core/src/server/shared_graphql/withdraw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ pub struct Withdrawal {
withdrawal_id: UUID,
amount: UsdCents,
status: WithdrawalStatus,
reference: String,
}

#[ComplexObject]
Expand All @@ -39,6 +40,7 @@ impl From<crate::withdraw::Withdraw> for Withdrawal {
customer_id: UUID::from(withdraw.customer_id),
amount: withdraw.amount,
status: withdraw.status(),
reference: withdraw.reference,
}
}
}
3 changes: 3 additions & 0 deletions core/src/withdraw/entity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ impl EntityEvent for WithdrawEvent {
#[builder(pattern = "owned", build_fn(error = "EntityError"))]
pub struct Withdraw {
pub id: WithdrawId,
pub reference: String,
pub customer_id: CustomerId,
pub amount: UsdCents,
pub debit_account_id: LedgerAccountId,
Expand Down Expand Up @@ -142,13 +143,15 @@ impl TryFrom<EntityEvents<WithdrawEvent>> for Withdraw {
customer_id,
amount,
debit_account_id,
reference,
..
} => {
builder = builder
.id(*id)
.customer_id(*customer_id)
.amount(*amount)
.debit_account_id(*debit_account_id)
.reference(reference.clone())
}
WithdrawEvent::Confirmed { .. } => {}
WithdrawEvent::Cancelled { .. } => {}
Expand Down

0 comments on commit 061fdf9

Please sign in to comment.