Skip to content

Commit

Permalink
View account/routing numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
cjdenio committed Mar 18, 2024
1 parent 5d42cd7 commit ab62040
Show file tree
Hide file tree
Showing 8 changed files with 161 additions and 4 deletions.
6 changes: 6 additions & 0 deletions app.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ export default {
cameraPermission: "Allow HCB to take photos of receipts",
},
],
[
"expo-font",
{
fonts: ["./assets/fonts/JetBrainsMono-Regular.ttf"],
},
],
"expo-secure-store",
["@config-plugins/react-native-dynamic-app-icon", appIconConfig],
],
Expand Down
Binary file added assets/fonts/JetBrainsMono-Regular.ttf
Binary file not shown.
9 changes: 9 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@
"react-native-screens": "~3.29.0",
"react-native-svg": "14.1.0",
"react-native-web": "^0.19.8",
"swr": "^2.2.1"
"swr": "^2.2.1",
"expo-clipboard": "~5.0.1"
},
"devDependencies": {
"@babel/core": "^7.22.11",
Expand Down
8 changes: 7 additions & 1 deletion src/Navigator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import CardsPage from "./pages/cards";
import Home from "./pages/index";
import InvitationPage from "./pages/Invitation";
import OrganizationPage from "./pages/organization";
import AccountNumberPage from "./pages/organization/AccountNumber";
import ReceiptsPage from "./pages/Receipts";
import RenameTransactionPage from "./pages/RenameTransaction";
import SettingsPage from "./pages/Settings";
Expand Down Expand Up @@ -130,11 +131,16 @@ export default function Navigator() {
name="Event"
options={({ route }) => ({
// headerTitle: () => <OrganizationTitle {...route.params} />,
title: route.params.organization?.name,
title: route.params.organization?.name || "Organization",
headerBackTitle: "Back",
})}
component={OrganizationPage}
/>
<Stack.Screen
name="AccountNumber"
component={AccountNumberPage}
options={{ presentation: "modal", title: "Account Details" }}
/>
<Stack.Screen
options={{ headerBackTitle: "Back" }}
name="Transaction"
Expand Down
1 change: 1 addition & 0 deletions src/lib/NavigatorParamList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export type StackParamList = {
Organizations: undefined;
Invitation: { inviteId: Invitation["id"]; invitation?: Invitation };
Event: { orgId: Organization["id"]; organization?: Organization };
AccountNumber: { orgId: Organization["id"] };
Transaction: {
transactionId: Transaction["id"];
orgId?: Organization["id"];
Expand Down
127 changes: 127 additions & 0 deletions src/pages/organization/AccountNumber.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
import { Ionicons } from "@expo/vector-icons";
import { useTheme } from "@react-navigation/native";
import { NativeStackScreenProps } from "@react-navigation/native-stack";
import * as Clipboard from "expo-clipboard";
import { useEffect, useState } from "react";
import { View, Text, StatusBar, Button } from "react-native";
import useSWR from "swr";

import { StackParamList } from "../../lib/NavigatorParamList";
import { OrganizationExpanded } from "../../lib/types/Organization";
import { palette } from "../../theme";

type Props = NativeStackScreenProps<StackParamList, "AccountNumber">;

function AccountDetail({
title,
value,
}: {
title: string;
value: string | undefined;
}) {
const { colors: themeColors } = useTheme();
const [copied, setCopied] = useState(false);

useEffect(() => {
if (copied) {
const timeout = setTimeout(() => setCopied(false), 2000);
return () => clearTimeout(timeout);
}
}, [copied]);

return (
<View>
<Text style={{ color: palette.muted, fontSize: 16 }}>{title}</Text>
<View
style={{ flexDirection: "row", alignItems: "center", marginBottom: 20 }}
>
<Text
style={{
color: themeColors.text,
fontFamily: "JetBrains Mono",
fontSize: 30,
}}
>
{value}
</Text>
<Ionicons.Button
name={copied ? "checkmark" : "copy-outline"}
iconStyle={{ marginRight: 0 }}
color={copied ? palette.success : palette.primary}
backgroundColor="transparent"
underlayColor={themeColors.background}
onPress={() => {
if (value) {
Clipboard.setStringAsync(value);
setCopied(true);
}
}}
/>
</View>
</View>
);
}

export default function AccountNumberPage({
navigation,
route: {
params: { orgId },
},
}: Props) {
const { data: organization } = useSWR<OrganizationExpanded>(
`/organizations/${orgId}`,
);

useEffect(() => {
navigation.setOptions({
headerLeft: () => (
<Button
title="Done"
color={palette.primary}
onPress={() => navigation.goBack()}
/>
),
});
}, []);

return (
<View
style={{
padding: 20,
display: "flex",
alignItems: "center",
justifyContent: "center",
flex: 1,
}}
>
<StatusBar barStyle="light-content" />

<View style={{ flexDirection: "column" }}>
<AccountDetail
title="Routing number"
value={organization?.routing_number}
/>
<AccountDetail
title="Account number"
value={organization?.account_number}
/>
<AccountDetail
title="SWIFT BIC code"
value={organization?.swift_bic_code}
/>

<View style={{ flexDirection: "row" }}>
<Ionicons
name="information-circle-outline"
color={palette.muted}
size={20}
style={{ marginRight: 10 }}
/>
<Text style={{ alignSelf: "center", color: palette.muted }}>
Use these details to receive ACH and wire transfers.
</Text>
</View>
</View>
</View>
);
}
11 changes: 9 additions & 2 deletions src/pages/organization/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,18 @@ export default function OrganizationPage({
actions={[
{
id: "accountNumber",
title: "View Account Number",
attributes: { disabled: true },
title: "View Account Details",
image: "creditcard.and.123",
},
]}
themeVariant={scheme || undefined}
onPressAction={({ nativeEvent: { event } }) => {
if (event == "accountNumber") {
navigation.navigate("AccountNumber", {
orgId: organization.id,
});
}
}}
>
<Ionicons.Button
name="ellipsis-horizontal-circle"
Expand Down

0 comments on commit ab62040

Please sign in to comment.