From b15b7536f88af00c60c1277ca7529448f740a6b3 Mon Sep 17 00:00:00 2001 From: Muktar Date: Mon, 19 Aug 2024 20:59:37 +0100 Subject: [PATCH] fix: eslint --- .../payment-information/[slug]/page.tsx | 52 +- .../_components/checkoutForm/checkoutForm.tsx | 604 +++++++++--------- .../_components/currentPlan.tsx | 7 +- .../payment-information/basic/basicPlan.tsx | 256 -------- .../payment-information/basic/page.tsx | 11 - .../basicPlan/basicPlan.tsx | 128 ++-- .../payment-information/checkout/page.tsx | 49 +- .../settings/payment-information/page.tsx | 13 +- src/app/invite/page.tsx | 78 ++- src/contexts/orgContext.tsx | 9 +- 10 files changed, 479 insertions(+), 728 deletions(-) delete mode 100644 src/app/dashboard/(admin)/admin/(settings)/settings/payment-information/basic/basicPlan.tsx delete mode 100644 src/app/dashboard/(admin)/admin/(settings)/settings/payment-information/basic/page.tsx diff --git a/src/app/dashboard/(admin)/admin/(settings)/settings/payment-information/[slug]/page.tsx b/src/app/dashboard/(admin)/admin/(settings)/settings/payment-information/[slug]/page.tsx index 26905776f..9e706a251 100644 --- a/src/app/dashboard/(admin)/admin/(settings)/settings/payment-information/[slug]/page.tsx +++ b/src/app/dashboard/(admin)/admin/(settings)/settings/payment-information/[slug]/page.tsx @@ -1,29 +1,29 @@ -/* eslint-disable prettier/prettier */ - -"use client" +"use client"; -import { useState, useEffect } from 'react'; -import { getApiUrl } from '~/actions/getApiUrl'; -import axios from 'axios'; -import { useToast } from '~/components/ui/use-toast'; -import CheckoutForm from '../_components/checkoutForm/checkoutForm'; -import Link from 'next/link'; - -import { ArrowLeft } from 'lucide-react'; +import axios from "axios"; +import { ArrowLeft } from "lucide-react"; +import Link from "next/link"; +import { useEffect, useState } from "react"; + +import { getApiUrl } from "~/actions/getApiUrl"; +import { useToast } from "~/components/ui/use-toast"; +import CheckoutForm from "../_components/checkoutForm/checkoutForm"; const Page = ({ params }: { params: { slug: string } }) => { const [plan, setPlan] = useState({ id: "", name: "", - price: 0 - }) - const { toast } = useToast() + price: 0, + }); + const { toast } = useToast(); useEffect(() => { const getSpecificPlan = async () => { try { const apiUrl = await getApiUrl(); - const response = await axios.get(`${apiUrl}/api/v1/billing-plans/${params.slug}`); + const response = await axios.get( + `${apiUrl}/api/v1/billing-plans/${params.slug}`, + ); setPlan(response.data.data); } catch { toast({ @@ -37,21 +37,21 @@ const Page = ({ params }: { params: { slug: string } }) => { }, [toast, params.slug]); return ( -
-
-
- +
+
+
+ -

{`Upgrade to ${plan.name}`}

+

{`Upgrade to ${plan.name}`}

-

Do more with unlimited users and Integration when you upgrade

+

+ Do more with unlimited users and Integration when you upgrade +

- {/* */} - {/* */}
- ) -} + ); +}; -export default Page +export default Page; diff --git a/src/app/dashboard/(admin)/admin/(settings)/settings/payment-information/_components/checkoutForm/checkoutForm.tsx b/src/app/dashboard/(admin)/admin/(settings)/settings/payment-information/_components/checkoutForm/checkoutForm.tsx index d81f428b7..c69b2e020 100644 --- a/src/app/dashboard/(admin)/admin/(settings)/settings/payment-information/_components/checkoutForm/checkoutForm.tsx +++ b/src/app/dashboard/(admin)/admin/(settings)/settings/payment-information/_components/checkoutForm/checkoutForm.tsx @@ -1,327 +1,323 @@ -/* eslint-disable unicorn/prevent-abbreviations */ -/* eslint-disable unused-imports/no-unused-imports */ -/* eslint-disable prettier/prettier */ -/* eslint-disable unused-imports/no-unused-vars */ -/* eslint-disable @typescript-eslint/no-unused-vars */ -'use client' -import { useState, useEffect } from "react"; -import Link from "next/link"; +"use client"; + import axios from "axios"; -import { getApiUrl } from "~/actions/getApiUrl"; +import { ChevronDown } from "lucide-react"; import Image from "next/image"; -import { Organisation } from "~/types"; -import { useLocalStorage } from "~/hooks/use-local-storage"; +import Link from "next/link"; +import { useEffect, useState } from "react"; + +import { getApiUrl } from "~/actions/getApiUrl"; import { - Dialog, - DialogContent, - DialogDescription, - DialogFooter, - DialogHeader, - DialogTitle, - DialogTrigger, -} from "~/components/ui/dialog" -import { fetchStripeUrl } from "~/actions/payments"; + Dialog, + DialogContent, + DialogDescription, + DialogFooter, + DialogHeader, + DialogTitle, + DialogTrigger, +} from "~/components/ui/dialog"; import { useToast } from "~/components/ui/use-toast"; -import { ChevronDown } from "lucide-react"; +import { useLocalStorage } from "~/hooks/use-local-storage"; interface planProperties { - id: string; - name: string, - price: number + id: string; + name: string; + price: number; } - const CheckoutForm = ({ plan }: { plan: planProperties | undefined }) => { - const [formData, setFormData] = useState({ - fullName: "", - businessName: "", - billingOption: "monthly", - paymentMethod: "stripe", - }); - const [isDialogOpen, setIsDialogOpen] = useState(false); - - const { toast } = useToast(); - - const [userOrg] = useLocalStorage("user_org", []); - - const [currentOrgId] = useLocalStorage( - "current_orgid", - "", - ); - const [isTermsChecked, setIsTermsChecked] = useState(false); - const [pricePerMonth, setPricePerMonth] = useState() - const [pricePerYear, setPricePerYear] = useState() - const [priceDesc, setPriceDesc] = useState(false) - - useEffect(() => { - - if (plan) { - setPricePerMonth(plan.price); - setPricePerYear(plan.price * 10); - } - }, [plan, isTermsChecked, pricePerMonth, pricePerYear]) - - - const handleInputChange = (e: React.ChangeEvent) => { - const { name, value } = e.target; - setFormData({ - ...formData, - [name]: value, - }); - }; - - const handleCheckboxChange = (e: React.ChangeEvent) => { - setIsTermsChecked(e.target.checked); - }; - - const priceDropDown = () => { - setPriceDesc(prev => !prev) + const [formData, setFormData] = useState({ + fullName: "", + businessName: "", + billingOption: "monthly", + paymentMethod: "stripe", + }); + const [isDialogOpen, setIsDialogOpen] = useState(false); + + useToast(); + + const [currentOrgId] = useLocalStorage( + "current_orgid", + "", + ); + const [isTermsChecked, setIsTermsChecked] = useState(false); + const [pricePerMonth, setPricePerMonth] = useState(); + const [pricePerYear, setPricePerYear] = useState(); + const [priceDesc, setPriceDesc] = useState(false); + + useEffect(() => { + if (plan) { + setPricePerMonth(plan.price); + setPricePerYear(plan.price * 10); } + }, [plan, isTermsChecked, pricePerMonth, pricePerYear]); - const handleSubmit = async (e: React.FormEvent) => { - e.preventDefault(); - - if (!isTermsChecked) { - alert('Please agree to the Terms of Service and Privacy Policy before proceeding.'); - return; - } - - try { - const json = { - fullname: formData.fullName, - business_name: formData.businessName, - organisation_id: currentOrgId, - plan_id: plan?.id, - billing_option: formData.billingOption - }; - - const apiUrl = await getApiUrl(); - const token = window.localStorage.getItem("token"); - - const response = await axios.post(`${apiUrl}/api/v1/payment/stripe`, json, - { - headers: { - Authorization: `Bearer ${token}`, - } - } - ); - - if (response.data.url) - window.location.href = response.data.url; - - // eslint-disable-next-line @typescript-eslint/no-explicit-any - } catch (error:any) { - return error; - toast({ - title: "Payment error", - description: error.response.data.message, - }); - } - }; - - return ( -
- {/* Form fields for Full Name and Business Name */} -
-
- - -
-
- - -
- - - {/* Billing Option */} -
- -
- -
-

Pay monthly

-

{`$${pricePerMonth}/ month/member`}

-
-
-
- -
-

Pay yearly

-

{`$${pricePerYear}/ year/member`}

-
-
-
- -
-
-

{`$${pricePerMonth}`}

-
-
-

Details

- -
-
- {priceDesc &&
-
-

Members in your workspace

-

1

-
-
-

x$20/month/member

-

{`${pricePerMonth}`}

-
-
-
-

Subtotal

-

$20

-
-
-

Tax if applicable

-

$20

-
-
-} + const handleInputChange = (event: React.ChangeEvent) => { + const { name, value } = event.target; + setFormData({ + ...formData, + [name]: value, + }); + }; - {/* Payment Method - Stripe only */} -
- + const handleCheckboxChange = (event: React.ChangeEvent) => { + setIsTermsChecked(event.target.checked); + }; - {/* Credit Card Option (Disabled) */} -
-
- -

Credit Card

-
- symbol -
+ const priceDropDown = () => { + setPriceDesc((previous) => !previous); + }; - {/* Stripe Payment Option */} -
-
- -

Stripe Payment

-
- symbol -
+ const handleSubmit = async (event: React.FormEvent) => { + event.preventDefault(); - {/* PayPal Option (Disabled) */} -
-
- -

PayPal Payment

-
- symbol -
-
+ if (!isTermsChecked) { + alert( + "Please agree to the Terms of Service and Privacy Policy before proceeding.", + ); + return; + } - {/* Agreement */} -
- -

- By submitting this form, you confirm that you agree to our{' '} - Terms of Service and{' '} - Privacy Policy -

-
+ try { + const json = { + fullname: formData.fullName, + business_name: formData.businessName, + organisation_id: currentOrgId, + plan_id: plan?.id, + billing_option: formData.billingOption, + }; + + const apiUrl = await getApiUrl(); + const token = window.localStorage.getItem("token"); + + const response = await axios.post( + `${apiUrl}/api/v1/payment/stripe`, + json, + { + headers: { + Authorization: `Bearer ${token}`, + }, + }, + ); + + if (response.data.url) window.location.href = response.data.url; + + // eslint-disable-next-line @typescript-eslint/no-explicit-any + } catch (error: any) { + return error; + } + }; + + return ( +
+ {/* Form fields for Full Name and Business Name */} + +
+ + +
+
+ + +
- {/* Submit Button */} - - - - + {/* Billing Option */} +
+ +
+ +
+

Pay monthly

+

{`$${pricePerMonth}/ month/member`}

+
+
+
+ +
+

Pay yearly

+

{`$${pricePerYear}/ year/member`}

+
+
+
-
- - - Edit profile - - Make changes to your profile here. Click save when you are done. - - -
-
- {/* Form fields go here */} -
-
- {/* Form fields go here */} -
-
- - - - - -
-
+
+
+

{`$${pricePerMonth}`}

+
+
+

Details

+ +
+
+ {priceDesc && ( +
+
+

Members in your workspace

+

1

+
+
+

x$20/month/member

+

{`${pricePerMonth}`}

+
+
+
+

Subtotal

+

$20

+
+
+

Tax if applicable

+

$20

+
+
+ )} + + {/* Payment Method - Stripe only */} +
+ + + {/* Credit Card Option (Disabled) */} +
+
+ +

Credit Card

+
+ symbol +
+ + {/* Stripe Payment Option */} +
+
+ +

Stripe Payment

+
+ symbol +
+ + {/* PayPal Option (Disabled) */} +
+
+ +

PayPal Payment

+
+ symbol +
+
+ {/* Agreement */} +
+ +

+ By submitting this form, you confirm that you agree to our{" "} + Terms of Service and{" "} + Privacy Policy +

- ); + + {/* Submit Button */} + + + + + + + Edit profile + + Make changes to your profile here. Click save when you are done. + + +
+
+ {/* Form fields go here */} +
+
+ {/* Form fields go here */} +
+
+ + + + + +
+
+
+ ); }; export default CheckoutForm; diff --git a/src/app/dashboard/(admin)/admin/(settings)/settings/payment-information/_components/currentPlan.tsx b/src/app/dashboard/(admin)/admin/(settings)/settings/payment-information/_components/currentPlan.tsx index 42d7aa5ff..e4ca2b890 100644 --- a/src/app/dashboard/(admin)/admin/(settings)/settings/payment-information/_components/currentPlan.tsx +++ b/src/app/dashboard/(admin)/admin/(settings)/settings/payment-information/_components/currentPlan.tsx @@ -1,4 +1,3 @@ -/* eslint-disable no-irregular-whitespace */ import Link from "next/link"; import desiredPlan, { highLightMobile, highlights } from "../dataJSON"; @@ -15,9 +14,9 @@ const CurrentPlan = () => { Free

- Your account is on a free 90-day trial of our free plan, - through September 27th. Upgrade anytime to stay on this plan when - your trial ends. + Your account is on a free 90-day trial of our free plan, // + eslint-disable-next-line no-irregular-whitespace through September + 27th. Upgrade anytime to stay on this plan when your trial ends.

$0/month diff --git a/src/app/dashboard/(admin)/admin/(settings)/settings/payment-information/basic/basicPlan.tsx b/src/app/dashboard/(admin)/admin/(settings)/settings/payment-information/basic/basicPlan.tsx deleted file mode 100644 index 5aa8c2ac1..000000000 --- a/src/app/dashboard/(admin)/admin/(settings)/settings/payment-information/basic/basicPlan.tsx +++ /dev/null @@ -1,256 +0,0 @@ -/* eslint-disable prettier/prettier */ -import { - Table, - TableBody, - TableCell, - TableHead, - TableHeader, - TableRow, -} from "~/components/ui/table" -import { Check } from "lucide-react"; -import { - Dialog, - DialogContent, - DialogDescription, - DialogFooter, - DialogHeader, - DialogTitle, - DialogTrigger, -} from "~/components/ui/dialog" - -const projectManagement = [ - { - task: "Projects", - specification: "Up to 5", - }, - { - task: "File Upload", - specification: "20gb", - }, - { - task: "User Account", - specification: "10", - }, - { - task: "Teams", - specification: "Unlimited", - }, -] - -const collaborations = [ - { - task: "Integration", - confirmation: , - }, - { - task: "Guest Access", - confirmation: , - }, - { - task: "Page Analysis", - confirmation: , - }, - { - task: "Task Managment", - confirmation: , - }, -] - -const managements = [ - { - task: "Team Security", - confirmation: , - }, - { - task: "Data Backup", - confirmation: , - }, - { - task: "HIPAA Compliance", - confirmation: , - } -] - -const supports = [ - { - task: "Priority Support", - confirmation: , - }, - { - task: "Customer Support", - confirmation: , - }, -] - -// const style = { -// width: '80%', -// '@media (min-width:600px)': { -// width: 'auto', -// }, -// '@media (min-width:900px)': { -// width: 'auto%', -// }, -// }; - -const recentTransactions = [ - { - date: "Date", - paymentStatus: "Status", - totalAmount: "Invoice", - }, - { - date: "7-7-24", - paymentStatus: "Paid", - totalAmount: "Download", - }, -] - - - -const BasicPlan = () => { - return ( -

-

Current Plan

-
-
-
-

Basic

-

You are currently enjoying the benefits of our Basic plan. Your subscription will auto-renew on the 30th of July 2024

-

$20/month

-
-

Upgrade to access more features

-
-
-

Current Plan Benefit

-
    -
  • 100 Projects
  • -
  • Up to 50 subscribers
  • -
  • Advanced analytics
  • -
  • 24-hour support
  • -
-
-
- - - - - Project Management - - - - - {projectManagement.map((project) => ( - - {project.task} - {project.specification} - - ))} - -
- - - - - Sharing and Collaboration - - - - - {collaborations.map((collaboration) => ( - - {collaboration.task} - {collaboration.confirmation} - - ))} - -
- - - - - Management and security - - - - - {managements.map((management) => ( - - {management.task} - {management.confirmation} - - ))} - -
- - - - - Support - - - - - {supports.map((support) => ( - - {support.task} - {support.confirmation} - - ))} - -
- - - - - Recent Transactions - - - - - - {recentTransactions.map((recentTransaction) => ( - - {recentTransaction.date} - {recentTransaction.paymentStatus} - {recentTransaction.totalAmount} - - ))} - -
-
- - - - - - - - - - - Edit profile - - Make changes to your profile here. Click save when you are done. - - -
-
-
-
- -
-
- -
- - -
-
-
-
-
-
- ) -} - -export default BasicPlan diff --git a/src/app/dashboard/(admin)/admin/(settings)/settings/payment-information/basic/page.tsx b/src/app/dashboard/(admin)/admin/(settings)/settings/payment-information/basic/page.tsx deleted file mode 100644 index 16afb240d..000000000 --- a/src/app/dashboard/(admin)/admin/(settings)/settings/payment-information/basic/page.tsx +++ /dev/null @@ -1,11 +0,0 @@ -import BasicPlan from "./basicPlan"; - -const Page = () => { - return ( - <> - - - ); -}; - -export default Page; diff --git a/src/app/dashboard/(admin)/admin/(settings)/settings/payment-information/basicPlan/basicPlan.tsx b/src/app/dashboard/(admin)/admin/(settings)/settings/payment-information/basicPlan/basicPlan.tsx index d291e9489..0fef4a8f2 100644 --- a/src/app/dashboard/(admin)/admin/(settings)/settings/payment-information/basicPlan/basicPlan.tsx +++ b/src/app/dashboard/(admin)/admin/(settings)/settings/payment-information/basicPlan/basicPlan.tsx @@ -1,5 +1,14 @@ import { Check } from "lucide-react"; +import { + Dialog, + DialogContent, + DialogDescription, + DialogFooter, + DialogHeader, + DialogTitle, + DialogTrigger, +} from "~/components/ui/dialog"; import { Table, TableBody, @@ -11,76 +20,76 @@ import { const projectManagement = [ { - invoice: "Projects", - paymentStatus: "Up to 5", + task: "Projects", + specification: "Up to 5", }, { - invoice: "File Upload", - paymentStatus: "20gb", + task: "File Upload", + specification: "20gb", }, { - invoice: "User Account", - paymentStatus: "10", + task: "User Account", + specification: "10", }, { - invoice: "Teams", - paymentStatus: "Unlimited", + task: "Teams", + specification: "Unlimited", }, ]; const collaborations = [ { - invoice: "Integration", - paymentStatus: , + task: "Integration", + confirmation: , }, { - invoice: "Guest Access", - paymentStatus: , + task: "Guest Access", + confirmation: , }, { - invoice: "Page Analysis", - paymentStatus: , + task: "Page Analysis", + confirmation: , }, { - invoice: "Task Managment", - paymentStatus: , + task: "Task Managment", + confirmation: , }, ]; const managements = [ { - invoice: "Team Security", - paymentStatus: , + task: "Team Security", + confirmation: , }, { - invoice: "Data Backup", - paymentStatus: , + task: "Data Backup", + confirmation: , }, { - invoice: "HIPAA Compliance", - paymentStatus: , + task: "HIPAA Compliance", + confirmation: , }, ]; const supports = [ { - invoice: "Priority Support", - paymentStatus: , + task: "Priority Support", + confirmation: , }, { - invoice: "Customer Support", - paymentStatus: , + task: "Customer Support", + confirmation: , }, ]; const recentTransactions = [ { - invoice: "Date", + date: "Date", paymentStatus: "Status", totalAmount: "Invoice", }, { - invoice: "7-7-24", + date: "7-7-24", paymentStatus: "Paid", totalAmount: "Download", }, @@ -128,9 +137,9 @@ const BasicPlan = () => { {projectManagement.map((project) => ( - - {project.invoice} - {project.paymentStatus} + + {project.task} + {project.specification} ))} @@ -147,11 +156,11 @@ const BasicPlan = () => { {collaborations.map((collaboration) => ( - + - {collaboration.invoice} + {collaboration.task} - {collaboration.paymentStatus} + {collaboration.confirmation} ))} @@ -168,11 +177,9 @@ const BasicPlan = () => { {managements.map((management) => ( - - - {management.invoice} - - {management.paymentStatus} + + {management.task} + {management.confirmation} ))} @@ -189,9 +196,9 @@ const BasicPlan = () => { {supports.map((support) => ( - - {support.invoice} - {support.paymentStatus} + + {support.task} + {support.confirmation} ))} @@ -209,9 +216,9 @@ const BasicPlan = () => { {recentTransactions.map((recentTransaction) => ( - + - {recentTransaction.invoice} + {recentTransaction.date} {recentTransaction.paymentStatus} { - + + + + + + + + Edit profile + + Make changes to your profile here. Click save when you are done. + + +
+
+
+
+ +
+ + +
+
+
+
); diff --git a/src/app/dashboard/(admin)/admin/(settings)/settings/payment-information/checkout/page.tsx b/src/app/dashboard/(admin)/admin/(settings)/settings/payment-information/checkout/page.tsx index 71f6f6ce0..39599baef 100644 --- a/src/app/dashboard/(admin)/admin/(settings)/settings/payment-information/checkout/page.tsx +++ b/src/app/dashboard/(admin)/admin/(settings)/settings/payment-information/checkout/page.tsx @@ -1,32 +1,29 @@ -/* eslint-disable no-console */ - -/* eslint-disable prettier/prettier */ -"use client" - -import CheckoutForm from '../_components/checkoutForm/checkoutForm'; -import Link from 'next/link'; -import { ArrowLeft } from 'lucide-react'; - -// const stripePromise = loadStripe(process.env.NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY!); +"use client"; +import { ArrowLeft } from "lucide-react"; +import Link from "next/link"; +import CheckoutForm from "../_components/checkoutForm/checkoutForm"; const Page = () => { -console.log('checkout') - return ( -
-
-
- - - -

Upgrade to Basic

-
-

Do more with unlimited users and Integration when you upgrade

-
- + return ( +
+
+
+ + + +

+ Upgrade to Basic +

- ) -} +

+ Do more with unlimited users and Integration when you upgrade +

+
+ +
+ ); +}; -export default Page +export default Page; diff --git a/src/app/dashboard/(admin)/admin/(settings)/settings/payment-information/page.tsx b/src/app/dashboard/(admin)/admin/(settings)/settings/payment-information/page.tsx index 2d6dc371c..5806b1d48 100644 --- a/src/app/dashboard/(admin)/admin/(settings)/settings/payment-information/page.tsx +++ b/src/app/dashboard/(admin)/admin/(settings)/settings/payment-information/page.tsx @@ -1,17 +1,12 @@ -/* eslint-disable prettier/prettier */ -/* eslint-disable no-console */ -// import Link from "next/link"; import CurrentPlan from "./_components/currentPlan"; import FreePlan from "./_components/freePlan"; -// import { Button } from "~/components/ui/button"; const PaymentInformation = () => { - console.log("here"); return ( -
- - -
+
+ + +
); }; diff --git a/src/app/invite/page.tsx b/src/app/invite/page.tsx index 23f045bc8..0743035ba 100644 --- a/src/app/invite/page.tsx +++ b/src/app/invite/page.tsx @@ -17,52 +17,50 @@ const AcceptInvitePage = () => { // Function to extract token from the query string - // eslint-disable-next-line react-hooks/exhaustive-deps - const handleAcceptInvite = async () => { - // Extract token using the function - const token = extractToken(); + // Process the invite on page load + useEffect(() => { + const handleAcceptInvite = async () => { + // Extract token using the function + const token = extractToken(); - if (!token) { - router.push("/error?message=Invalid invite link"); - return; - } + if (!token) { + router.push("/error?message=Invalid invite link"); + return; + } - try { - const response = await acceptInviteRequest(token); + try { + const response = await acceptInviteRequest(token); - switch (response.status) { - case 200: { - // User was added, redirect to login page - router.push("/login?message=Invite accepted, please login"); - break; - } - case 202: { - // Redirect to registration page - router.push("/register?message=Please complete registration"); - break; - } - case 422: { - // Bad invite code, redirect to error page - router.push("/error?message=Invalid invite code"); - break; - } - default: { - // Handle unexpected status codes - router.push( - `/error?message=${response.error || "Unexpected error occurred"}`, - ); + switch (response.status) { + case 200: { + // User was added, redirect to login page + router.push("/login?message=Invite accepted, please login"); + break; + } + case 202: { + // Redirect to registration page + router.push("/register?message=Please complete registration"); + break; + } + case 422: { + // Bad invite code, redirect to error page + router.push("/error?message=Invalid invite code"); + break; + } + default: { + // Handle unexpected status codes + router.push( + `/error?message=${response.error || "Unexpected error occurred"}`, + ); + } } + } catch { + // Handle unexpected errors + router.push("/error?message=An unexpected error occurred"); } - } catch { - // Handle unexpected errors - router.push("/error?message=An unexpected error occurred"); - } - }; - - // Process the invite on page load - useEffect(() => { + }; handleAcceptInvite(); - }, [handleAcceptInvite]); + }, [router]); return (
diff --git a/src/contexts/orgContext.tsx b/src/contexts/orgContext.tsx index 714b3a8d5..9313ac3c4 100644 --- a/src/contexts/orgContext.tsx +++ b/src/contexts/orgContext.tsx @@ -1,4 +1,3 @@ -/* eslint-disable unicorn/prevent-abbreviations */ "use client"; import React, { @@ -78,8 +77,8 @@ const OrgContextProvider = ({ children }: { children: React.ReactNode }) => { getAllOrg().then((data) => { const fetchedOrganizations = (data && data.organization) || []; if (fetchedOrganizations.length > 0) { - setOrganizations((prevOrganizations) => [ - ...prevOrganizations, + setOrganizations((previousOrganizations) => [ + ...previousOrganizations, ...fetchedOrganizations, ]); } @@ -114,8 +113,8 @@ const OrgContextProvider = ({ children }: { children: React.ReactNode }) => { ), ); if (uniqueOrgs.length > 0) { - setOrganizations((prevOrganizations) => [ - ...prevOrganizations, + setOrganizations((previousOrganizations) => [ + ...previousOrganizations, ...uniqueOrgs, ]); }