79685866

Date: 2025-07-01 09:59:05
Score: 0.5
Natty:
Report link
**11*
Name="flex items-center space-x-4 mb-4">
                <Badge className={`${currentLevel.color} font-semibold`}>
                  {currentLevel.name}
                </Badge>
                <div className="flex items-center space-x-1">
                  <Star className="w-4 h-4" />
                  <span>{profile?.points || 0} Points</span>
                </div>
              </div>
              <div className="space-y-2">
                <div className="flex justify-between text-sm">
                  <span>Progress to {currentLevel.name === "Master" ? "Max Level" : "Next Level"}</span>
                  <span>{profile?.points || 0} / {nextLevelPoints}</span>
                </div>
                <Progress value={progressPercent} className="bg-white/20" />
              </div>
            </div>
          </div>
        </CardContent>
      </Card>

      {/* Stats Grid */}
      <div className="grid md:grid-cols-4 gap-6">
        <Card>
          <CardContent className="p-6 text-center">
            <Award className="w-8 h-8 text-blue-500 mx-auto mb-2" />
            <p className="text-2xl font-bold text-blue-600">{profile?.points || 0}</p>
            <p className="text-gray-600 text-sm">Total Points</p>
          </CardContent>
        </Card>

        <Card>
          <CardContent className="p-6 text-center">
            <Calendar className="w-8 h-8 text-green-500 mx-auto mb-2" />
            <p className="text-2xl font-bold text-green-600">{profile?.events_attended || 0}</p>
            <p className="text-gray-600 text-sm">Events Attended</p>
          </CardContent>
        </Card>

        <Card>
          <CardContent className="p-6 text-center">
            <TrendingUp className="w-8 h-8 text-purple-500 mx-auto mb-2" />
            <p className="text-2xl font-bold text-purple-600">{profile?.impact_score || 0}</p>
            <p className="text-gray-600 text-sm">Impact Score</p>
          </CardContent>
        </Card>

        <Card>
          <CardContent className="p-6 text-center">
            <Trophy className="w-8 h-8 text-orange-500 mx-auto mb-2" />
            <p className="text-2xl font-bold text-orange-600">{profile?.badges?.length || 0}</p>
            <p className="text-gray-600 text-sm">Badges Earned</p>
          </CardContent>
        </Card>
      </div>

      {/* Badges Section */}
      <Card>
        <CardHeader>
          <CardTitle className="flex items-center space-x-2">
            <Star className="w-5 h-5" />
            <span>Badges & Achievements</span>
          </CardTitle>
          <CardDescription>Recognition for your environmental impact</CardDescription>
        </CardHeader>
        <CardContent>
          {profile?.badges && profile.badges.length > 0 ? (
            <div className="grid grid-cols-2 md:grid-cols-4 gap-4">
              {profile.badges.map((badge, index) => (
                <div key={index} className="text-center p-4 bg-gradient-to-br from-yellow-50 to-orange-50 rounded-lg border">
                  <Award className="w-8 h-8 text-yellow-500 mx-auto mb-2" />
                  <p className="font-semibold text-sm">{badge}</p>
                </div>
              ))}
            </div>
          ) : (
            <div className="text-center py-8">
              <Target className="w-16 h-16 text-gray-400 mx-auto mb-4" />
              <p className="text-gray-600">No badges earned yet</p>
              <p className="text-sm text-gray-500">Participate in events to earn your first badge!</p>
            </div>
          )}
        </CardContent>
      </Card>

      {/* Recent Activities */}
      <Card>
        <CardHeader>
          <CardTitle className="flex items-center space-x-2">
            <Calendar className="w-5 h-5" />
            <span>Recent Activities</span>
          </CardTitle>
          <CardDescription>Your latest environmental contributions</CardDescription>
        </CardHeader>
        <CardContent>
          {loading ? (
            <div className="text-center py-4">
              <div className="animate-spin rounded-full h-8 w-8 border-b-2 border-blue-600 mx-auto"></div>
            </div>
          ) : recentActivities.length > 0 ? (
            <div className="space-y-4">
              {recentActivities.map((activity, index) => (
                <div key={index} className="flex items-center justify-between p-4 bg-gray-50 rounded-lg">
                  <div className="flex items-center space-x-3">
                    <div className="w-2 h-2 bg-green-500 rounded-full"></div>
                    <div>
                      <h4 className="font-semibold">{activity.events?.title}</h4>
                      <p className="text-sm text-gray-600">
                        {activity.events?.location} • {new Date(activity.events?.date).toLocaleDateString()}
                      </p>
                    </div>
                  </div>
                  <Badge className="bg-green-100 text-green-800">
                    +{activity.points_awarded} pts
                  </Badge>
                </div>
              ))}
            </div>
          ) : (
            <div className="text-center py-8">
              <Calendar className="w-16 h-16 text-gray-400 mx-auto mb-4" />
              <p className="text-gray-600">No recent activities</p>
              <p className="text-sm text-gray-500">Join events to see your activities here!</p>
            </div>
          )}
        </CardContent>
      </Card>
    </div>
  );
};

