Skip to content

Commit 44e5cd5

Browse files
committed
Home page Request
1 parent 1f63220 commit 44e5cd5

File tree

1 file changed

+125
-28
lines changed

1 file changed

+125
-28
lines changed

components/GithubProjectsPage.tsx

Lines changed: 125 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,29 @@ import { Textarea } from '@/components/ui/textarea';
88
import { Alert, AlertDescription, AlertTitle } from '@/components/ui/alert';
99
import { Badge } from '@/components/ui/badge';
1010
import { Star, GitFork, Search, Tag, ChevronLeft, ChevronRight, Heart, Github, Share2, Check, AlertCircle } from 'lucide-react';
11+
import {
12+
AlertDialog,
13+
AlertDialogAction,
14+
AlertDialogCancel,
15+
AlertDialogContent,
16+
AlertDialogDescription,
17+
AlertDialogFooter,
18+
AlertDialogHeader,
19+
AlertDialogTitle,
20+
} from "@/components/ui/alert-dialog";
21+
const DiscordIcon = ({ className = "" }) => (
22+
<svg
23+
role="img"
24+
viewBox="0 0 24 24"
25+
xmlns="http://www.w3.org/2000/svg"
26+
className={className}
27+
width="24"
28+
height="24"
29+
fill="currentColor"
30+
>
31+
<path d="M20.317 4.3698a19.7913 19.7913 0 00-4.8851-1.5152.0741.0741 0 00-.0785.0371c-.211.3753-.4447.8648-.6083 1.2495-1.8447-.2762-3.68-.2762-5.4868 0-.1636-.3933-.4058-.8742-.6177-1.2495a.077.077 0 00-.0785-.037 19.7363 19.7363 0 00-4.8852 1.515.0699.0699 0 00-.0321.0277C.5334 9.0458-.319 13.5799.0992 18.0578a.0824.0824 0 00.0312.0561c2.0528 1.5076 4.0413 2.4228 5.9929 3.0294a.0777.0777 0 00.0842-.0276c.4616-.6304.8731-1.2952 1.226-1.9942a.076.076 0 00-.0416-.1057c-.6528-.2476-1.2743-.5495-1.8722-.8923a.077.077 0 01-.0076-.1277c.1258-.0943.2517-.1923.3718-.2914a.0743.0743 0 01.0776-.0105c3.9278 1.7933 8.18 1.7933 12.0614 0a.0739.0739 0 01.0785.0095c.1202.099.246.1981.3728.2924a.077.077 0 01-.0066.1276 12.2986 12.2986 0 01-1.873.8914.0766.0766 0 00-.0407.1067c.3604.698.7719 1.3628 1.225 1.9932a.076.076 0 00.0842.0286c1.961-.6067 3.9495-1.5219 6.0023-3.0294a.077.077 0 00.0313-.0552c.5004-5.177-.8382-9.6739-3.5485-13.6604a.061.061 0 00-.0312-.0286zM8.02 15.3312c-1.1825 0-2.1569-1.0857-2.1569-2.419 0-1.3332.9555-2.4189 2.157-2.4189 1.2108 0 2.1757 1.0952 2.1568 2.419 0 1.3332-.9555 2.4189-2.1569 2.4189zm7.9748 0c-1.1825 0-2.1569-1.0857-2.1569-2.419 0-1.3332.9554-2.4189 2.1569-2.4189 1.2108 0 2.1757 1.0952 2.1568 2.419 0 1.3332-.946 2.4189-2.1568 2.4189Z"/>
32+
</svg>
33+
);
1134

