Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions .firebase/hosting.ZGlzdA.cache
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
index.html,1749989256616,474429312b97f7883e2a55ffd0d5512ac189a8c263f8783fa13b0afdb1eb85f5
vite.svg,1749989255852,12b282beddfe94d624e7f1155761299a42ce1e3eac8053ebe3f38bd1fa04816c
assets/index-KKYGH1cM.css,1749989256617,f4308d34365633cc77d689ba983b6e9975a8680a7b3e8b3d9062ac160b452a76
assets/LogoImage2-CnRDdseu.png,1749989256616,a66cf9e4a92f730fb63be83da1b3a6737a0d34799ecc5491e8f4bedb65c1cec5
assets/ball-2L3qYoA5.png,1749989256616,0e8d7928863803039d5048359f9a54538133081f818f5fcde6f9ddf4282c9c18
assets/LogoHeader-CUjJw69W.png,1749989256616,ccf0f72db9f9c41a70b0c04e254bcecaaa3888895bcf527f149d9ec7f034ea77
assets/LogoImage1-BCZxbJ3r.png,1749989256617,0a6b7b39cda96fbc44f23ca5185f6e4d6c4e7dc144d58e6c3ffb6550a3e4b4ac
assets/LogoImage4-BLasCPcK.png,1749989256616,2b5d13b40e30f34278efbb79cfb718524a72d19c48ef3a05a73f752a6e0e3480
assets/BannerImage-BOAaKFKq.png,1749989256617,bd2c190e091547aff77f293723e5aa5b5a0c9bb54b046d34a4b6ab6694d74a97
assets/Lizard-j-rDX4sN.png,1749989256617,11d4a15ba7b59919d352f1fc5cd97acdf68fa2877120ae46a88c38ca0127f628
assets/Qing-BHvJUCZo.png,1749989256617,7c46e13fdb2a66e64208a1f458d8dbb94932e4bcb03a02a17473185331593dd8
assets/Eleanor-BaOjiqMk.png,1749989256617,3e1a0aed180077dac941315c7ee29f89c69ab942ccbe27830665cb6ff846773e
assets/index-DJdyAr2J.js,1749989256618,2dbce7cf64a8953ed64ecc6d1bc472464f4e1ac22040e88ca07430746c493a42
vite.svg,1750691927467,12b282beddfe94d624e7f1155761299a42ce1e3eac8053ebe3f38bd1fa04816c
index.html,1750691928148,81939ecaea34adfc35766352e9e4e3a75c9308e8ad992f70c0bdf4095c3a696e
assets/index-DG-8OsDy.css,1750691928146,450d4fd4c3c370c240cc360e058a443269a9349120489fc33c1fa10f8f19433e
assets/LogoImage2-CnRDdseu.png,1750691928146,a66cf9e4a92f730fb63be83da1b3a6737a0d34799ecc5491e8f4bedb65c1cec5
assets/ball-2L3qYoA5.png,1750691928146,0e8d7928863803039d5048359f9a54538133081f818f5fcde6f9ddf4282c9c18
assets/LogoImage1-BCZxbJ3r.png,1750691928146,0a6b7b39cda96fbc44f23ca5185f6e4d6c4e7dc144d58e6c3ffb6550a3e4b4ac
assets/LogoHeader-CUjJw69W.png,1750691928146,ccf0f72db9f9c41a70b0c04e254bcecaaa3888895bcf527f149d9ec7f034ea77
assets/LogoImage4-BLasCPcK.png,1750691928146,2b5d13b40e30f34278efbb79cfb718524a72d19c48ef3a05a73f752a6e0e3480
assets/BannerImage-BOAaKFKq.png,1750691928146,bd2c190e091547aff77f293723e5aa5b5a0c9bb54b046d34a4b6ab6694d74a97
assets/Lizard-j-rDX4sN.png,1750691928148,11d4a15ba7b59919d352f1fc5cd97acdf68fa2877120ae46a88c38ca0127f628
assets/Qing-BHvJUCZo.png,1750691928149,7c46e13fdb2a66e64208a1f458d8dbb94932e4bcb03a02a17473185331593dd8
assets/Eleanor-BaOjiqMk.png,1750691928151,3e1a0aed180077dac941315c7ee29f89c69ab942ccbe27830665cb6ff846773e
assets/index-DjatRlfd.js,1750691928159,3a6a1ec1ae09e8b937c5fec5840590b3cd1be197964833cb7086d1fe0cd406f8
1 change: 1 addition & 0 deletions dist/assets/index-DG-8OsDy.css

