Skip to content

Commit

Permalink
Hotfix duplicate type build errors (#155)
Browse files Browse the repository at this point in the history
* Cleanup.

* Run prettier

---------

Co-authored-by: Vineeth Voruganti <13438633+VVoruganti@users.noreply.github.com>
  • Loading branch information
bLopata and VVoruganti authored Oct 18, 2024
1 parent e8e787f commit 889a1db
Show file tree
Hide file tree
Showing 5 changed files with 115 additions and 113 deletions.
72 changes: 37 additions & 35 deletions www/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,29 @@ import useSWR from 'swr';

import dynamic from 'next/dynamic';

import banner from "@/public/bloom2x1.svg";
import darkBanner from "@/public/bloom2x1dark.svg";
import { DarkModeSwitch } from "react-toggle-dark-mode";
import { FaLightbulb, FaPaperPlane, FaBars } from "react-icons/fa";
import Swal from "sweetalert2";
import banner from '@/public/bloom2x1.svg';
import darkBanner from '@/public/bloom2x1dark.svg';
import { DarkModeSwitch } from 'react-toggle-dark-mode';
import { FaLightbulb, FaPaperPlane, FaBars } from 'react-icons/fa';
import Swal from 'sweetalert2';

import { useRef, useEffect, useState, ElementRef } from 'react';
import { redirect } from 'next/navigation';
import { usePostHog } from 'posthog-js/react';

import { getSubscription } from '@/utils/supabase/queries';

import { API } from "@/utils/api";
import { createClient } from "@/utils/supabase/client";
import { Reaction } from "@/components/messagebox";
import { API } from '@/utils/api';
import { createClient } from '@/utils/supabase/client';
import { Reaction } from '@/components/messagebox';

const Thoughts = dynamic(() => import("@/components/thoughts"), {
const Thoughts = dynamic(() => import('@/components/thoughts'), {
ssr: false,
});
const MessageBox = dynamic(() => import("@/components/messagebox"), {
const MessageBox = dynamic(() => import('@/components/messagebox'), {
ssr: false,
});
const Sidebar = dynamic(() => import("@/components/sidebar"), {
const Sidebar = dynamic(() => import('@/components/sidebar'), {
ssr: false,
});

Expand Down Expand Up @@ -164,7 +164,7 @@ export default function Home() {
});
}, true);
} catch (error) {
console.error("Failed to update reaction:", error);
console.error('Failed to update reaction:', error);
}
};

Expand Down Expand Up @@ -272,8 +272,9 @@ export default function Home() {

return (
<main
className={`flex h-[100dvh] w-screen flex-col pb-[env(keyboard-inset-height)] text-sm lg:text-base overflow-hidden relative ${isDarkMode ? 'dark' : ''
}`}
className={`flex h-[100dvh] w-screen flex-col pb-[env(keyboard-inset-height)] text-sm lg:text-base overflow-hidden relative ${
isDarkMode ? 'dark' : ''
}`}
>
<Sidebar
conversations={conversations || []}
Expand Down Expand Up @@ -339,23 +340,23 @@ export default function Home() {
onReactionAdded={handleReactionAdded}
/>
)) || (
<MessageBox
isUser={false}
message={{
text: "",
id: "",
isUser: false,
metadata: { reaction: null },
}}
loading={true}
setThought={setThought}
setIsThoughtsOpen={setIsThoughtsOpen}
onReactionAdded={handleReactionAdded}
userId={userId}
URL={URL}
conversationId={conversationId}
/>
)}
<MessageBox
isUser={false}
message={{
text: '',
id: '',
isUser: false,
metadata: { reaction: null },
}}
loading={true}
setThought={setThought}
setIsThoughtsOpen={setIsThoughtsOpen}
onReactionAdded={handleReactionAdded}
userId={userId}
URL={URL}
conversationId={conversationId}
/>
)}
</section>
<form
id="send"
Expand All @@ -374,10 +375,11 @@ export default function Home() {
placeholder={
isSubscribed ? 'Type a message...' : 'Subscribe to send messages'
}
className={`flex-1 px-3 py-1 lg:px-5 lg:py-3 bg-gray-100 dark:bg-gray-800 text-gray-400 rounded-2xl border-2 resize-none ${canSend && isSubscribed
? 'border-green-200'
: 'border-red-200 opacity-50'
}`}
className={`flex-1 px-3 py-1 lg:px-5 lg:py-3 bg-gray-100 dark:bg-gray-800 text-gray-400 rounded-2xl border-2 resize-none ${
canSend && isSubscribed
? 'border-green-200'
: 'border-red-200 opacity-50'
}`}
rows={1}
disabled={!isSubscribed}
onKeyDown={(e) => {
Expand Down
42 changes: 21 additions & 21 deletions www/components/messagebox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import Image from 'next/image';
import icon from '@/public/bloomicon.jpg';
import usericon from '@/public/usericon.svg';
import Skeleton from 'react-loading-skeleton';
import { FaLightbulb } from 'react-icons/fa';
import { API } from '@/utils/api';
import MarkdownWrapper from './markdownWrapper';
import { FaLightbulb, FaThumbsDown, FaThumbsUp } from 'react-icons/fa';
import { API, type Message } from '@/utils/api';
import Spinner from './spinner';

export type Reaction = "thumbs_up" | "thumbs_down" | null;

export type Reaction = 'thumbs_up' | 'thumbs_down' | null;

interface MessageBoxProps {
isUser?: boolean;
Expand All @@ -23,8 +23,6 @@ interface MessageBoxProps {
onReactionAdded: (messageId: string, reaction: Reaction) => Promise<void>;
}

export type Reaction = "thumbs_up" | "thumbs_down" | null;

export default function MessageBox({
isUser,
userId,
Expand All @@ -42,7 +40,7 @@ export default function MessageBox({

const { id: messageId, text, metadata } = message;
const reaction = metadata?.reaction || null;
const shouldShowButtons = messageId !== "";
const shouldShowButtons = messageId !== '';

const handleReaction = async (newReaction: Exclude<Reaction, null>) => {
if (!messageId || !conversationId || !userId || !URL) return;
Expand All @@ -53,11 +51,11 @@ export default function MessageBox({
const reactionToSend = reaction === newReaction ? null : newReaction;
await onReactionAdded(
messageId,
reactionToSend as Exclude<Reaction, null>,
reactionToSend as Exclude<Reaction, null>
);
} catch (err) {
console.error(err);
setError("Failed to update reaction.");
setError('Failed to update reaction.');
} finally {
setPendingReaction(null);
}
Expand Down Expand Up @@ -108,31 +106,33 @@ export default function MessageBox({
{!loading && !isUser && shouldShowButtons && (
<div className="flex justify-start gap-2 mt-2">
<button
className={`p-2 rounded-full ${reaction === "thumbs_up"
? "bg-blue-500 text-white"
: "bg-gray-200 dark:bg-gray-700"
} ${pendingReaction === "thumbs_up" ? "opacity-50" : ""}`}
onClick={() => handleReaction("thumbs_up")}
className={`p-2 rounded-full ${
reaction === 'thumbs_up'
? 'bg-blue-500 text-white'
: 'bg-gray-200 dark:bg-gray-700'
} ${pendingReaction === 'thumbs_up' ? 'opacity-50' : ''}`}
onClick={() => handleReaction('thumbs_up')}
disabled={pendingReaction !== null}
>
<div className="w-5 h-5 flex items-center justify-center">
{pendingReaction === "thumbs_up" ? (
{pendingReaction === 'thumbs_up' ? (
<Spinner size={16} />
) : (
<FaThumbsUp />
)}
</div>
</button>
<button
className={`p-2 rounded-full ${reaction === "thumbs_down"
? "bg-red-500 text-white"
: "bg-gray-200 dark:bg-gray-700"
} ${pendingReaction === "thumbs_down" ? "opacity-50" : ""}`}
onClick={() => handleReaction("thumbs_down")}
className={`p-2 rounded-full ${
reaction === 'thumbs_down'
? 'bg-red-500 text-white'
: 'bg-gray-200 dark:bg-gray-700'
} ${pendingReaction === 'thumbs_down' ? 'opacity-50' : ''}`}
onClick={() => handleReaction('thumbs_down')}
disabled={pendingReaction !== null}
>
<div className="w-5 h-5 flex items-center justify-center">
{pendingReaction === "thumbs_down" ? (
{pendingReaction === 'thumbs_down' ? (
<Spinner size={16} />
) : (
<FaThumbsDown />
Expand Down
10 changes: 5 additions & 5 deletions www/components/spinner.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import React from "react";
import { FaCircleNotch } from "react-icons/fa";
import React from 'react';
import { FaCircleNotch } from 'react-icons/fa';

const Spinner = ({ size = 24, color = "#000000" }) => {
const Spinner = ({ size = 24, color = '#000000' }) => {
const spinnerStyle = {
animation: "spin 1s linear infinite",
animation: 'spin 1s linear infinite',
color: color,
fontSize: `${size}px`,
};

return (
<div style={{ display: "inline-block" }}>
<div style={{ display: 'inline-block' }}>
<style>
{`
@keyframes spin {
Expand Down
Loading

0 comments on commit 889a1db

Please sign in to comment.