11"use client" ;
22
3- import { useSession } from ' next-auth/react' ;
3+ import { useSession } from " next-auth/react" ;
44import React , { useState , useEffect } from "react" ;
55import Alert from "@/components/Alert" ;
66import Button from "@/components/Button" ;
@@ -23,7 +23,6 @@ export default function ItemPageClient({ id }: ItemPageClientProps) {
2323 const [ buyError , setBuyError ] = useState < string | null > ( null ) ;
2424 const [ buySuccess , setBuySuccess ] = useState < string | null > ( null ) ;
2525
26-
2726 const router = useRouter ( ) ;
2827 const { balance, refreshBalance } = useBalance ( ) ;
2928
@@ -103,61 +102,56 @@ export default function ItemPageClient({ id }: ItemPageClientProps) {
103102 return (
104103 < >
105104 { item && < PageTitle > { item . title } </ PageTitle > }
106- < div className = "flex justify-center items-center" >
107- < div className = "w-full md:w-1/2" >
105+ < div className = "flex justify-center items-center" >
106+ < div className = "w-full md:w-1/2" >
108107 { item && (
109108 < >
110- < div className = "text-lg" >
111- < span className = "font-bold" > Description: </ span > { " " }
109+ < div className = "text-lg" >
110+ < span className = "font-bold" >
111+ { " " }
112+ Description:{ " " }
113+ </ span > { " " }
112114 { item . description }
113115 </ div >
114- < div className = "text-lg" >
115- < span className = "font-bold" > Price: </ span > $
116+ < div className = "text-lg" >
117+ < span className = "font-bold" > Price: </ span > $
116118 { item . price . toFixed ( 2 ) }
117119 </ div >
118- < div className = "text-lg" >
119- < span className = "font-bold" > Owner: </ span > { " " }
120+ < div className = "text-lg" >
121+ < span className = "font-bold" > Owner: </ span > { " " }
120122 { item . user . name }
121123 </ div >
122124 </ >
123125 ) }
124- {
125- session &&
126+ { session &&
126127 item &&
127128 parseInt ( session . user . id ) !== item . owner &&
128129 item . on_marketplace && (
129- < div className = "mt-4" >
130+ < div className = "mt-4" >
130131 < Button
131132 onClick = { handleBuy }
132- disabled = { ! canAfford || isBuying
133- }
133+ disabled = { ! canAfford || isBuying }
134134 >
135135 { isBuying ? "Processing..." : "Buy Now" }
136136 </ Button >
137- {
138- ! canAfford && (
139- < p className = "text-red-500 text-sm mt-2" >
140- You don & apos ; t have enough balance to buy
141- this item .
142- </ p >
143- )
144- }
145- {
146- buyError && (
147- < Alert
148- variant = "danger"
149- message = { buyError }
150- />
151- )
152- }
153- {
154- buySuccess && (
155- < Alert
156- variant = "success"
157- message = { buySuccess }
158- />
159- )
160- }
137+ { ! canAfford && (
138+ < p className = "text-red-500 text-sm mt-2" >
139+ You don & apos ; t have enough balance to
140+ buy this item .
141+ </ p >
142+ ) }
143+ { buyError && (
144+ < Alert
145+ variant = "danger"
146+ message = { buyError }
147+ />
148+ ) }
149+ { buySuccess && (
150+ < Alert
151+ variant = "success"
152+ message = { buySuccess }
153+ />
154+ ) }
161155 </ div >
162156 ) }
163157 </ div >
0 commit comments