export default ProfileStats;



========== C:\Users\satya\Downloads\sarthi-beach-brigade-main\sarthi-beach-brigade-main\src\components\volunteer\SarthiBot.tsx ==========

import { useState, useRef, useEffect } from 'react';
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card';
import { Button } from '@/components/ui/button';
import { Input } from '@/components/ui/input';
import { Badge } from '@/components/ui/badge';
import { MessageSquare, Send, Mic, MicOff, Volume2 } from 'lucide-react';

interface Message {
  id: string;
  text: string;
  sender: 'user' | 'bot';
  timestamp: Date;
}

const SarthiBot = () => {
  const [messages, setMessages] = useState<Message[]>([
    {
      id: '1',
      text: "Hi! I'm SarthiBot, your beach cleanup assistant. Ask me about events, eco-tips, or anything related to ocean conservation!",
      sender: 'bot',
      timestamp: new Date(),
    }
  ]);
  const [inputText, setInputText] = useState('');
  const [isListening, setIsListening] = useState(false);
  const [isLoading, setIsLoading] = useState(false);
  const messagesEndRef = useRef<HTMLDivElement>(null);

  const scrollToBottom = () => {
    messagesEndRef.current?.scrollIntoView({ behavior: 'smooth' });
  };

  useEffect(() => {
    scrollToBottom();
  }, [messages]);

  const sendMessage = async (text: string) => {
    if (!text.trim()) return;

    const userMessage: Message = {
      id: Date.now().toString(),
      text: text.trim(),
      sender: 'user',
      timestamp: new Date(),
    };

    setMessages(prev => [...prev, userMessage]);
    setInputText('');
    setIsLoading(true);

    // Simulate AI response
    setTimeout(() => {
      const botResponse: Message = {
        id: (Date.now() + 1).toString(),
        text: getBotResponse(text),
        sender: 'bot',
        timestamp: new Date(),
      };
      setMessages(prev => [...prev, botResponse]);
      setIsLoading(false);
    }, 1000);
  };

  const getBotResponse = (userText: string): string => {
    const lowerText = userText.toLowerCase();
    
    if (lowerText.includes('event') || lowerText.includes('cleanup')) {
      return "Great question! There are several beach cleanup events happening in Mumbai this week. Check the 'Discover' tab to see events near Juhu Beach, Marine Drive, and Versova Beach. Would you like me to help you register for one?";
    }
    
    if (lowerText.includes('point') || lowerText.includes('badge')) {
      return "You earn points by participating in events! Beach cleanups give 50-100 points, educational modules give 25 points, and referring friends gives 30 points. You can unlock badges like 'Ocean Guardian' and 'Cleanup Champion'!";
    }
    
    if (lowerText.includes('plastic') || lowerText.includes('waste')) {
      return "Here's an eco-tip: Microplastics are one of the biggest threats to marine life. Always sort waste during cleanups - plastics, glass, and organic matter should be separated. Every piece you collect makes a difference!";
    }
    
    if (lowerText.includes('mumbai') || lowerText.includes('beach')) {
      return "Mumbai has amazing beaches perfect for cleanup activities! Juhu Beach is great for beginners, Marine Drive for urban cleanup, and Versova Beach has shown incredible transformation through community efforts. Which one interests you most?";
    }
    
    return "That's an interesting question! I'm here to help with beach cleanup activities, event information, and eco-tips. You can also ask me about points, badges, or conservation techniques. What would you like to know more about?";
  };

  const handleVoiceToggle = () => {
    setIsListening(!isListening);
    // Voice recognition would be implemented here
    if (!isListening) {
      // Start listening
      setTimeout(() => {
        setIsListening(false);
        sendMessage("I heard you say something about beach cleanup events!");
      }, 3000);
    }
  };

  const speakText = (text: string) => {
    if ('speechSynthesis' in window) {
      const utterance = new SpeechSynthesisUtterance(text);
      speechSynthesis.speak(utterance);
    }
  };

  return (
    <Card className="h-[600px] flex flex-col">
      <CardHeader className="bg-gradient-to-r from-blue-500 to-cyan-500 text-white rounded-t-lg">
        <CardTitle className="flex items-center space-x-2">
          <MessageSquare className="w-5 h-5" />
          <span>SarthiBot - AI Assistant</span>
        </CardTitle>
        <CardDescription className="text-blue-100">
          Your friendly beach cleanup companion
        </CardDescription>
      </CardHeader>
      
      <CardContent className="flex-1 flex flex-col p-0">
        {/* Messages */}
        <div className="flex-1 overflow-y-auto p-4 space-y-4">
          {messages.map((message) => (
            <div
              key={message.id}
              className={`flex ${message.sender === 'user' ? 'justify-end' : 'justify-start'}`}
            >
              <div
                className={`max-w-[80%] p-3 rounded-lg ${
                  message.sender === 'user'
                    ? 'bg-blue-500 text-white'
                    : 'bg-gray-100 text-gray-800'
                }`}
              >
                <p className="text-sm">{message.text}</p>
                {message.sender === 'bot' && (
                  <Button
                    size="sm"
                    variant="ghost"
                    className="mt-2 h-6 px-2 text-xs"
                    onClick={() => speakText(message.text)}
                  >
                    <Volume2 className="w-3 h-3" />
                  </Button>
                )}
              </div>
            </div>
          ))}
          
          {isLoading && (
            <div className="flex justify-start">
              <div className="bg-gray-100 p-3 rounded-lg">
                <div className="flex space-x-1">
                  <div className="w-2 h-2 bg-gray-400 rounded-full animate-bounce"></div>
                  <div className="w-2 h-2 bg-gray-400 rounded-full animate-bounce" style={{ animationDelay: '0.1s' }}></div>
                  <div className="w-2 h-2 bg-gray-400 rounded-full animate-bounce" style={{ animationDelay: '0.2s' }}></div>
                </div>
              </div>
            </div>
          )}
          
          <div ref={messagesEndRef} />
        </div>
        
        {/* Input */}
        <div className="border-t p-4">
          <div className="flex space-x-2">
            <Input
              value={inputText}
              onChange={(e) => setInputText(e.target.value)}
              placeholder="Ask me anything about beach cleanup..."
              onKeyPress={(e) => e.key === 'Enter' && sendMessage(inputText)}
              className="flex-1"
            />
            <Button
              onClick={handleVoiceToggle}
              variant={isListening ? "default" : "outline"}
              size="sm"
              className={isListening ? "bg-red-500 hover:bg-red-600" : ""}
            >
              {isListening ? <MicOff className="w-4 h-4" /> : <Mic className="w-4 h-4" />}
            </Button>
            <Button onClick={() => sendMessage(inputText)} size="sm">
              <Send className="w-4 h-4" />
            </Button>
          </div>
          
          {/* Quick Actions */}
          <div className="flex flex-wrap gap-2 mt-3">
            <Badge
              variant="outline"
              className="cursor-pointer hover:bg-blue-50"
              onClick={() => sendMessage("Show me upcoming events")}
            >
              Upcoming Events
            </Badge>
            <Badge
              variant="outline"
              className="cursor-pointer hover:bg-blue-50"
              onClick={() => sendMessage("How do I earn more points?")}
            >
              Earning Points
            </Badge>
            <Badge
              variant="outline"
              className="cursor-pointer hover:bg-blue-50"
              onClick={() => sendMessage("Tell me about Mumbai beaches")}
            >
              Mumbai Beaches
            </Badge>
          </div>
        </div>
      </CardContent>
    </Card>
  );
};

