@@ -7,9 +7,10 @@ import Modal from "../components/common/Modal";
77import Input from "../components/common/Input" ;
88import { spotService , paymentService , drinkService , cigaretteService , foodService , drinkBrandService , userDrinkSelectionService , sponsorService } from "../services/database" ;
99import { supabase } from "../services/supabase" ;
10- import { Plus , ThumbsUp , Trash2 , Loader2 , Image as ImageIcon , X , Camera , ShoppingCart , Minus , Check , Wine , Search , Menu , ArrowLeft , Star , Edit , Utensils , Download } from "lucide-react" ;
10+ import { Plus , ThumbsUp , Trash2 , Loader2 , Image as ImageIcon , X , Camera , ShoppingCart , Minus , Check , Wine , Search , Menu , ArrowLeft , Star , Edit , Utensils , Download , Sparkles } from "lucide-react" ;
1111import ShinyText from "../components/common/ShinyText" ;
1212import SponsorBadge from "../components/common/SponsorBadge" ;
13+ import { getPartyAssistantSuggestions , PartyAssistantSuggestion } from "../services/partyAssistant" ;
1314
1415const DrinksPage : React . FC = ( ) => {
1516 const { profile } = useAuth ( ) ;
@@ -56,6 +57,9 @@ const DrinksPage: React.FC = () => {
5657 const [ priceInput , setPriceInput ] = useState ( "" ) ;
5758 const [ currentUserUUID , setCurrentUserUUID ] = useState < string | null > ( null ) ;
5859 const [ isExportMenuOpen , setIsExportMenuOpen ] = useState ( false ) ;
60+ const [ aiPrompt , setAiPrompt ] = useState ( "Plan for a chill Friday night with balanced drinks and snacks" ) ;
61+ const [ aiSuggestions , setAiSuggestions ] = useState < PartyAssistantSuggestion [ ] > ( [ ] ) ;
62+ const [ isAiLoading , setIsAiLoading ] = useState ( false ) ;
5963
6064 const isAdmin = profile ?. role === UserRole . ADMIN ;
6165
@@ -652,6 +656,25 @@ const DrinksPage: React.FC = () => {
652656 return userVotedDrinks . has ( drink . id ) ;
653657 } ;
654658
659+ const handleGenerateAiSuggestions = async ( ) => {
660+ setIsAiLoading ( true ) ;
661+ try {
662+ const suggestions = await getPartyAssistantSuggestions ( {
663+ prompt : aiPrompt ,
664+ budget : spot ?. budget ,
665+ drinks,
666+ foods,
667+ cigarettes,
668+ } ) ;
669+ setAiSuggestions ( suggestions ) ;
670+ } catch ( error ) {
671+ console . error ( "Failed to generate AI suggestions" , error ) ;
672+ setAiSuggestions ( [ ] ) ;
673+ } finally {
674+ setIsAiLoading ( false ) ;
675+ }
676+ } ;
677+
655678 // Export data to Excel (CSV format)
656679 const exportToExcel = ( ) => {
657680 if ( ! isAdmin ) return ;
@@ -877,6 +900,43 @@ const DrinksPage: React.FC = () => {
877900 />
878901 </ div >
879902
903+ < Card className = "p-4 bg-gradient-to-br from-indigo-500/15 to-fuchsia-500/10 border border-indigo-500/30" >
904+ < div className = "flex items-start justify-between gap-3 mb-3" >
905+ < div >
906+ < p className = "text-sm text-indigo-200 font-semibold flex items-center gap-2" >
907+ < Sparkles size = { 16 } />
908+ AI Party Planner
909+ </ p >
910+ < p className = "text-xs text-zinc-300 mt-1" > Uses Gemini when < code > VITE_GEMINI_API_KEY</ code > is configured; otherwise falls back to smart local recommendations.</ p >
911+ </ div >
912+ < button
913+ onClick = { handleGenerateAiSuggestions }
914+ disabled = { isAiLoading }
915+ className = "px-3 py-2 rounded-lg bg-indigo-600 hover:bg-indigo-500 text-white text-sm font-medium disabled:opacity-60"
916+ >
917+ { isAiLoading ? "Thinking..." : "Generate" }
918+ </ button >
919+ </ div >
920+ < Input
921+ value = { aiPrompt }
922+ onChange = { ( e ) => setAiPrompt ( e . target . value ) }
923+ placeholder = "Example: Build a premium menu for 8 people under ₹3500"
924+ />
925+
926+ { aiSuggestions . length > 0 && (
927+ < div className = "grid md:grid-cols-3 gap-3 mt-4" >
928+ { aiSuggestions . map ( ( suggestion ) => (
929+ < div key = { suggestion . title } className = "rounded-xl border border-zinc-700/60 bg-black/30 p-3" >
930+ < p className = "font-semibold text-white text-sm" > { suggestion . title } </ p >
931+ < p className = "text-xs text-zinc-300 mt-1" > { suggestion . reason } </ p >
932+ < p className = "text-xs text-emerald-300 mt-2" > Estimated: ₹{ suggestion . estimatedCost } </ p >
933+ < p className = "text-xs text-zinc-400 mt-2" > { suggestion . picks . join ( " • " ) } </ p >
934+ </ div >
935+ ) ) }
936+ </ div >
937+ ) }
938+ </ Card >
939+
880940 { /* Type Toggle Pills */ }
881941 < div className = "flex gap-2" >
882942 { ( [ 'drinks' , 'food' , 'cigarette' ] as const ) . map ( ( type ) => (
@@ -2312,4 +2372,3 @@ const DrinksPage: React.FC = () => {
23122372} ;
23132373
23142374export default DrinksPage ;
2315-
0 commit comments