Large diffs are not rendered by default.

123 changes: 61 additions & 62 deletions dist/assets/index-BUpXx_cY.js → dist/assets/index-DjatRlfd.js

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion dist/assets/index-RuLCgXo7.css

This file was deleted.

4 changes: 2 additions & 2 deletions dist/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
<link rel="icon" type="image" href="/assets/ball-2L3qYoA5.png" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Toweel</title>
<script type="module" crossorigin src="/assets/index-BUpXx_cY.js"></script>
<link rel="stylesheet" crossorigin href="/assets/index-RuLCgXo7.css">
<script type="module" crossorigin src="/assets/index-DjatRlfd.js"></script>
<link rel="stylesheet" crossorigin href="/assets/index-DG-8OsDy.css">
</head>
<body>
<div id="root"></div>
Expand Down
983 changes: 495 additions & 488 deletions package-lock.json

Large diffs are not rendered by default.

38 changes: 10 additions & 28 deletions src/components/cardReading/CardReading.jsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import { motion, AnimatePresence } from 'framer-motion'
import EmotionCard from '../emotion-card/EmotionCard'
import { useRef, useEffect, useState } from 'react'
import SummaryContent from '../summary/SummaryContent'
import { useDispatch } from 'react-redux'
import { setSummaryOpen } from '../../store/slices/summarySlice'
import { useRef, useEffect} from 'react'
import { simulatedEmotionData } from '../../data/emotionData';

