Skip to content

Commit 3b3daa2

Browse files
feat(web): replace alert with toast notifications (#8)
1 parent 9b2575d commit 3b3daa2

File tree

3 files changed

+14
-11
lines changed

3 files changed

+14
-11
lines changed

async-code-web/app/page.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import { SupabaseService } from "@/lib/supabase-service";
2222
import { Project, Task } from "@/types";
2323
import { ClaudeIcon } from "@/components/icon/claude";
2424
import { OpenAIIcon } from "@/components/icon/openai";
25+
import { toast } from "sonner";
2526

2627
interface TaskWithProject extends Task {
2728
project?: Project
@@ -135,12 +136,12 @@ export default function Home() {
135136

136137
const handleStartTask = async () => {
137138
if (!prompt.trim() || !githubToken.trim()) {
138-
alert('Please provide both a prompt and GitHub token');
139+
toast.error('Please provide both a prompt and GitHub token');
139140
return;
140141
}
141142

142143
if (!user?.id) {
143-
alert('User not authenticated');
144+
toast.error('User not authenticated');
144145
return;
145146
}
146147

@@ -155,7 +156,7 @@ export default function Home() {
155156
}
156157
} else {
157158
// Custom repo URL - would need an input field for this
158-
alert('Custom repo URL input not implemented yet. Please select a project or create one first.');
159+
toast.error('Custom repo URL input not implemented yet. Please select a project or create one first.');
159160
return;
160161
}
161162

@@ -196,7 +197,7 @@ export default function Home() {
196197
setShowNotification(true);
197198
setTimeout(() => setShowNotification(false), 5000);
198199
} catch (error) {
199-
alert(`Error starting task: ${error}`);
200+
toast.error(`Error starting task: ${error}`);
200201
} finally {
201202
setIsLoading(false);
202203
}

async-code-web/app/projects/page.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { ProtectedRoute } from "@/components/protected-route";
1313
import { useAuth } from "@/contexts/auth-context";
1414
import { ApiService } from "@/lib/api-service";
1515
import { Project } from "@/types";
16+
import { toast } from "sonner";
1617

1718
interface ProjectWithStats extends Project {
1819
task_count?: number
@@ -68,7 +69,7 @@ export default function ProjectsPage() {
6869
loadProjects();
6970
} catch (error) {
7071
console.error('Error creating project:', error);
71-
alert('Error creating project. Please check the GitHub URL format.');
72+
toast.error('Error creating project. Please check the GitHub URL format.');
7273
}
7374
};
7475

@@ -84,7 +85,7 @@ export default function ProjectsPage() {
8485
loadProjects();
8586
} catch (error) {
8687
console.error('Error deleting project:', error);
87-
alert('Error deleting project');
88+
toast.error('Error deleting project');
8889
}
8990
};
9091

async-code-web/app/settings/page.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { Button } from "@/components/ui/button";
66
import { Input } from "@/components/ui/input";
77
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
88
import { Label } from "@/components/ui/label";
9+
import { toast } from "sonner";
910

1011
import Link from "next/link";
1112

@@ -42,7 +43,7 @@ export default function SettingsPage() {
4243

4344
const handleValidateToken = async () => {
4445
if (!githubToken.trim() || !repoUrl.trim()) {
45-
alert('Please provide both GitHub token and repository URL');
46+
toast.error('Please provide both GitHub token and repository URL');
4647
return;
4748
}
4849

@@ -74,15 +75,15 @@ export default function SettingsPage() {
7475
].join('\n');
7576

7677
if (permissions.create_branches) {
77-
alert(`✅ Token is fully valid for PR creation!\n\n${permissionSummary}`);
78+
toast.success(`✅ Token is fully valid for PR creation!\n\n${permissionSummary}`);
7879
} else {
79-
alert(`⚠️ Token validation partial success!\n\n${permissionSummary}\n\n❌ Cannot create branches - this will prevent PR creation.\nPlease ensure your token has 'repo' scope (not just 'public_repo').`);
80+
toast.warning(`⚠️ Token validation partial success!\n\n${permissionSummary}\n\n❌ Cannot create branches - this will prevent PR creation.\nPlease ensure your token has 'repo' scope (not just 'public_repo').`);
8081
}
8182
} else {
82-
alert(`❌ Token validation failed: ${data.error}`);
83+
toast.error(`❌ Token validation failed: ${data.error}`);
8384
}
8485
} catch (error) {
85-
alert(`Error validating token: ${error}`);
86+
toast.error(`Error validating token: ${error}`);
8687
setTokenValidation({ status: 'error', error: String(error) });
8788
} finally {
8889
setIsValidatingToken(false);

0 commit comments

Comments
 (0)