Skip to content

FinceptTerminal is a modern finance application offering advanced market analytics, investment research, and economic data tools, designed for interactive exploration and data-driven decision-making in a user-friendly environment.

refactor: extract PaymentOverlay component to remove duplicated InAppPaymentWindow code

Josh Caron48e3b97036b5
diff --git a/.gitignore b/.gitignore
index 93cc63164..2e74ddd8a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -43,4 +43,5 @@ get-pip.py
temp
tempdist
settings.json
-watchlist_settings.json
\ No newline at end of file
+watchlist_settings.json
+.DS_Store
\ No newline at end of file
diff --git a/fincept-terminal-desktop/src/App.tsx b/fincept-terminal-desktop/src/App.tsx
index dab0b3834..3e8ea2de5 100644
--- a/fincept-terminal-desktop/src/App.tsx
+++ b/fincept-terminal-desktop/src/App.tsx
@@ -13,7 +13,6 @@ import HelpScreen from './components/auth/HelpScreen';
import PricingScreen from './components/auth/PricingScreen';
import PaymentProcessingScreen from './components/payment/PaymentProcessingScreen';
import PaymentSuccessScreen from './components/payment/PaymentSuccessScreen';
-import InAppPaymentWindow from './components/payment/InAppPaymentWindow';
import ContactUsScreen from './components/info/ContactUsScreen';
import TermsOfServiceScreen from './components/info/TermsOfServiceScreen';
import TrademarksScreen from './components/info/TrademarksScreen';
@@ -22,6 +21,7 @@ import DashboardScreen from './components/dashboard/DashboardScreen';
import BackgroundPattern from './components/common/BackgroundPattern';
import Header from './components/common/Header';
import Footer from './components/common/Footer';
+import PaymentOverlay from './components/payment/PaymentOverlay';
export type Screen =
| 'login'
@@ -194,16 +194,7 @@ const App: React.FC = () => {
<>
<DashboardScreen />
{/* In-App Payment Window Overlay */}
- {paymentWindow.isOpen && (
- <InAppPaymentWindow
- checkoutUrl={paymentWindow.checkoutUrl}
- planName={paymentWindow.planName}
- planPrice={paymentWindow.planPrice}
- onSuccess={paymentWindow.onSuccess || (() => {})}
- onCancel={paymentWindow.onCancel || (() => {})}
- onError={paymentWindow.onError || (() => {})}
- />
- )}
+ <PaymentOverlay paymentWindow={paymentWindow} />
</>
);
}
@@ -217,16 +208,7 @@ const App: React.FC = () => {
{renderPaymentScreen()}
</div>
{/* In-App Payment Window Overlay */}
- {paymentWindow.isOpen && (
- <InAppPaymentWindow
- checkoutUrl={paymentWindow.checkoutUrl}
- planName={paymentWindow.planName}
- planPrice={paymentWindow.planPrice}
- onSuccess={paymentWindow.onSuccess || (() => {})}
- onCancel={paymentWindow.onCancel || (() => {})}
- onError={paymentWindow.onError || (() => {})}
- />
- )}
+ <PaymentOverlay paymentWindow={paymentWindow} />
</div>
);
}
@@ -331,16 +313,7 @@ const App: React.FC = () => {
<Footer onNavigate={setCurrentScreen} />
{/* In-App Payment Window Overlay - Available on all screens */}
- {paymentWindow.isOpen && (
- <InAppPaymentWindow
- checkoutUrl={paymentWindow.checkoutUrl}
- planName={paymentWindow.planName}
- planPrice={paymentWindow.planPrice}
- onSuccess={paymentWindow.onSuccess || (() => {})}
- onCancel={paymentWindow.onCancel || (() => {})}
- onError={paymentWindow.onError || (() => {})}
- />
- )}
+ <PaymentOverlay paymentWindow={paymentWindow} />
</div>
);
};
diff --git a/fincept-terminal-desktop/src/components/payment/PaymentOverlay.tsx b/fincept-terminal-desktop/src/components/payment/PaymentOverlay.tsx
new file mode 100644
index 000000000..59bc3b13c
--- /dev/null
+++ b/fincept-terminal-desktop/src/components/payment/PaymentOverlay.tsx
@@ -0,0 +1,29 @@
+import React from 'react';
+import InAppPaymentWindow from './InAppPaymentWindow';
+
+interface PaymentWindowState {
+ isOpen: boolean;
+ checkoutUrl: string;
+ planName: string;
+ planPrice: number;
+ onSuccess?: () => void;
+ onCancel?: () => void;
+ onError?: (error: string) => void;
+}
+
+const PaymentOverlay: React.FC<{ paymentWindow: PaymentWindowState }> = ({ paymentWindow }) => {
+ if (!paymentWindow.isOpen) return null;
+
+ return (
+ <InAppPaymentWindow
+ checkoutUrl={paymentWindow.checkoutUrl}
+ planName={paymentWindow.planName}
+ planPrice={paymentWindow.planPrice}
+ onSuccess={paymentWindow.onSuccess || (() => {})}
+ onCancel={paymentWindow.onCancel || (() => {})}
+ onError={paymentWindow.onError || (() => {})}
+ />
+ );
+};
+
+export default PaymentOverlay;