Naufal Arhab commited on
Commit
663d525
·
1 Parent(s): ead8917

refactor(journal): ensure resilient stats refresh and tab badge counts

Browse files
frontend/src/components/signals/AIExecutiveSummaryCard.tsx CHANGED
@@ -1,4 +1,4 @@
1
- import { useState } from 'react';
2
  import {
3
  Sparkles,
4
  TrendingUp,
@@ -287,6 +287,11 @@ export function AIExecutiveSummaryCard({
287
  const [isLogged, setIsLogged] = useState(false);
288
  const { toast } = useToast();
289
 
 
 
 
 
 
290
  const summary = parseAIExecutiveSummary(content, inputBias, dataSnapshot, tradeLevels);
291
  if (!summary) return null;
292
 
 
1
+ import { useState, useEffect } from 'react';
2
  import {
3
  Sparkles,
4
  TrendingUp,
 
287
  const [isLogged, setIsLogged] = useState(false);
288
  const { toast } = useToast();
289
 
290
+ useEffect(() => {
291
+ setIsLogged(false);
292
+ setCopied(false);
293
+ }, [symbol, content]);
294
+
295
  const summary = parseAIExecutiveSummary(content, inputBias, dataSnapshot, tradeLevels);
296
  if (!summary) return null;
297
 
frontend/src/pages/TradeJournal.tsx CHANGED
@@ -156,13 +156,19 @@ export function TradeJournal({ onNavigateToAI }: TradeJournalProps) {
156
  const handleConfirmDelete = async () => {
157
  if (!deleteModalData) return;
158
  setIsDeleting(true);
 
 
159
  try {
160
- await journalApi.deleteEntry(deleteModalData.id);
161
- setEntries((prev) => prev.filter((e) => e.id !== deleteModalData.id));
162
- const newStats = await journalApi.getStats();
163
- setStats(newStats);
164
- toast(`[${deleteModalData.symbol}] Berhasil dihapus permanen dari Jurnal & Database.`, 'info');
165
  setDeleteModalData(null);
 
 
 
 
 
 
 
166
  } catch (err: any) {
167
  toast(err.message || 'Gagal menghapus catatan trade', 'error');
168
  } finally {
@@ -371,11 +377,11 @@ export function TradeJournal({ onNavigateToAI }: TradeJournalProps) {
371
  {/* Status Filter Tabs */}
372
  <div className="flex items-center gap-1 overflow-x-auto no-scrollbar">
373
  {[
374
- { id: 'ALL', label: 'Semua' },
375
  { id: 'PENDING', label: `Pending (${stats.pending})` },
376
  { id: 'HIT_TP', label: `Hit TP (${stats.hit_tp})` },
377
  { id: 'HIT_SL', label: `Hit SL (${stats.hit_sl})` },
378
- { id: 'CANCELLED', label: 'Batal' },
379
  ].map((tab) => (
380
  <button
381
  key={tab.id}
 
156
  const handleConfirmDelete = async () => {
157
  if (!deleteModalData) return;
158
  setIsDeleting(true);
159
+ const deletedSymbol = deleteModalData.symbol;
160
+ const deletedId = deleteModalData.id;
161
  try {
162
+ await journalApi.deleteEntry(deletedId);
163
+ setEntries((prev) => prev.filter((e) => e.id !== deletedId));
 
 
 
164
  setDeleteModalData(null);
165
+ toast(`[${deletedSymbol}] Berhasil dihapus permanen dari Jurnal & Database.`, 'info');
166
+ try {
167
+ const newStats = await journalApi.getStats();
168
+ setStats(newStats);
169
+ } catch {
170
+ // Non-fatal stats refresh
171
+ }
172
  } catch (err: any) {
173
  toast(err.message || 'Gagal menghapus catatan trade', 'error');
174
  } finally {
 
377
  {/* Status Filter Tabs */}
378
  <div className="flex items-center gap-1 overflow-x-auto no-scrollbar">
379
  {[
380
+ { id: 'ALL', label: `Semua (${stats.total})` },
381
  { id: 'PENDING', label: `Pending (${stats.pending})` },
382
  { id: 'HIT_TP', label: `Hit TP (${stats.hit_tp})` },
383
  { id: 'HIT_SL', label: `Hit SL (${stats.hit_sl})` },
384
+ { id: 'CANCELLED', label: `Batal (${stats.cancelled})` },
385
  ].map((tab) => (
386
  <button
387
  key={tab.id}