export default SarthiBot;



========== C:\Users\satya\Downloads\sarthi-beach-brigade-main\sarthi-beach-brigade-main\src\hooks\use-mobile.tsx ==========
import * as React from "react"

const MOBILE_BREAKPOINT = 768

export function useIsMobile() {
  const [isMobile, setIsMobile] = React.useState<boolean | undefined>(undefined)

  React.useEffect(() => {
    const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`)
    const onChange = () => {
      setIsMobile(window.innerWidth < MOBILE_BREAKPOINT)
    }
    mql.addEventListener("change", onChange)
    setIsMobile(window.innerWidth < MOBILE_BREAKPOINT)
    return () => mql.removeEventListener("change", onChange)
  }, [])

  return !!isMobile
}



========== C:\Users\satya\Downloads\sarthi-beach-brigade-main\sarthi-beach-brigade-main\src\hooks\use-toast.ts ==========
import * as React from "react"

import type {
  ToastActionElement,
  ToastProps,
} from "@/components/ui/toast"

const TOAST_LIMIT = 1
const TOAST_REMOVE_DELAY = 1000000

type ToasterToast = ToastProps & {
  id: string
  title?: React.ReactNode
  description?: React.ReactNode
  action?: ToastActionElement
}

const actionTypes = {
  ADD_TOAST: "ADD_TOAST",
  UPDATE_TOAST: "UPDATE_TOAST",
  DISMISS_TOAST: "DISMISS_TOAST",
  REMOVE_TOAST: "REMOVE_TOAST",
} as const

let count = 0

function genId() {
  count = (count + 1) % Number.MAX_SAFE_INTEGER
  return count.toString()
}

type ActionType = typeof actionTypes

type Action =
  | {
      type: ActionType["ADD_TOAST"]
      toast: ToasterToast
    }
  | {
      type: ActionType["UPDATE_TOAST"]
      toast: Partial<ToasterToast>
    }
  | {
      type: ActionType["DISMISS_TOAST"]
      toastId?: ToasterToast["id"]
    }
  | {
      type: ActionType["REMOVE_TOAST"]
      toastId?: ToasterToast["id"]
    }

interface State {
  toasts: ToasterToast[]
}

const toastTimeouts = new Map<string, ReturnType<typeof setTimeout>>()

const addToRemoveQueue = (toastId: string) => {
  if (toastTimeouts.has(toastId)) {
    return
  }

  const timeout = setTimeout(() => {
    toastTimeouts.delete(toastId)
    dispatch({
      type: "REMOVE_TOAST",
      toastId: toastId,
    })
  }, TOAST_REMOVE_DELAY)

  toastTimeouts.set(toastId, timeout)
}

export const reducer = (state: State, action: Action): State => {
  switch (action.type) {
    case "ADD_TOAST":
      return {
        ...state,
        toasts: [action.toast, ...state.toasts].slice(0, TOAST_LIMIT),
      }

    case "UPDATE_TOAST":
      return {
        ...state,
        toasts: state.toasts.map((t) =>
          t.id === action.toast.id ? { ...t, ...action.toast } : t
        ),
      }

    case "DISMISS_TOAST": {
      const { toastId } = action

      // ! Side effects ! - This could be extracted into a dismissToast() action,
      // but I'll keep it here for simplicity
      if (toastId) {
        addToRemoveQueue(toastId)
      } else {
        state.toasts.forEach((toast) => {
          addToRemoveQueue(toast.id)
        })
      }

      return {
        ...state,
        toasts: state.toasts.map((t) =>
          t.id === toastId || toastId === undefined
            ? {
                ...t,
                open: false,
              }
            : t
        ),
      }
    }
    case "REMOVE_TOAST":
      if (action.toastId === undefined) {
        return {
          ...state,
          toasts: [],
        }
      }
      return {
        ...state,
        toasts: state.toasts.filter((t) => t.id !== action.toastId),
      }
  }
}

const listeners: Array<(state: State) => void> = []

let memoryState: State = { toasts: [] }

function dispatch(action: Action) {
  memoryState = reducer(memoryState, action)
  listeners.forEach((listener) => {
    listener(memoryState)
  })
}

type Toast = Omit<ToasterToast, "id">

function toast({ ...props }: Toast) {
  const id = genId()

  const update = (props: ToasterToast) =>
    dispatch({
      type: "UPDATE_TOAST",
      toast: { ...props, id },
    })
  const dismiss = () => dispatch({ type: "DISMISS_TOAST", toastId: id })

  dispatch({
    type: "ADD_TOAST",
    toast: {
      ...props,
      id,
      open: true,
      onOpenChange: (open) => {
        if (!open) dismiss()
      },
    },
  })

  return {
    id: id,
    dismiss,
    update,
  }
}

function useToast() {
  const [state, setState] = React.useState<State>(memoryState)

  React.useEffect(() => {
    listeners.push(setState)
    return () => {
      const index = listeners.indexOf(setState)
      if (index > -1) {
        listeners.splice(index, 1)
      }
    }
  }, [state])

  return {
    ...state,
    toast,
    dismiss: (toastId?: string) => dispatch({ type: "DISMISS_TOAST", toastId }),
  }
}

export { useToast, toast }



========== C:\Users\satya\Downloads\sarthi-beach-brigade-main\sarthi-beach-brigade-main\src\hooks\useAuth.tsx ==========

import { createContext, useContext, useState, useEffect, ReactNode } from 'react';
import { User, Session } from '@supabase/supabase-js';
import { supabase } from '@/integrations/supabase/client';

interface Profile {
  id: string;
  name: string;
  role: 'volunteer' | 'organizer';
  points: number;
  badges: string[];
  events_attended: number;
  impact_score: number;
}

interface AuthContextType {
  user: User | null;
  profile: Profile | null;
  session: Session | null;
  isAuthenticated: boolean;
  isLoading: boolean;
  signIn: (email: string, password: string) => Promise<{ error: any }>;
  signUp: (email: string, password: string, name: string, role: 'volunteer' | 'organizer') => Promise<{ error: any }>;
  signOut: () => Promise<void>;
}

const AuthContext = createContext<AuthContextType | null>(null);

export const useAuth = () => {
  const context = useContext(AuthContext);
  if (!context) {
    throw new Error('useAuth must be used within an AuthProvider');
  }
  return context;
};

interface AuthProviderProps {
  children: ReactNode;
}

export const AuthProvider = ({ children }: AuthProviderProps) => {
  const [user, setUser] = useState<User | null>(null);
  const [profile, setProfile] = useState<Profile | null>(null);
  const [session, setSession] = useState<Session | null>(null);
  const [isLoading, setIsLoading] = useState(true);

  const fetchProfile = async (userId: string) => {
    try {
      console.log('Fetching profile for user:', userId);
      const { data, error } = await supabase
        .from('profiles')
        .select('*')
        .eq('id', userId)
        .single();

      if (error) {
        console.error('Error fetching profile:', error);
        return null;
      }

      console.log('Profile data fetched:', data);
      // Cast the role to the correct type
      return {
        ...data,
        role: data.role as 'volunteer' | 'organizer'
      } as Profile;
    } catch (error) {
      console.error('Error fetching profile:', error);
      return null;
    }
  };

  useEffect(() => {
    console.log('Setting up auth state listener');
    // Set up auth state listener
    const { data: { subscription } } = supabase.auth.onAuthStateChange(
      async (event, session) => {
        console.log('Auth state changed:', event, session?.user?.email);
        setSession(session);
        setUser(session?.user ?? null);
        
        if (session?.user) {
          // Fetch user profile data
          setTimeout(async () => {
            const profileData = await fetchProfile(session.user.id);
            console.log('Setting profile data:', profileData);
            setProfile(profileData);
            setIsLoading(false);
          }, 0);
        } else {
          setProfile(null);
          setIsLoading(false);
        }
      }
    );

    // Check for existing session
    supabase.auth.getSession().then(({ data: { session } }) => {
      console.log('Initial session check:', session?.user?.email);
      setSession(session);
      setUser(session?.user ?? null);
      
      if (session?.user) {
        fetchProfile(session.user.id).then((profileData) => {
          console.log('Initial profile data:', profileData);
          setProfile(profileData);
          setIsLoading(false);
        });
      } else {
        setIsLoading(false);
      }
    });

    return () => subscription.unsubscribe();
  }, []);

  const signIn = async (email: string, password: string) => {
    setIsLoading(true);
    
    const { error } = await supabase.auth.signInWithPassword({
      email,
      password,
    });

    if (error) {
      setIsLoading(false);
    }
    return { error };
  };

  const signUp = async (email: string, password: string, name: string, role: 'volunteer' | 'organizer') => {
    setIsLoading(true);
    
    const redirectUrl = `${window.location.origin}/`;
    
    const { error } = await supabase.auth.signUp({
      email,
      password,
      options: {
        emailRedirectTo: redirectUrl,
        data: {
          name,
          role,
        }
      }
    });

    if (error) {
      setIsLoading(false);
    }
    return { error };
  };

  const signOut = async () => {
    console.log('Starting sign out process...');
    setIsLoading(true);
    
    try {
      const { error } = await supabase.auth.signOut();
      if (error) {
        console.error('Error during sign out:', error);
        throw error;
      }
      
      // Clear local state immediately
      setUser(null);
      setProfile(null);
      setSession(null);
      
      console.log('Sign out completed successfully');
    } catch (error) {
      console.error('Sign out failed:', error);
      throw error;
    } finally {
      setIsLoading(false);
    }
  };

  const value: AuthContextType = {
    user,
    profile,
    session,
    isAuthenticated: !!session,
    isLoading,
    signIn,
    signUp,
    signOut,
  };

  console.log('Auth context value:', { isAuthenticated: !!session, profile, isLoading });

  return (
    <AuthContext.Provider value={value}>
      {children}
    </AuthContext.Provider>
  );
};



========== C:\Users\satya\Downloads\sarthi-beach-brigade-main\sarthi-beach-brigade-main\src\hooks\useCreateEventForm.ts ==========

import { useState } from 'react';
import { useAuth } from '@/hooks/useAuth';
import { supabase } from '@/integrations/supabase/client';
import { useToast } from '@/hooks/use-toast';

export interface EventFormData {
  title: string;
  description: string;
  location: string;
  date: string;
  time: string;
  maxVolunteers: string;
  category: string;
}

export const useCreateEventForm = (onEventCreated: (event: any) => void, onClose: () => void) => {
  const { user } = useAuth();
  const { toast } = useToast();
  
  const [formData, setFormData] = useState<EventFormData>({
    title: '',
    description: '',
    location: '',
    date: '',
    time: '',
    maxVolunteers: '',
    category: 'beach-cleanup'
  });
  
  const [loading, setLoading] = useState(false);
  const [errors, setErrors] = useState<Record<string, string>>({});

  const validateForm = () => {
    const newErrors: Record<string, string> = {};

    if (!formData.title.trim()) newErrors.title = 'Event title is required';
    if (!formData.description.trim()) newErrors.description = 'Description is required';
    if (!formData.location.trim()) newErrors.location = 'Location is required';
    if (!formData.date) newErrors.date = 'Date is required';
    if (!formData.time) newErrors.time = 'Time is required';
    if (!formData.maxVolunteers || parseInt(formData.maxVolunteers) < 1) {
      newErrors.maxVolunteers = 'Valid number of volunteers is required';
    }

    setErrors(newErrors);
    return Object.keys(newErrors).length === 0;
  };

  const handleSubmit = async (e: React.FormEvent) => {
    e.preventDefault();
    
    if (!validateForm() || !user) return;

    setLoading(true);

    try {
      console.log('Creating event with data:', formData);

      const { data: newEvent, error } = await supabase
        .from('events')
        .insert({
          title: formData.title,
          description: formData.description,
          location: formData.location,
          date: formData.date,
          time: formData.time,
          max_volunteers: parseInt(formData.maxVolunteers),
          organizer_id: user.id,
          status: 'Open',
          difficulty: 'Easy',
          points_reward: 50,
          equipment: []
        })
        .select()
        .single();

      if (error) {
        console.error('Error creating event:', error);
        toast({
          title: "Error",
          description: "Failed to create event. Please try again.",
          variant: "destructive",
        });
        return;
      }

      console.log('Event created successfully:', newEvent);
      
      toast({
        title: "Success!",
        description: "Event created successfully!",
      });

      onEventCreated(newEvent);
      
      // Reset form
      setFormData({
        title: '',
        description: '',
        location: '',
        date: '',
        time: '',
        maxVolunteers: '',
        category: 'beach-cleanup'
      });
      setErrors({});
      onClose();
    } catch (error) {
      console.error('Error in handleSubmit:', error);
      toast({
        title: "Error",
        description: "An unexpected error occurred.",
        variant: "destructive",
      });
    } finally {
      setLoading(false);
    }
  };

  const handleChange = (field: string, value: string) => {
    setFormData(prev => ({ ...prev, [field]: value }));
    if (errors[field]) {
      setErrors(prev => ({ ...prev, [field]: '' }));
    }
  };

  return {
    formData,
    errors,
    loading,
    handleSubmit,
    handleChange
  };
};



========== C:\Users\satya\Downloads\sarthi-beach-brigade-main\sarthi-beach-brigade-main\src\integrations\supabase\client.ts ==========
// This file is automatically generated. Do not edit it directly.
import { createClient } from '@supabase/supabase-js';
import type { Database } from './types';

const SUPABASE_URL = "https://mbofnsqwfjmgmjlxjcxw.supabase.co";
const SUPABASE_PUBLISHABLE_KEY = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Im1ib2Zuc3F3ZmptZ21qbHhqY3h3Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NTA3ODM2ODEsImV4cCI6MjA2NjM1OTY4MX0.DKFASdj-5udhXz8wX_ztIeBtvgrfjsyCzHpHHuro60U";

// Import the supabase client like this:
// import { supabase } from "@/integrations/supabase/client";

export const supabase = createClient<Database>(SUPABASE_URL, SUPABASE_PUBLISHABLE_KEY);



========== C:\Users\satya\Downloads\sarthi-beach-brigade-main\sarthi-beach-brigade-main\src\integrations\supabase\types.ts ==========
export type Json =
  | string
  | number
  | boolean
  | null
  | { [key: string]: Json | undefined }
  | Json[]

export type Database = {
  public: {
    Tables: {
      event_attendance: {
        Row: {
          attended: boolean | null
          event_id: string
          id: string
          marked_at: string | null
          marked_by: string | null
          points_awarded: number | null
          volunteer_id: string
        }
        Insert: {
          attended?: boolean | null
          event_id: string
          id?: string
          marked_at?: string | null
          marked_by?: string | null
          points_awarded?: number | null
          volunteer_id: string
      
Reasons:
  • Blacklisted phrase (1): How do I
  • Long answer (-1):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: sa ga