Skip to content

Commit

Permalink
Receivers: amount is optional (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
quietbits authored Sep 25, 2023
1 parent 17e6336 commit b27de39
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 18 deletions.
6 changes: 4 additions & 2 deletions src/components/AssetAmount/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import "./styles.scss";

interface AssetAmountProps {
amount?: string;
assetCode: string;
assetCode?: string;
fallback?: string;
showIcon?: boolean;
}
Expand Down Expand Up @@ -41,7 +41,9 @@ export const AssetAmount: React.FC<AssetAmountProps> = ({
return (
<span className="AssetAmount">
{decimal.format(Number(amount))}
<span className="AssetAmount__code">{assetCode}</span>
{assetCode ? (
<span className="AssetAmount__code">{assetCode}</span>
) : null}
{showIcon ? (
<span className="AssetAmount__icon">
{foundAsset ? (
Expand Down
8 changes: 6 additions & 2 deletions src/components/MultipleAmounts/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@ import { DropdownMenu } from "components/DropdownMenu";
import { AmountReceived } from "types";
import "./styles.scss";

export const MultipleAmounts = ({ amounts }: { amounts: AmountReceived[] }) => {
if (amounts.length === 0) {
export const MultipleAmounts = ({
amounts,
}: {
amounts?: AmountReceived[];
}) => {
if (!amounts || amounts.length === 0) {
return <>"-"</>;
}

Expand Down
2 changes: 1 addition & 1 deletion src/generated/gitInfo.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export default { commitHash: "4f12382", version: "1.0.0-rc1-9-g4f12382" };
export default { commitHash: "17e6336", version: "1.0.0-rc1-10-g17e6336" };
2 changes: 1 addition & 1 deletion src/helpers/formatReceivers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const formatReceivers = (receivers: ApiReceiver[]): Receiver[] => {
totalPaymentsCount: Number(r.total_payments),
successfulPaymentsCounts: Number(r.successful_payments),
createdAt: r.created_at,
amountsReceived: r.received_amounts.map((a) => ({
amountsReceived: r.received_amounts?.map((a) => ({
assetCode: a.asset_code,
assetIssuer: a.asset_issuer,
amount: a.received_amount,
Expand Down
2 changes: 1 addition & 1 deletion src/store/ducks/paymentDetails.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ const formatPaymentReceiver = (payload: {
totalPaymentsCount: Number(receiver.total_payments),
successfulPaymentsCount: Number(receiver.successful_payments),
createdAt: paymentWallet?.created_at || "",
amountsReceived: receiver.received_amounts.map((a) => ({
amountsReceived: receiver.received_amounts?.map((a) => ({
amount: a.received_amount,
assetCode: a.asset_code,
assetIssuer: a.asset_issuer,
Expand Down
8 changes: 4 additions & 4 deletions src/store/ducks/receiverDetails.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ const initialState: ReceiverDetailsInitialState = {
id: "",
phoneNumber: "",
email: "",
assetCode: "",
totalReceived: "",
assetCode: undefined,
totalReceived: undefined,
orgId: "",
stats: {
paymentsTotalCount: 0,
Expand Down Expand Up @@ -167,8 +167,8 @@ const formatReceiver = (receiver: ApiReceiver): ReceiverDetails => ({
email: receiver.email,
orgId: receiver.external_id,
// TODO: how to handle multiple
assetCode: receiver.received_amounts[0].asset_code,
totalReceived: receiver.received_amounts[0].received_amount,
assetCode: receiver.received_amounts?.[0].asset_code,
totalReceived: receiver.received_amounts?.[0].received_amount,
stats: {
paymentsTotalCount: Number(receiver.total_payments),
paymentsSuccessfulCount: Number(receiver.successful_payments),
Expand Down
14 changes: 7 additions & 7 deletions src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,8 @@ export type ReceiverDetailsInitialState = {
id: string;
phoneNumber: string;
email?: string;
assetCode: string;
totalReceived: string;
assetCode?: string;
totalReceived?: string;
orgId: string;
stats: {
paymentsTotalCount: number;
Expand Down Expand Up @@ -439,7 +439,7 @@ export type PaymentDetailsReceiver = {
totalPaymentsCount: number;
successfulPaymentsCount: number;
createdAt: string;
amountsReceived: AmountReceived[];
amountsReceived?: AmountReceived[];
status: ReceiverStatus | undefined;
};

Expand All @@ -466,7 +466,7 @@ export type Receiver = {
totalPaymentsCount: number;
successfulPaymentsCounts: number;
createdAt: string;
amountsReceived: AmountReceived[];
amountsReceived?: AmountReceived[];
};

export type ReceiverWallet = {
Expand Down Expand Up @@ -511,8 +511,8 @@ export type ReceiverDetails = {
id: string;
phoneNumber: string;
email?: string;
assetCode: string;
totalReceived: string;
assetCode?: string;
totalReceived?: string;
orgId: string;
stats: {
paymentsTotalCount: number;
Expand Down Expand Up @@ -830,7 +830,7 @@ export type ApiReceiver = {
successful_payments: string | number;
failed_payments: string | number;
remaining_payments: string | number;
received_amounts: {
received_amounts?: {
asset_code: string;
asset_issuer: string;
received_amount: string;
Expand Down

0 comments on commit b27de39

Please sign in to comment.