const CardReading = ({ isOpen, onClose, onBackToWheel, emotionData, isLastCard }) => {
const localDefinition = simulatedEmotionData.find(
(item) => item.emotion.toLowerCase() === (emotionData?.emotion || '').toLowerCase()
)?.definition;

const dialogueRef = useRef(null);
const [showSummary, setShowSummary] = useState(false);
const dispatch = useDispatch();
// const [showSummary, setShowSummary] = useState(false);
// const dispatch = useDispatch();

const readingSteps = [
{
Expand All @@ -25,7 +27,8 @@ const CardReading = ({ isOpen, onClose, onBackToWheel, emotionData, isLastCard }
<p className="text-3xl font-bold" style={{ color: emotionData?.textColor || '#2563EB' }}>{emotionData?.emotion || 'Unknown'}</p>
<p className="text-xl mt-4 leading-relaxed font-bold" style={{ color: emotionData?.textColor || '#374151' }}>What is {emotionData?.emotion}?</p>
<p className="text-xl mt-4 leading-relaxed" style={{ color: emotionData?.textColor || '#374151' }}>
{emotionData?.definition || 'No definition available'}</p>
{localDefinition || 'No definition available'}
</p>
{emotionData?.analysis && (
<div className="mt-4">
<p className="text-lg" style={{ color: emotionData?.textColor || '#374151' }}>
Expand Down Expand Up @@ -63,14 +66,6 @@ const CardReading = ({ isOpen, onClose, onBackToWheel, emotionData, isLastCard }
}, [isOpen]);

const handleNextCard = () => {
console.log('handleNextCard called, isLastCard:', isLastCard);

if (isLastCard) {
console.log('Processing last card...');
// Only open the summary, data should already be in Redux
dispatch(setSummaryOpen(true));
console.log('Summary opened');
}
onClose();
};

Expand Down Expand Up @@ -182,19 +177,6 @@ const CardReading = ({ isOpen, onClose, onBackToWheel, emotionData, isLastCard }
</motion.div>
</motion.div>
)}
{showSummary && (
<div className="fixed inset-0 bg-black/50 flex items-center justify-center z-50">
<div className="bg-white rounded-lg p-6 w-full max-w-4xl max-h-[90vh] overflow-y-auto">
<SummaryContent
accumulated_text={emotionData.accumulated_text}
summaryReport={emotionData.summaryReport}
cards={emotionData.cards}
onClose={() => setShowSummary(false)}
showSharedContent={false}
/>
</div>
</div>
)}
</AnimatePresence>
)
}
Expand Down
22 changes: 18 additions & 4 deletions src/components/dialogue/DialogueModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import ReadyModal from './ReadyModal'
import LogoImage2 from '../../assets/LogoImage2.png'
import { structureSummaryReport, createReadingObject } from '../../utils/summaryReportUtils'
import { analyzeEmotionData } from '../../services/emotionAnalysis'
import { setShowDialogue } from '../../store/slices/uiSlice'
import {
setMessages,
addMessage,
Expand Down Expand Up @@ -88,7 +89,7 @@ const DownloadIcon = () => (
</svg>
)

const DialogueModal = forwardRef(({ isOpen, onClose, onEmotionsAnalyzed }, ref) => {
const DialogueModal = forwardRef(({ onClose, onEmotionsAnalyzed }, ref) => {
const dispatch = useDispatch();
const mediaRecorderRef = useRef(null);
const [scope, animate] = useAnimate();
Expand All @@ -111,6 +112,8 @@ const DialogueModal = forwardRef(({ isOpen, onClose, onEmotionsAnalyzed }, ref)
sessionId,
} = useSelector((state) => state.dialogue);

const isOpen = useSelector((state) => state.ui.showDialogue)

// Reset processing state when modal opens
useEffect(() => {
if (isOpen) {
Expand Down Expand Up @@ -370,8 +373,13 @@ const DialogueModal = forwardRef(({ isOpen, onClose, onEmotionsAnalyzed }, ref)

const handleClose = () => {
console.log('DialogueModal: Close button clicked');
// Close ReadyModal first if it's open
if (showReadyModal) {
dispatch(setShowReadyModal(false));
}
dispatch(resetDialogueState());
onClose();
dispatch(setShowDialogue(false))
if(onClose) onClose();
};

const handleEmotionAnalysis = async () => {
Expand Down Expand Up @@ -415,7 +423,7 @@ const DialogueModal = forwardRef(({ isOpen, onClose, onEmotionsAnalyzed }, ref)
console.log('💾 Saved session to localStorage');

// Close DialogueModal
onClose();
if (onClose) onClose();
}
} catch (error) {
console.error('❌ Error during emotion analysis:', error);
Expand Down Expand Up @@ -455,6 +463,7 @@ const DialogueModal = forwardRef(({ isOpen, onClose, onEmotionsAnalyzed }, ref)
<div className="flex justify-between items-center p-4">
<button
className="text-gray-500 hover:text-black text-5xl m-8"
style={{ zIndex: 1100, position: 'relative' }}
onClick={handleClose}
>
×
Expand Down Expand Up @@ -604,7 +613,12 @@ const DialogueModal = forwardRef(({ isOpen, onClose, onEmotionsAnalyzed }, ref)
</motion.div>
)}
</AnimatePresence>
<ReadyModal onSearch={handleEmotionAnalysis} onClose={onClose} />
{showReadyModal && (
<ReadyModal onSearch={handleEmotionAnalysis} onClose={() => {
dispatch(setShowReadyModal(false));
if (onClose) onClose();
}} />
)}
</>
);
});
Expand Down
21 changes: 16 additions & 5 deletions src/components/dialogue/ReadyModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ import { LoadingAnimation } from '../../animations/LoadingAnimation';
import Navbar from '../navbar/Navbar';
import LogoImage1 from '../../assets/LogoImage1.png';
import { setShowReadyModal } from '../../store/slices/dialogueSlice';
import { setSelectedCards, setCurrentSummaryReport } from '../../store/slices/emotionSlice';
import { setSummaryOpen, setSummaryData } from '../../store/slices/summarySlice';
import { setSelectedCards, setCurrentSummaryReport, setCardClickMode } from '../../store/slices/emotionSlice';
import { setSummaryData } from '../../store/slices/summarySlice';
import { setShowSummary } from '../../store/slices/uiSlice';
import { simulatedEmotionData } from '../../data/emotionData';

const BackIcon = () => (
Expand All @@ -20,13 +21,17 @@ const BackIcon = () => (
</svg>
)

const ReadyModal = ({ onSearch }) => {
const ReadyModal = ({ onSearch, onClose }) => {
const dispatch = useDispatch();
const [isLoading, setIsLoading] = useState(false);
const showReadyModal = useSelector((state) => state.dialogue.showReadyModal);

const handleClose = () => {
console.log('ReadyModal: Close button clicked');
dispatch(setShowReadyModal(false));
if (onClose) {
onClose();
}
};

const handleSearch = async () => {
Expand Down Expand Up @@ -76,7 +81,7 @@ const ReadyModal = ({ onSearch }) => {
};
console.log('ReadyModal: Setting summary data to Redux:', summaryData);
dispatch(setSummaryData(summaryData));
dispatch(setSummaryOpen(true));
dispatch(setShowSummary(true));
} else {
console.warn('ReadyModal: No summary_report found in result');
}
Expand All @@ -93,8 +98,14 @@ const ReadyModal = ({ onSearch }) => {
const prev = JSON.parse(localStorage.getItem('emotionReadings') || '[]');
localStorage.setItem('emotionReadings', JSON.stringify([...prev, newReading]));

// Close the ready modal
// Set card click mode to reading and close the ready modal
dispatch(setCardClickMode('reading'));
dispatch(setShowReadyModal(false));

// Close the dialogue modal as well
if (onClose) {
onClose();
}
} else {
console.warn('ReadyModal: No emotions data in result:', result);
}
Expand Down
11 changes: 11 additions & 0 deletions src/components/footer/Footer.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const Footer = () => {
return (
<header className="fixed bottom-1 left-0 w-full z-50 bg-transparent text-gray-500 text-sm py-3 flex justify-center">
<p>
AI Powered with <span className="font-medium">Gemini 2.0</span>
</p>
</header>
);
};

export default Footer;
9 changes: 8 additions & 1 deletion src/components/product-intro/ProductIntroModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ const ProductIntroModal = ({ onGetStarted, onExplore }) => {
<div className="w-full max-w-[90rem] px-2 flex flex-row items-center justify-between m-10">
{/* Left side - Text content */}
<div className="w-1/2 text-left">
{/*ai*/}
<div className="relative inline-flex items-center justify-center px-6 py-2 text-sm font-medium text-gray-800 bg-white rounded-full">
<div className="absolute inset-0 rounded-full border-[3px] border-transparent bg-gradient-to-r from-orange-500 via-blue-500 to-green-500 pointer-events-none mask-border" />
<p className="relative z-10">
<span className="font-semibold text-green-600">AI</span> Powered with <span className="font-semibold text-green-600">Gemini 2.0</span>
</p>
</div>
<h1 className="text-6xl font-bold mb-8 text-gray-800 leading-tight">
Emotions guide you.
Toweel help you listen.
Expand Down Expand Up @@ -48,4 +55,4 @@ const ProductIntroModal = ({ onGetStarted, onExplore }) => {
)
}

export default ProductIntroModal
export default ProductIntroModal
67 changes: 53 additions & 14 deletions src/components/summary/Summary.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,49 @@ import { AnimatePresence } from 'framer-motion'
import { useEffect } from 'react'
import { useSelector, useDispatch } from 'react-redux'
import SummaryContent from './SummaryContent.jsx'
import { setSummaryOpen } from '../../store/slices/summarySlice'
import { setShowSummary } from '../../store/slices/uiSlice'

const Summary = ({ onClose }) => {
console.log("🎉 SummaryContent mounted");

const Summary = () => {
const dispatch = useDispatch();
const showSummary = useSelector((state) => state.ui.showSummary);
const summaryState = useSelector((state) => state.summary) || {
isOpen: false,
cards: [],
accumulatedText: '',
summaryReport: null
};

// Add debug logs for state
useEffect(() => {
console.log('Summary: Current state:', {
showSummary,
summaryState,
cards: summaryState.cards,
summaryReport: summaryState.summaryReport,
accumulatedText: summaryState.accumulatedText,
isHistorical: summaryState.isHistorical
});

// 检查 summaryReport 的结构
if (summaryState.summaryReport) {
console.log('Summary: summaryReport structure:', {
hasKeyInsights: !!summaryState.summaryReport.keyInsights,
hasKeyInsightsSummary: !!summaryState.summaryReport.keyInsightsSummary,
hasMovingForward: !!summaryState.summaryReport.movingForward,
fullReport: summaryState.summaryReport
});
}
}, [showSummary, summaryState]);

// Function to check for duplicate records using timestamp
const isDuplicateRecord = (readings, newReading) => {
return readings.some(reading => reading.timestamp === newReading.timestamp);
};

useEffect(() => {
if (summaryState.isOpen && summaryState.summaryReport) {
if (showSummary && summaryState.summaryReport && !summaryState.isHistorical) {
console.log('Summary: Saving reading to localStorage');
// Save reading to localStorage
const savedReadings = localStorage.getItem('emotionReadings');
const readings = savedReadings ? JSON.parse(savedReadings) : [];
Expand All @@ -32,6 +57,8 @@ const Summary = () => {
accumulated_text: summaryState.accumulatedText,
};

console.log('Summary: New reading object:', newReading);

// Check for duplicates before adding
if (!isDuplicateRecord(readings, newReading)) {
// Add new reading to the beginning of the array
Expand All @@ -47,23 +74,35 @@ const Summary = () => {
window.dispatchEvent(new Event('storage'));
}
}
}, [summaryState.isOpen, summaryState.summaryReport, summaryState.cards, summaryState.accumulatedText]);
}, [showSummary, summaryState.summaryReport, summaryState.cards, summaryState.accumulatedText, summaryState.isHistorical]);

const handleClose = () => {
dispatch(setSummaryOpen(false));
dispatch(setShowSummary(false));
if (onClose) {
onClose(); // 调用父组件传入的清理函数
}
};

return (
<AnimatePresence>
{summaryState.isOpen && (
{showSummary && (
<div className="fixed inset-0 z-[1000] backdrop-blur-md flex items-center justify-center">
<div className="w-full h-full bg-white/40 backdrop-blur flex">
<SummaryContent
accumulated_text={summaryState.accumulatedText}
summaryReport={summaryState.summaryReport}
cards={summaryState.cards}
onClose={handleClose}
/>
<div className="w-full h-full bg-white backdrop-blur flex relative">
<div className="w-full h-[100vh] bg-white rounded-lg overflow-y-auto relative">
{/* Back Button */}
<button
onClick={handleClose}
className="absolute top-4 right-4 z-10 p-2 rounded-full bg-white/80 hover:bg-black/20 transition-colors"
>
x
</button>
<SummaryContent
accumulated_text={summaryState.accumulatedText}
summaryReport={summaryState.summaryReport}
cards={summaryState.cards}
onClose={handleClose}
/>
</div>
</div>
</div>
)}
Expand Down
Loading
Loading