Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: remove "syntax validate" button, add toast message to run button #170

Merged
merged 8 commits into from
Nov 29, 2024
Prev Previous commit
Next Next commit
feat: enhance editor response handling and error notifications
  • Loading branch information
HashCookie committed Nov 28, 2024
commit bcfaba4643aca92aeeb72d9ec7370f130b3f8fa0
12 changes: 10 additions & 2 deletions app/components/editor/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -439,9 +439,15 @@ export const EditorScreen = () => {
customConfig,
request,
enforceContextData,
onResponse: (v) => {
onResponse: (v: JSX.Element | any[]) => {
if (isValidElement(v)) {
setEcho(v);
const props = (v as any).props;
if (props.className?.includes('text-red-500')) {
const errorMessage = props.children;
toast.error(errorMessage);
setRequestResult(errorMessage);
}
} else if (Array.isArray(v)) {
const formattedResults = v.map((res) => {
if (typeof res === 'object') {
Expand All @@ -454,7 +460,9 @@ export const EditorScreen = () => {
});
const result = formattedResults.join('\n');
setRequestResult(result);
toast.success(`Test completed`);
if (result && !result.includes('error')) {
toast.success('Test completed successfully');
}
}
},
});
Expand Down