@@ -8,15 +8,15 @@ import Button from "@/components/Button";
88import { useState , ChangeEvent , useEffect , useCallback } from "react" ;
99import { Thread } from "@/types" ;
1010import { toast } from "react-hot-toast" ;
11- import ErrorAlert from "@/components/Form/ErrorAlert" ;
1211import LoadingSpinner from "@/components/LoadingSpinner" ;
1312import CommentListing from "@/components/OnlyApp/Comment/CommentListing" ;
14- import { RefreshCw } from "lucide-react" ;
1513import RESPONSE_MESSAGES from "@/utils/constants/RESPONSE_MESSAGES" ;
1614import ItemNotFound from "../NotFound/ItemNotFound" ;
1715import { useAuth , useInfiniteScroll } from "@/hooks" ;
1816import { deleteThread , fetchThreadById , fetchThreads } from "@/services/thread/threadService" ;
1917import { createComment } from "@/services/thread/commentService" ;
18+ import { logger } from "@/utils/logger" ;
19+ import RetryAgain from "../RetryAgain" ;
2020
2121function DiscussionPageContent ( { discussionId } : { discussionId : string } ) {
2222 const router = useRouter ( ) ;
@@ -52,12 +52,10 @@ function DiscussionPageContent({ discussionId }: { discussionId: string }) {
5252 setThread ( threadData ) ;
5353 } else {
5454 setError ( threadResult . error . message || 'حدث خطأ أثناء تحميل المناقشة' ) ;
55- toast . error ( threadResult . error . message || 'حدث خطأ أثناء تحميل المناقشة' ) ;
5655 }
5756 } catch {
5857 const errorMessage = 'حدث خطأ أثناء تحميل المناقشة' ;
5958 setError ( errorMessage ) ;
60- toast . error ( errorMessage ) ;
6159 } finally {
6260 setIsLoading ( false ) ;
6361 }
@@ -82,7 +80,7 @@ function DiscussionPageContent({ discussionId }: { discussionId: string }) {
8280 setPage ( 2 ) ;
8381 }
8482 } catch {
85- toast . error ( "حدث خطأ أثناء تحميل المناقشات المشابهة" ) ;
83+ logger ( ) . error ( "حدث خطأ أثناء تحميل المناقشات المشابهة" ) ;
8684 } finally {
8785 setIsLoadingSimilar ( false ) ;
8886 }
@@ -107,7 +105,6 @@ function DiscussionPageContent({ discussionId }: { discussionId: string }) {
107105 }
108106 } catch ( err ) {
109107 console . error ( "Error loading more threads:" , err ) ;
110- toast . error ( "حدث خطأ أثناء تحميل المزيد من المناقشات" ) ;
111108 } finally {
112109 setIsLoadingSimilar ( false ) ;
113110 }
@@ -194,9 +191,7 @@ function DiscussionPageContent({ discussionId }: { discussionId: string }) {
194191 const result = await fetchThreadById ( thread . thread_id ) ;
195192 if ( result . success ) {
196193 setThread ( result . data ) ;
197- } else {
198- toast . error ( result . error . message || RESPONSE_MESSAGES . thread . DEFAULT ) ;
199- }
194+ }
200195 } ;
201196
202197 useEffect ( ( ) => {
@@ -215,17 +210,10 @@ function DiscussionPageContent({ discussionId }: { discussionId: string }) {
215210
216211 if ( error ) {
217212 return (
218- < div className = "space-y-4" >
219- < ErrorAlert message = { error } />
220- < Button
221- onClick = { loadThread }
222- variant = "outline"
223- icon = { < RefreshCw className = "w-4" /> }
224- color = "secondary"
225- >
226- إعادة المحاولة
227- </ Button >
228- </ div >
213+ < RetryAgain
214+ error = { error }
215+ handleRetry = { loadThread }
216+ />
229217 ) ;
230218 }
231219
0 commit comments