11import { Button } from "@/components/ui/Button" ;
22import { useDialog } from "@/contexts" ;
33import { Check , CreditCard , HelpCircle , X , AlertCircle , RefreshCcw } from "lucide-react" ;
4- import { ReactNode , useEffect } from "react" ;
4+ import { ReactNode } from "react" ;
55import { motion } from "motion/react" ;
66import { cn } from "@/lib/utils" ;
77
@@ -23,7 +23,7 @@ type StatusConfig = {
2323} ;
2424
2525const statusConfigMap : Record < string , StatusConfig > = {
26- SUCCESS : {
26+ PAID : {
2727 icon : < Check className = "h-16 w-16" /> ,
2828 title : "Payment Successful!" ,
2929 description : "Your payment has been confirmed. You're all set for the event!" ,
@@ -77,28 +77,11 @@ const EventCheckStatusModal = ({ status = "", transaction_no = "", onRefresh }:
7777 action : "close" ,
7878 } as StatusConfig ) ;
7979
80- useEffect ( ( ) => {
81- if ( config . autoClose && status . toUpperCase ( ) === "SUCCESS" ) {
82- const timer = setTimeout ( ( ) => {
83- closeDialog ( ) ;
84- onRefresh ?.( ) ;
85- } , config . autoClose ) ;
86-
87- return ( ) => clearTimeout ( timer ) ;
88- }
89- } , [ config . autoClose , status , closeDialog , onRefresh ] ) ;
90-
9180 const handleAction = ( ) => {
9281 if ( config . action === "refresh" && onRefresh ) {
93- closeDialog ( ) ;
94- setTimeout ( ( ) => {
95- onRefresh ( ) ;
96- } , 300 ) ;
82+ onRefresh ( ) ;
9783 } else {
9884 closeDialog ( ) ;
99- if ( status . toUpperCase ( ) === "SUCCESS" ) {
100- onRefresh ?.( ) ;
101- }
10285 }
10386 } ;
10487
@@ -155,24 +138,13 @@ const EventCheckStatusModal = ({ status = "", transaction_no = "", onRefresh }:
155138 </ Button >
156139 ) }
157140 < Button
158- variant = { status . toUpperCase ( ) === "SUCCESS " ? "default" : "outline" }
159- className = { cn ( "flex-1" , status . toUpperCase ( ) === "SUCCESS " && "bg-green-600 hover:bg-green-700" ) }
160- onClick = { handleAction }
141+ variant = { status . toUpperCase ( ) === "PAID " ? "default" : "outline" }
142+ className = { cn ( "flex-1" , status . toUpperCase ( ) === "PAID " && "bg-green-600 hover:bg-green-700" ) }
143+ onClick = { ( ) => closeDialog ( ) }
161144 >
162- { status . toUpperCase ( ) === "SUCCESS " ? "Great!" : "Close" }
145+ { status . toUpperCase ( ) === "PAID " ? "Great!" : "Close" }
163146 </ Button >
164147 </ motion . div >
165-
166- { status . toUpperCase ( ) === "SUCCESS" && config . autoClose && (
167- < motion . p
168- initial = { { opacity : 0 } }
169- animate = { { opacity : 1 } }
170- transition = { { duration : 0.3 , delay : 0.5 } }
171- className = "text-muted-foreground text-xs"
172- >
173- This dialog will close automatically in 3 seconds...
174- </ motion . p >
175- ) }
176148 </ div >
177149 ) ;
178150} ;
0 commit comments