Skip to content

Commit

Permalink
refactor navigation in transaction views
Browse files Browse the repository at this point in the history
  • Loading branch information
cjdenio committed Mar 22, 2024
1 parent 2c9965c commit 076f348
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 41 deletions.
7 changes: 1 addition & 6 deletions src/components/transaction/types/AchTransferTransaction.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import { useNavigation } from "@react-navigation/native";
import { NativeStackNavigationProp } from "@react-navigation/native-stack";
import { View } from "react-native";

import { StackParamList } from "../../../lib/NavigatorParamList";
import { TransactionAchTransfer } from "../../../lib/types/Transaction";
import { palette } from "../../../theme";
import { renderMoney } from "../../../util";
Expand All @@ -16,10 +13,8 @@ import { TransactionViewProps } from "./TransactionViewProps";
export default function AchTransferTransaction({
transaction: { ach_transfer, ...transaction },
orgId,
navigation,
}: TransactionViewProps<TransactionAchTransfer>) {
const navigation =
useNavigation<NativeStackNavigationProp<StackParamList, "Transaction">>();

return (
<View>
<TransactionTitle
Expand Down
7 changes: 1 addition & 6 deletions src/components/transaction/types/BankAccountTransaction.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import { useNavigation } from "@react-navigation/native";
import { NativeStackNavigationProp } from "@react-navigation/native-stack";
import { Text, View } from "react-native";

import { StackParamList } from "../../../lib/NavigatorParamList";
import { palette } from "../../../theme";
import { renderDate, renderMoney } from "../../../util";
import TransactionDetails, { descriptionDetail } from "../TransactionDetails";
Expand All @@ -12,11 +9,9 @@ import { TransactionViewProps } from "./TransactionViewProps";

export default function BankAccountTransaction({
transaction,
navigation,
...props
}: TransactionViewProps) {
const navigation =
useNavigation<NativeStackNavigationProp<StackParamList, "Transaction">>();

return (
<View>
<TransactionTitle>
Expand Down
6 changes: 1 addition & 5 deletions src/components/transaction/types/BankFeeTransaction.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import { useNavigation } from "@react-navigation/native";
import { NativeStackNavigationProp } from "@react-navigation/native-stack";
import { Text, View } from "react-native";
import useSWR from "swr";

import { StackParamList } from "../../../lib/NavigatorParamList";
import Organization from "../../../lib/types/Organization";
import { palette } from "../../../theme";
import { renderDate, renderMoney } from "../../../util";
Expand All @@ -15,12 +12,11 @@ import { TransactionViewProps } from "./TransactionViewProps";
export default function BankFeeTransaction({
transaction,
orgId,
navigation,
}: TransactionViewProps) {
const { data: organization } = useSWR<Organization>(
`/organizations/${orgId}`,
);
const navigation =
useNavigation<NativeStackNavigationProp<StackParamList, "Transaction">>();

return (
<View>
Expand Down
7 changes: 1 addition & 6 deletions src/components/transaction/types/CardChargeTransaction.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import { useNavigation } from "@react-navigation/native";
import { NativeStackNavigationProp } from "@react-navigation/native-stack";
import { View } from "react-native";

import { StackParamList } from "../../../lib/NavigatorParamList";
import { TransactionCardCharge } from "../../../lib/types/Transaction";
import { palette } from "../../../theme";
import { renderDate, renderMoney } from "../../../util";
Expand All @@ -20,10 +17,8 @@ export default function CardChargeTransaction({
...transaction
},
orgId,
navigation,
}: TransactionViewProps<TransactionCardCharge>) {
const navigation =
useNavigation<NativeStackNavigationProp<StackParamList, "Transaction">>();

const isRefund = transaction.amount_cents > 0;

const badge = transaction.pending ? (
Expand Down
7 changes: 1 addition & 6 deletions src/components/transaction/types/CheckTransaction.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import { useNavigation } from "@react-navigation/native";
import { NativeStackNavigationProp } from "@react-navigation/native-stack";
import humanizeString from "humanize-string";
import { View } from "react-native";

import { StackParamList } from "../../../lib/NavigatorParamList";
import { TransactionCheck } from "../../../lib/types/Transaction";
import { renderMoney, statusColor } from "../../../util";
import Badge from "../../Badge";
Expand All @@ -15,11 +12,9 @@ import { TransactionViewProps } from "./TransactionViewProps";

export default function CheckTransaction({
transaction: { check, ...transaction },
navigation,
...props
}: TransactionViewProps<TransactionCheck>) {
const navigation =
useNavigation<NativeStackNavigationProp<StackParamList, "Transaction">>();

return (
<View>
<TransactionTitle
Expand Down
7 changes: 1 addition & 6 deletions src/components/transaction/types/DonationTransaction.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import { Ionicons } from "@expo/vector-icons";
import { useNavigation } from "@react-navigation/native";
import { NativeStackNavigationProp } from "@react-navigation/native-stack";
import { Text, View } from "react-native";

import { StackParamList } from "../../../lib/NavigatorParamList";
import { TransactionDonation } from "../../../lib/types/Transaction";
import { palette } from "../../../theme";
import { renderMoney } from "../../../util";
Expand All @@ -15,11 +12,9 @@ import { TransactionViewProps } from "./TransactionViewProps";

export default function DonationTransaction({
transaction: { donation, ...transaction },
navigation,
...props
}: TransactionViewProps<TransactionDonation>) {
const navigation =
useNavigation<NativeStackNavigationProp<StackParamList, "Transaction">>();

return (
<View>
<TransactionTitle
Expand Down
7 changes: 1 addition & 6 deletions src/components/transaction/types/TransferTransaction.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import { useNavigation } from "@react-navigation/native";
import { NativeStackNavigationProp } from "@react-navigation/native-stack";
import humanizeString from "humanize-string";
import { View } from "react-native";
import useSWR from "swr";

import { StackParamList } from "../../../lib/NavigatorParamList";
import Organization from "../../../lib/types/Organization";
import { TransactionTransfer } from "../../../lib/types/Transaction";
import User from "../../../lib/types/User";
Expand All @@ -18,6 +15,7 @@ import { TransactionViewProps } from "./TransactionViewProps";

export default function TransferTransaction({
transaction: { transfer, ...transaction },
navigation,
...props
}: TransactionViewProps<TransactionTransfer>) {
const { data: userOrgs } = useSWR<Organization[]>(`/user/organizations`);
Expand All @@ -28,9 +26,6 @@ export default function TransferTransaction({
const userInToOrg =
user?.admin || userOrgs?.some((org) => org.id == transfer.to.id);

const navigation =
useNavigation<NativeStackNavigationProp<StackParamList, "Transaction">>();

return (
<View>
<TransactionTitle
Expand Down

0 comments on commit 076f348

Please sign in to comment.