feat: goals now update in UI
ref: N25B-400
This commit is contained in:
@@ -119,7 +119,7 @@ export const StatusList: React.FC<StatusListProps> = ({ title, items, type }) =>
|
||||
let isAchieved = item.achieved;
|
||||
const showIndicator = type !== 'norm';
|
||||
const canOverride = showIndicator && !isAchieved;
|
||||
|
||||
const isCurrentGoal = type === 'goal' && item.isCurrent;
|
||||
const handleOverrideClick = () => {
|
||||
if (!canOverride) return;
|
||||
let contextValue = String(item.id);
|
||||
@@ -136,7 +136,14 @@ export const StatusList: React.FC<StatusListProps> = ({ title, items, type }) =>
|
||||
{isAchieved ? "✔️" : "❌"}
|
||||
</span>
|
||||
)}
|
||||
<span className={styles.itemDescription}>
|
||||
<span
|
||||
className={styles.itemDescription}
|
||||
style={{
|
||||
textDecoration: isCurrentGoal ? 'underline' : 'none',
|
||||
fontWeight: isCurrentGoal ? 'bold' : 'normal',
|
||||
color: isCurrentGoal ? '#007bff' : 'inherit'
|
||||
}}
|
||||
>
|
||||
{item.description || item.label || item.norm}
|
||||
</span>
|
||||
</li>
|
||||
|
||||
@@ -17,6 +17,7 @@ const MonitoringPage: React.FC = () => {
|
||||
// Can be used to block actions until feedback from CB.
|
||||
const [loading, setLoading] = React.useState(false);
|
||||
const [activeIds, setActiveIds] = React.useState<Record<string, boolean>>({});
|
||||
const [goalIndex, setGoalIndex] = React.useState(0);
|
||||
|
||||
const phaseIds = getPhaseIds();
|
||||
const [phaseIndex, setPhaseIndex] = React.useState(0);
|
||||
@@ -29,11 +30,25 @@ const MonitoringPage: React.FC = () => {
|
||||
const newIndex = allIds.indexOf(data.phase_id);
|
||||
if (newIndex !== -1) {
|
||||
setPhaseIndex(newIndex);
|
||||
setGoalIndex(0); //when phase change we reset the index
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
else if (data.type === 'trigger_update' || data.type === 'goal_update') {
|
||||
else if (data.type === 'goal_update') {
|
||||
// We find which goal in the current phase matches this ID
|
||||
const currentPhaseGoals = getGoalsInPhase(phaseIds[phaseIndex]);
|
||||
const gIndex = currentPhaseGoals.findIndex((g: any) => g.id === data.id);
|
||||
if (gIndex !== -1) {
|
||||
setGoalIndex(gIndex);
|
||||
console.log(`Goal index updated to ${gIndex} for goal ID ${data.id}`);
|
||||
}
|
||||
|
||||
setActiveIds((prev) => ({
|
||||
...prev,
|
||||
[data.id]: true
|
||||
}));
|
||||
}
|
||||
|
||||
else if (data.type === 'trigger_update') {
|
||||
setActiveIds((prev) => ({
|
||||
...prev,
|
||||
[data.id]: data.achieved // data.id is de key, achieved is true/false
|
||||
|
||||
@@ -31,6 +31,7 @@ export function useExperimentLogger(onUpdate?: (data: any) => void) {
|
||||
try {
|
||||
const parsedData = JSON.parse(event.data);
|
||||
if (onUpdate) {
|
||||
console.log(event.data);
|
||||
onUpdate(parsedData);
|
||||
}
|
||||
} catch (err) {
|
||||
|
||||
Reference in New Issue
Block a user