@@ -2,7 +2,7 @@ import React, { useState } from 'react';
22import { motion } from 'framer-motion' ;
33import { Send , FileText , User , Mail , Globe , Briefcase } from 'lucide-react' ;
44import { db } from '../services/firebase' ;
5- import { collection , addDoc , Timestamp } from 'firebase/firestore' ;
5+ import { collection , addDoc , Timestamp , query , where , getDocs } from 'firebase/firestore' ;
66import { useAuth } from '../context/AuthContext' ;
77
88const BecomeContributor = ( ) => {
@@ -42,6 +42,28 @@ const BecomeContributor = () => {
4242 } ) ;
4343 const [ submitting , setSubmitting ] = useState ( false ) ;
4444 const [ submitted , setSubmitted ] = useState ( false ) ;
45+ const [ hasPendingApp , setHasPendingApp ] = useState ( false ) ;
46+
47+ React . useEffect ( ( ) => {
48+ const checkPending = async ( ) => {
49+ if ( user ) {
50+ try {
51+ const q = query (
52+ collection ( db , 'contributor_applications' ) ,
53+ where ( 'uid' , '==' , user . uid ) ,
54+ where ( 'status' , '==' , 'pending' )
55+ ) ;
56+ const snapshot = await getDocs ( q ) ;
57+ if ( ! snapshot . empty ) {
58+ setHasPendingApp ( true ) ;
59+ }
60+ } catch ( error ) {
61+ console . error ( "Error checking pending apps:" , error ) ;
62+ }
63+ }
64+ } ;
65+ checkPending ( ) ;
66+ } , [ user ] ) ;
4567
4668 const handleSubmit = async ( e ) => {
4769 e . preventDefault ( ) ;
@@ -62,6 +84,34 @@ const BecomeContributor = () => {
6284 }
6385 } ;
6486
87+ if ( hasPendingApp ) {
88+ return (
89+ < div className = "min-h-screen pt-20 flex items-center justify-center bg-gray-900 px-4" >
90+ < div className = "bg-gray-800 p-8 rounded-2xl max-w-lg w-full text-center border border-yellow-500/30" >
91+ < div className = "w-16 h-16 bg-yellow-500/20 rounded-full flex items-center justify-center mx-auto mb-6" >
92+ < FileText className = "text-yellow-500" size = { 32 } />
93+ </ div >
94+ < h2 className = "text-3xl font-bold text-white mb-4" > Application Pending</ h2 >
95+ < p className = "text-gray-300 mb-6" >
96+ You have already submitted an application which is pending approval.
97+ </ p >
98+ < div className = "bg-gray-900/50 p-4 rounded-lg mb-6 border border-gray-700" >
99+ < p className = "text-sm text-gray-400 mb-2" > In case of delayed response, reach out to a community leader:</ p >
100+ < a href = "mailto:mianshaheerahmed@gmail.com" className = "text-blue-400 font-medium hover:underline flex items-center justify-center gap-2" >
101+ < Mail size = { 16 } /> mianshaheerahmed@gmail.com
102+ </ a >
103+ </ div >
104+ < button
105+ onClick = { ( ) => window . location . href = '/' }
106+ className = "px-6 py-2 bg-gray-700 hover:bg-gray-600 text-white rounded-lg transition-colors"
107+ >
108+ Return Home
109+ </ button >
110+ </ div >
111+ </ div >
112+ ) ;
113+ }
114+
65115 if ( submitted ) {
66116 return (
67117 < div className = "min-h-screen pt-20 flex items-center justify-center bg-gray-900 px-4" >
0 commit comments