diff --git a/frontend/src/components/Checkout/CheckoutForm.tsx b/frontend/src/components/Checkout/CheckoutForm.tsx index 8fc2dfa..692d358 100644 --- a/frontend/src/components/Checkout/CheckoutForm.tsx +++ b/frontend/src/components/Checkout/CheckoutForm.tsx @@ -5,47 +5,6 @@ import { EmbeddedCheckout, } from "@stripe/react-stripe-js"; -//! Unsure whether this component is used/needed in the project -// export const Return: React.FC = () => { -// const [status, setStatus] = useState(null); -// const [customerEmail, setCustomerEmail] = useState(""); - -// useEffect(() => { -// const queryString = window.location.search; -// const urlParams = new URLSearchParams(queryString); -// const sessionId = urlParams.get("session_id"); - -// if (sessionId) { -// console.log("1"); -// fetch(`/api/session-status?session_id=${sessionId}`) -// .then((res) => res.json()) -// .then((data) => { -// console.log("Response Data:", data); -// setStatus(data.status); -// setCustomerEmail(data.customer_email); -// }); -// } -// }, []); - -// if (status === "open") { -// return ; -// } - -// if (status === "complete") { -// return ( -//
-//

-// We appreciate your business! A confirmation email will be sent to{" "} -// {customerEmail}. If you have any questions, please email{" "} -// orders@example.com. -//

-//
-// ); -// } - -// return null; -// }; - interface CheckoutFormProps { streamerID: number; onClose: () => void; @@ -77,7 +36,7 @@ const CheckoutForm: React.FC = ({ streamerID, onClose }) => { <>
-
+
diff --git a/frontend/src/components/Stream/ChatPanel.tsx b/frontend/src/components/Stream/ChatPanel.tsx index c9914eb..0e3eb46 100644 --- a/frontend/src/components/Stream/ChatPanel.tsx +++ b/frontend/src/components/Stream/ChatPanel.tsx @@ -6,12 +6,17 @@ import { useAuthModal } from "../../hooks/useAuthModal"; import { useAuth } from "../../context/AuthContext"; import { useSocket } from "../../context/SocketContext"; import { useChat } from "../../context/ChatContext"; -import { ArrowLeftFromLineIcon, ArrowRightFromLineIcon } from "lucide-react"; +import { + ArrowLeftFromLineIcon, + ArrowRightFromLineIcon, + CrownIcon, +} from "lucide-react"; interface ChatMessage { chatter_username: string; message: string; time_sent: string; + is_subscribed: boolean; } interface ChatPanelProps { @@ -210,7 +215,7 @@ const ChatPanel: React.FC = ({
{/* Username */} = ({ : (window.location.href = `/user/${msg.chatter_username}`) } > - {msg.chatter_username} + {msg.chatter_username} + {msg.is_subscribed && }
{/* Message content */} diff --git a/web_server/blueprints/chat.py b/web_server/blueprints/chat.py index 91e3cae..402bb27 100644 --- a/web_server/blueprints/chat.py +++ b/web_server/blueprints/chat.py @@ -76,19 +76,32 @@ def get_past_chat(stream_id: int): # Connect to the database db = Database() - # fetched in format: [(username, message, time_sent)] + # fetched in format: [(username, message, time_sent, is_subscribed)] all_chats = db.fetchall(""" - SELECT username, message, time_sent - FROM chat - JOIN users ON chat.chatter_id = users.user_id - WHERE stream_id = ? - ORDER BY time_sent ASC + SELECT + u.username, + c.message, + c.time_sent, + CASE + WHEN s.user_id IS NOT NULL AND s.expires > CURRENT_TIMESTAMP THEN 1 + ELSE 0 + END AS is_subscribed + FROM chat c + JOIN users u ON c.chatter_id = u.user_id + LEFT JOIN subscribes s ON c.chatter_id = s.user_id AND s.subscribed_id = ? + WHERE c.stream_id = ? + ORDER BY c.time_sent ASC LIMIT 50; - """, (stream_id,)) + """, (stream_id, stream_id)) + db.close_connection() # Create JSON output of chat_history to pass through NGINX proxy - chat_history = [{"chatter_username": chat["username"], "message": chat["message"], "time_sent": chat["time_sent"]} for chat in all_chats] + chat_history = [{"chatter_username": chat["username"], + "message": chat["message"], + "time_sent": chat["time_sent"], + "is_subscribed": bool(chat["is_subscribed"])} for chat in all_chats] + print(chat_history) # Pass the chat history to the proxy return jsonify({"chat_history": chat_history}), 200