From ba379dac95d07bfb67a412c74d33119f400a750b Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Tue, 23 Jul 2024 04:20:41 +0000 Subject: [PATCH] style: format code with StandardJS This commit fixes the style issues introduced in edb8084 according to the output from StandardJS. Details: None --- .../settingComponents/UpgradeBox.jsx | 194 +++++++++--------- src/pages/settings/billing.jsx | 130 ++++++------ 2 files changed, 161 insertions(+), 163 deletions(-) diff --git a/src/components/settingComponents/UpgradeBox.jsx b/src/components/settingComponents/UpgradeBox.jsx index 6f2851b7..e1bf75a2 100644 --- a/src/components/settingComponents/UpgradeBox.jsx +++ b/src/components/settingComponents/UpgradeBox.jsx @@ -1,172 +1,172 @@ +import request from '@/utils/request' +import { loadStripe } from '@stripe/stripe-js' +import { useState } from 'react' +const STRIPE_KEY = process.env.NEXT_PUBLIC_APP_STRIPE_KEY +const subscriptionTypes = ['PRO_MONTHLY', 'PRO_YEARLY'] -import request from '@/utils/request'; -import { loadStripe } from '@stripe/stripe-js'; -const STRIPE_KEY = process.env.NEXT_PUBLIC_APP_STRIPE_KEY; -import { useState } from 'react'; -const subscriptionTypes = ['PRO_MONTHLY', 'PRO_YEARLY']; - -export default function UpgradeBox() { - const [loading, setLoading] = useState(-1); +export default function UpgradeBox () { + const [loading, setLoading] = useState(-1) const redirectToCheckout = async (subIdx) => { - setLoading(subIdx); + setLoading(subIdx) try { - - const stripe = await loadStripe(STRIPE_KEY); - const subscriptionType = subscriptionTypes[subIdx]; + const stripe = await loadStripe(STRIPE_KEY) + const subscriptionType = subscriptionTypes[subIdx] const body = { subType: subscriptionType, quantity: 1, operation: 'subscription', - data: {}, + data: {} } - const url = `${process.env.NEXT_PUBLIC_API_URL}/payments/stripe/create-checkout-session`; - const session = await request(url, 'POST', body); + const url = `${process.env.NEXT_PUBLIC_API_URL}/payments/stripe/create-checkout-session` + const session = await request(url, 'POST', body) if (session.error) { - console.log('Creating the stripe session failed'); - return; + console.log('Creating the stripe session failed') + return } const result = await stripe.redirectToCheckout({ - sessionId: session.sessionId, - }); + sessionId: session.sessionId + }) if (result.error) { - console.log(result.error.message); + console.log(result.error.message) } } catch (error) { - console.log("INTERNAL SERVER ERRROROOROR") - console.log(error); + console.log('INTERNAL SERVER ERRROROOROR') + console.log(error) } - setLoading(-1); - }; + setLoading(-1) + } return ( <> -
-
-
Pro plan
-
- $ - 5 - /month -
-
- Yearly subscribers save $2/month -
+
+
+
Pro plan
+
+ $ + 5 + /month +
+
+ Yearly subscribers save $2/month +
-
    -
  • +
      +
    • - + Acess to challenge catalog
    • -
    • +
    • - + Increased terminal time
    • -
    • +
    • - + No ads
    • -
    • +
    • - + Custom banner images
    • -
    • +
    • - + PRO badge
    • -
    • +
    • - + Colored username
    • -
    • +
    • - + Acess to upcoming beta features
    -
    +
    -
    - ); + ) } diff --git a/src/pages/settings/billing.jsx b/src/pages/settings/billing.jsx index 93377c89..225e0bee 100644 --- a/src/pages/settings/billing.jsx +++ b/src/pages/settings/billing.jsx @@ -1,20 +1,19 @@ -import { loadStripe } from '@stripe/stripe-js'; -const STRIPE_KEY = process.env.NEXT_PUBLIC_APP_STRIPE_KEY; -import Head from 'next/head'; -import { Footer } from '@/components/Footer'; -import { useState, useEffect } from 'react'; - -import { StandardNav } from '@/components/StandardNav'; -import Sidebar from '@/components/settingComponents/sidebar'; -import UpgradeBox from '@/components/settingComponents/UpgradeBox'; -import FreeBox from '@/components/settingComponents/FreeBox'; -import Dropdown from '@/components/settingComponents/dropdown'; // Import the new Dropdown component - -export default function Billing() { - +import { loadStripe } from '@stripe/stripe-js' +import Head from 'next/head' +import { Footer } from '@/components/Footer' +import { useState, useEffect } from 'react' + +import { StandardNav } from '@/components/StandardNav' +import Sidebar from '@/components/settingComponents/sidebar' +import UpgradeBox from '@/components/settingComponents/UpgradeBox' +import FreeBox from '@/components/settingComponents/FreeBox' +import Dropdown from '@/components/settingComponents/dropdown' +const STRIPE_KEY = process.env.NEXT_PUBLIC_APP_STRIPE_KEY // Import the new Dropdown component + +export default function Billing () { const updateCardInfo = async () => { try { - window.location.href = 'https://billing.stripe.com/p/login/28o4i86t419hh1K3cc'; + window.location.href = 'https://billing.stripe.com/p/login/28o4i86t419hh1K3cc' /* const stripe = await loadStripe(STRIPE_KEY); const response = await fetch( @@ -37,53 +36,53 @@ export default function Billing() { }); */ } catch (error) { - console.log(error); + console.log(error) } - }; + } const cancelSubscription = async () => { try { - const subscriptionType = document.getElementById('paymentType').value; - const url = `${process.env.NEXT_PUBLIC_API_URL}/payments/stripe/cancel`; + const subscriptionType = document.getElementById('paymentType').value + const url = `${process.env.NEXT_PUBLIC_API_URL}/payments/stripe/cancel` const response = await fetch(url, { method: 'PUT', credentials: 'include', body: JSON.stringify({ - subType: subscriptionType, + subType: subscriptionType }), headers: { - 'Content-Type': 'application/json', - }, - }); - const data = await response.json(); - // console.log(data.message); + 'Content-Type': 'application/json' + } + }) + const data = await response.json() + // console.log(data.message); } catch (err) { - console.log(err); + console.log(err) } - }; + } - const [isMobile, setIsMobile] = useState(false); + const [isMobile, setIsMobile] = useState(false) useEffect(() => { const handleResize = () => { - setIsMobile(window.innerWidth <= 768); - }; + setIsMobile(window.innerWidth <= 768) + } - handleResize(); // Check on initial render - window.addEventListener('resize', handleResize); + handleResize() // Check on initial render + window.addEventListener('resize', handleResize) return () => { - window.removeEventListener('resize', handleResize); - }; - }, []); + window.removeEventListener('resize', handleResize) + } + }, []) return ( <> User Settings