-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This pull request introduces several significant changes, including the addition of a new AI advisor feature, updates to the rewards page, and enhancements to the messaging system. The most important changes are summarized below: ### AI Advisor Feature: * Added a new `AdvisorChatbot` component that allows users to interact with an AI advisor. This includes setting up the chat interface, handling message sending, and displaying messages. (`app/(tabs)/ai-advisor.tsx`) * Updated `TabLayout` to include the new AI advisor tab with an appropriate icon. (`app/(tabs)/_layout.tsx`) [[1]](diffhunk://#diff-ea7f70dea9b63c4fcf80ad308f46fc316bfd05e41531a2a44dd56e1ea215a637R7) [[2]](diffhunk://#diff-ea7f70dea9b63c4fcf80ad308f46fc316bfd05e41531a2a44dd56e1ea215a637R87-R98) ### Rewards Page Enhancements: * Refactored the rewards page to fetch and display rewards dynamically, including a search functionality to filter rewards. (`app/(tabs)/rewards.tsx`) [[1]](diffhunk://#diff-c35e1e058777e8b7e00c54546afb9a15451de31415bb33b3e65497322ecc17ebL1-R42) [[2]](diffhunk://#diff-c35e1e058777e8b7e00c54546afb9a15451de31415bb33b3e65497322ecc17ebL33-L149) * Updated the single reward page to fetch reward details dynamically and display additional information such as images and legal disclosures. (`app/rewards/[id].tsx`) ([app/rewards/[id].tsxL1-R98](diffhunk://#diff-e9cb913d6859fe44b83b3a2f5065f76164b17d5beda8c9a8e010218dfba95a4fL1-R98)) ### Messaging System Improvements: * Added new queries and mutations for handling messages, including fetching messages by thread ID and sending messages. (`convex/messages.ts`) * Updated the schema to include new tables for messages and threads, with appropriate indexing. (`convex/schema.ts`) ### UI and Styling Updates: * Introduced a new CSS file for styling the reward descriptions and links. (`app/rewards/dom-content.css`) * Enhanced the `Input` component to use a consistent font family across the application. (`components/ui/input.tsx`) [[1]](diffhunk://#diff-c2f62fb0cb5e2955363d1c27d9cb0b33d03fed2193d16c3877af492d82770d2cR3) [[2]](diffhunk://#diff-c2f62fb0cb5e2955363d1c27d9cb0b33d03fed2193d16c3877af492d82770d2cR12-R14) These changes collectively improve the functionality and user experience of the application, particularly with the introduction of the AI advisor and the dynamic handling of rewards.- **add Bot icon**
- Loading branch information
Showing
19 changed files
with
5,044 additions
and
6,403 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
import { SafeAreaView } from "react-native-safe-area-context"; | ||
// import AsyncStorage from "@react-native-async-storage/async-storage"; | ||
|
||
import { useState, useRef, useMemo } from "react"; | ||
import { View, KeyboardAvoidingView, Platform, FlatList } from "react-native"; | ||
import { Text } from "~/components/ui/text"; | ||
import { Button } from "~/components/ui/button"; | ||
import { useMutation, useQuery } from "convex/react"; | ||
import { api } from "~/convex/_generated/api"; | ||
import { cn } from "~/lib/utils"; | ||
import { Send } from "~/lib/icons/Send"; | ||
import { Input } from "~/components/ui/input"; | ||
import { Separator } from "~/components/ui/separator"; | ||
|
||
export default function AdvisorChatbot() { | ||
const thread = useQuery(api.threads.getThread); | ||
const remoteMessages = useQuery(api.messages.getMessages, { | ||
threadId: thread?.threadId, | ||
}); | ||
const sendMessage = useMutation(api.messages.sendMessage); | ||
|
||
const messages = useMemo( | ||
() => | ||
[ | ||
{ | ||
role: "assistant", | ||
content: | ||
"Hey there, I'm your personal AI Advisor. What can I help you with?", | ||
threadId: "", | ||
}, | ||
].concat(remoteMessages ?? []), | ||
[remoteMessages] | ||
); | ||
|
||
const [inputText, setInputText] = useState(""); | ||
const flatListRef = useRef<FlatList>(null); | ||
|
||
const handleSend = async () => { | ||
if (!inputText) { | ||
return; | ||
} | ||
await sendMessage({ threadId: thread?.threadId, message: inputText }); | ||
setInputText(""); | ||
}; | ||
|
||
return ( | ||
<SafeAreaView | ||
style={{ flex: 1, backgroundColor: "#082139" }} | ||
edges={["top", "left", "right"]} | ||
> | ||
<KeyboardAvoidingView | ||
behavior={Platform.OS === "ios" ? "padding" : "height"} | ||
className="flex-1" | ||
> | ||
<FlatList | ||
ref={flatListRef} | ||
data={messages} | ||
onContentSizeChange={() => { | ||
if (flatListRef.current) { | ||
flatListRef.current.scrollToEnd({ animated: true }); | ||
} | ||
}} | ||
renderItem={({ item }) => ( | ||
<MessageComp isViewer={item.role === "user"} text={item.content} /> | ||
)} | ||
ItemSeparatorComponent={() => <Separator />} | ||
/> | ||
|
||
<View className="relative flex-row items-center justify-between bg-card"> | ||
<Input | ||
className="native:h-20 flex-1 rounded-none border-0 bg-card py-6 placeholder:text-muted-foreground" | ||
value={inputText} | ||
onChangeText={setInputText} | ||
placeholder="Send a message..." | ||
multiline | ||
/> | ||
<Button variant="ghost" hitSlop={20} onPress={handleSend}> | ||
<Send className="text-white" /> | ||
</Button> | ||
</View> | ||
</KeyboardAvoidingView> | ||
</SafeAreaView> | ||
); | ||
} | ||
|
||
function MessageComp({ text, isViewer }: { text: string; isViewer: boolean }) { | ||
return ( | ||
<View className={cn("gap-3 p-4", isViewer && "bg-card")}> | ||
<Text className={cn(!isViewer && "font-semibold")}>{text}</Text> | ||
<Text | ||
className={cn( | ||
"text-sm font-light text-muted-foreground", | ||
isViewer && "text-right" | ||
)} | ||
> | ||
{isViewer ? "You" : "LT AI Advisor"} | ||
</Text> | ||
</View> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.