@@ -5,6 +5,7 @@ import { BugFixBody, BugFixMessage, BugFixResponse } from './bug-fix.types';
55import { usePost } from '@/core/react-query' ;
66import { toast } from 'sonner' ;
77import { BeatLoader } from 'react-spinners' ;
8+ import { isAxiosError } from 'axios' ;
89
910const BugFix : FC = ( ) => {
1011 const { mutateAsync } = usePost < BugFixResponse , BugFixBody > (
@@ -57,18 +58,23 @@ const BugFix: FC = () => {
5758 ) ,
5859 ) ;
5960 } catch ( error ) {
60- console . log ( error ) ;
6161 setMessages ( ( prev ) => prev . slice ( 0 , - 1 ) ) ;
62- toast . error ( 'Something went wrong' ) ;
62+ if ( isAxiosError ( error ) ) {
63+ if ( error . response ?. data . detail ) {
64+ toast . error ( error . response . data . detail ) ;
65+ } else {
66+ toast . error ( 'Something went wrong' ) ;
67+ }
68+ }
6369 }
6470 } ;
6571
6672 return (
6773 < div className = "flex h-[calc(100vh-56px)] w-full items-center justify-center text-black dark:text-white" >
6874 < div className = "w-full max-w-[1024px]" >
69- < div className = "w-full rounded-md p-2" >
70- < div className = "flex h-full w-full items-center justify-center gap-3" >
71- < div className = "flex w-full flex-col" >
75+ < div className = "w-full p-2 rounded-md " >
76+ < div className = "flex items-center justify-center w-full h-full gap-3" >
77+ < div className = "flex flex-col w-full " >
7278 < label htmlFor = "min_token" className = "mb-2" >
7379 Min Token
7480 </ label >
@@ -77,10 +83,10 @@ const BugFix: FC = () => {
7783 type = "number"
7884 value = { minToken }
7985 onChange = { ( e ) => setMinToken ( e . target . value ) }
80- className = "w-full rounded-md bg-gray-200 p-3 outline-none dark:bg-black-1"
86+ className = "w-full p-3 bg-gray-200 rounded-md outline-none dark:bg-black-1"
8187 />
8288 </ div >
83- < div className = "flex w-full flex-col" >
89+ < div className = "flex flex-col w-full " >
8490 < label htmlFor = "max_token" className = "mb-2" >
8591 Max Token
8692 </ label >
@@ -89,10 +95,10 @@ const BugFix: FC = () => {
8995 type = "number"
9096 value = { maxToken }
9197 onChange = { ( e ) => setMaxToken ( e . target . value ) }
92- className = "w-full rounded-md bg-gray-200 p-3 outline-none dark:bg-black-1"
98+ className = "w-full p-3 bg-gray-200 rounded-md outline-none dark:bg-black-1"
9399 />
94100 </ div >
95- < div className = "flex w-full flex-col" >
101+ < div className = "flex flex-col w-full " >
96102 < label htmlFor = "service" className = "mb-2" >
97103 Service
98104 </ label >
@@ -101,10 +107,10 @@ const BugFix: FC = () => {
101107 type = "text"
102108 value = { service }
103109 onChange = { ( e ) => setService ( e . target . value ) }
104- className = "w-full rounded-md bg-gray-200 p-3 outline-none dark:bg-black-1"
110+ className = "w-full p-3 bg-gray-200 rounded-md outline-none dark:bg-black-1"
105111 />
106112 </ div >
107- < div className = "flex w-full flex-col" >
113+ < div className = "flex flex-col w-full " >
108114 < label htmlFor = "version" className = "mb-2" >
109115 Version
110116 </ label >
@@ -113,7 +119,7 @@ const BugFix: FC = () => {
113119 type = "text"
114120 value = { version }
115121 onChange = { ( e ) => setVersion ( e . target . value ) }
116- className = "w-full rounded-md bg-gray-200 p-3 outline-none dark:bg-black-1"
122+ className = "w-full p-3 bg-gray-200 rounded-md outline-none dark:bg-black-1"
117123 />
118124 </ div >
119125 </ div >
@@ -124,14 +130,14 @@ const BugFix: FC = () => {
124130 >
125131 { messages . map ( ( message ) =>
126132 message . role === 'user' ? (
127- < div className = "chat chat-end max-w-full" >
128- < div className = "chat-bubble bg-gray-600 text-white " >
133+ < div className = "max-w-full chat chat-end " >
134+ < div className = "text-white bg-gray-600 chat-bubble " >
129135 { message . content }
130136 </ div >
131137 </ div >
132138 ) : (
133- < div className = "chat chat-start max-w-full" >
134- < div className = "chat-bubble text-white" >
139+ < div className = "max-w-full chat chat-start " >
140+ < div className = "text-white chat-bubble " >
135141 { message . loading ? (
136142 < BeatLoader color = "#e3e3e3" size = { 10 } />
137143 ) : (
@@ -148,12 +154,12 @@ const BugFix: FC = () => {
148154 value = { bugDescription }
149155 onChange = { ( e ) => setBugDescription ( e . target . value ) }
150156 rows = { 2 }
151- className = "w-full resize-none rounded-md bg-gray-200 p-4 pr-16 outline -none dark:bg-black-1"
157+ className = "w-full p-4 pr-16 bg-gray-200 rounded-md outline-none resize -none dark:bg-black-1"
152158 />
153159 < button
154160 disabled = { ! bugDescription }
155161 onClick = { handleSendMessage }
156- className = "absolute right-3 top-5 flex items-center justify-center rounded-full bg-white p-2 transition-all disabled:opacity-50"
162+ className = "absolute flex items-center justify-center p-2 transition-all bg-white rounded-full right-3 top-5 disabled:opacity-50"
157163 >
158164 < Send className = "size-6 stroke-[#121212]" />
159165 </ button >
0 commit comments