1235
interface Project {
1336
name: string;
@@ -19,6 +42,11 @@ interface Project {
1942
color: string;
2043
}
2144

45+
interface SubmissionStatus {
46+
status: string;
47+
message: string;
48+
}
49+
2250
function getRandomGradient() {
2351
const colors = [
2452
'from-purple-500 to-pink-500',
@@ -40,6 +68,12 @@ export default function GithubProjectsPage() {
4068
}
4169
return [];
4270
});
71+
const [showDiscordDialog, setShowDiscordDialog] = useState(false);
72+
const [submissionStatus, setSubmissionStatus] = useState<SubmissionStatus>({
73+
status: '',
74+
message: ''
75+
});
76+
4377
const [currentPage, setCurrentPage] = useState(1);
4478
const [projectRequest, setProjectRequest] = useState({
4579
title: '',
@@ -85,36 +119,56 @@ export default function GithubProjectsPage() {
85119
!projectRequest.githubLink.trim() ||
86120
!projectRequest.description.trim() ||
87121
!projectRequest.reason.trim()) {
88-
setSubmitButton("Please Fill every Text-Area");
122+
setSubmissionStatus({
123+
status: 'error',
124+
message: 'Please fill in all fields before submitting'
125+
});
89126
return;
90127
}
91128

129+
setShowDiscordDialog(true);
130+
};
131+
132+
const handleFinalSubmit = async () => {
92133
try {
134+
setSubmissionStatus({
135+
status: 'loading',
136+
message: 'Submitting your request...'
137+
});
138+
93139
const response = await fetch('/api/project-requests', {
94140
method: 'POST',
95141
headers: { 'Content-Type': 'application/json' },
96142
body: JSON.stringify(projectRequest),
97143
});
98-
99-
if (!response.ok) {
100-
setSubmitButton("Failed to submit request");
101-
throw new Error('Failed to submit request');
102-
}
103-
104-
setSubmitButton("Successfully Sent");
105-
144+
145+
if (!response.ok) throw new Error('Failed to submit request');
146+
147+
setSubmissionStatus({
148+
status: 'success',
149+
message: 'Thank you for contributing to the community! Your submission will be reviewed shortly.'
150+
});
151+
106152
setProjectRequest({
107153
title: '',
108154
githubLink: '',
109155
description: '',
110156
reason: ''
111157
});
112158
} catch (error) {
113-
setSubmitButton("Failed to submit request");
159+
setSubmissionStatus({
160+
status: 'error',
161+
message: 'Failed to submit project request. Please try again.'
162+
});
114163
console.error('Failed to submit project request:', error);
115164
}
116165
};
117166

167+
const handleDiscordJoin = () => {
168+
window.open('https://discord.gg/QtnFGDQj5S', '_blank');
169+
handleFinalSubmit();
170+
};
171+
118172
const addProject = (projectName: string) => {
119173
setSavedProjects((prev) => [...prev, projectName]);
120174
};
@@ -279,24 +333,23 @@ export default function GithubProjectsPage() {
279333
className="bg-slate-800/50 border-slate-700 text-white placeholder:text-gray-400"
280334
/>
281335

282-
{SubmitButton !== "Submit" && (
283-
<Alert className={`${
284-
SubmitButton.includes("Success") ? 'bg-green-500/20 border-green-500' :
285-
SubmitButton.includes("Failed") ? 'bg-red-500/20 border-red-500' :
286-
'bg-blue-500/20 border-blue-500'
287-
} text-white border`}>
288-
<AlertCircle className="h-4 w-4" />
289-
<AlertTitle>
290-
{SubmitButton.includes("Success") ? 'Success!' :
291-
SubmitButton.includes("Failed") ? 'Error' :
292-
'Note'}
293-
</AlertTitle>
294-
<AlertDescription>
295-
{SubmitButton}
296-
</AlertDescription>
297-
</Alert>
298-
)}
299-
336+
{submissionStatus.status && (
337+
<Alert className={`${
338+
submissionStatus.status === 'success' ? 'bg-green-500/20 border-green-500' :
339+
submissionStatus.status === 'error' ? 'bg-red-500/20 border-red-500' :
340+
'bg-blue-500/20 border-blue-500'
341+
} text-white border`}>
342+
<AlertCircle className="h-4 w-4" />
343+
<AlertTitle>
344+
{submissionStatus.status === 'success' ? 'Success!' :
345+
submissionStatus.status === 'error' ? 'Error' :
346+
'Submitting...'}
347+
</AlertTitle>
348+
<AlertDescription>
349+
{submissionStatus.message}
350+
</AlertDescription>
351+
</Alert>
352+
)}
300353
<Button
301354
onClick={handleProjectRequest}
302355
className="bg-purple-500 hover:bg-purple-600 text-white w-full flex items-center justify-center gap-2"
@@ -367,6 +420,50 @@ export default function GithubProjectsPage() {
367420
</div>
368421
</div>
369422
</div>
423+
<AlertDialog open={showDiscordDialog} onOpenChange={setShowDiscordDialog}>
424+
<AlertDialogContent className="bg-slate-800 text-white border-slate-700">
425+
<AlertDialogHeader>
426+
<AlertDialogTitle className="text-2xl flex items-center gap-2">
427+
<DiscordIcon className="text-purple-500 w-6 h-6" />
428+
Join Our Discord Community!
429+
</AlertDialogTitle>
430+
<AlertDialogDescription className="text-gray-300 space-y-4">
431+
<p>
432+
Dont miss updates about your submission! Join our vibrant Discord community to:
433+
</p>
434+
<ul className="space-y-2">
435+
<li className="flex items-start gap-2">
436+
<Check className="text-green-500 mt-1 shrink-0" />
437+
Get notified when your project is reviewed
438+
</li>
439+
<li className="flex items-start gap-2">
440+
<Check className="text-green-500 mt-1 shrink-0" />
441+
Connect with like-minded developers
442+
</li>
443+
<li className="flex items-start gap-2">
444+
<Check className="text-green-500 mt-1 shrink-0" />
445+
Discover more amazing projects daily
446+
</li>
447+
<li className="flex items-start gap-2">
448+
<Check className="text-green-500 mt-1 shrink-0" />
449+
Share your knowledge and learn from others
450+
</li>
451+
</ul>
452+
</AlertDialogDescription>
453+
</AlertDialogHeader>
454+
<AlertDialogFooter>
455+
<AlertDialogCancel onClick={handleFinalSubmit} className="bg-slate-700 text-white hover:bg-slate-600 border-slate-600">
456+
Submit Without Joining
457+
</AlertDialogCancel>
458+
<AlertDialogAction
459+
onClick={handleDiscordJoin}
460+
className="bg-purple-500 hover:bg-purple-600 text-white"
461+
>
462+
Join Discord and Submit
463+
</AlertDialogAction>
464+
</AlertDialogFooter>
465+
</AlertDialogContent>
466+
</AlertDialog>
370467
</div>
371468
);
372469
}

0 commit comments

Comments
 (0)