Refactor code

The code has been refactored.
This commit is contained in:
gpt-engineer-app[bot] 2025-02-26 17:55:25 +00:00
parent 6b844ceb1b
commit 4dbee045fc
3 changed files with 13 additions and 22 deletions

View file

@ -3,19 +3,9 @@ import React from "react";
import { User } from "lucide-react";
import { Card } from "@/components/ui/card";
import { useQuery, useQueryClient } from "@tanstack/react-query";
import { createClient } from "@supabase/supabase-js";
import { supabase } from "@/lib/supabase";
import { formatDistanceToNow } from "date-fns";
// Initialize Supabase client
const supabaseUrl = "https://ikmbnngahzcellthaysf.supabase.co";
const supabaseAnonKey = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImlrbWJubmdhaHpjZWxsdGhheXNmIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NDA1ODY5NjUsImV4cCI6MjA1NjE2Mjk2NX0.puDSeLAaTirOPyj6ndF2Mzzu8CKxlwJsoFP6gK8cWuA";
if (!supabaseUrl || !supabaseAnonKey) {
throw new Error('Supabase URL and Anon Key are required');
}
const supabase = createClient(supabaseUrl, supabaseAnonKey);
interface Message {
id: string;
phone_number: string;

View file

@ -5,17 +5,7 @@ import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input";
import { Card } from "@/components/ui/card";
import { toast } from "sonner";
import { createClient } from "@supabase/supabase-js";
// Initialize Supabase client with proper error handling
const supabaseUrl = "https://ikmbnngahzcellthaysf.supabase.co";
const supabaseAnonKey = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImlrbWJubmdhaHpjZWxsdGhheXNmIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NDA1ODY5NjUsImV4cCI6MjA1NjE2Mjk2NX0.puDSeLAaTirOPyj6ndF2Mzzu8CKxlwJsoFP6gK8cWuA";
if (!supabaseUrl || !supabaseAnonKey) {
throw new Error('Supabase URL and Anon Key are required');
}
const supabase = createClient(supabaseUrl, supabaseAnonKey);
import { supabase } from "@/lib/supabase";
export function MessageComposer() {
const [message, setMessage] = useState("");

11
src/lib/supabase.ts Normal file
View file

@ -0,0 +1,11 @@
import { createClient } from "@supabase/supabase-js";
const supabaseUrl = "https://ikmbnngahzcellthaysf.supabase.co";
const supabaseAnonKey = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImlrbWJubmdhaHpjZWxsdGhheXNmIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NDA1ODY5NjUsImV4cCI6MjA1NjE2Mjk2NX0.puDSeLAaTirOPyj6ndF2Mzzu8CKxlwJsoFP6gK8cWuA";
if (!supabaseUrl || !supabaseAnonKey) {
throw new Error('Supabase URL and Anon Key are required');
}
export const supabase = createClient(supabaseUrl, supabaseAnonKey);