feat: The Big One UI #47
@@ -119,7 +119,7 @@ export const StatusList: React.FC<StatusListProps> = ({ title, items, type }) =>
|
|||||||
let isAchieved = item.achieved;
|
let isAchieved = item.achieved;
|
||||||
const showIndicator = type !== 'norm';
|
const showIndicator = type !== 'norm';
|
||||||
const canOverride = showIndicator && !isAchieved;
|
const canOverride = showIndicator && !isAchieved;
|
||||||
|
const isCurrentGoal = type === 'goal' && item.isCurrent;
|
||||||
const handleOverrideClick = () => {
|
const handleOverrideClick = () => {
|
||||||
if (!canOverride) return;
|
if (!canOverride) return;
|
||||||
let contextValue = String(item.id);
|
let contextValue = String(item.id);
|
||||||
@@ -136,7 +136,14 @@ export const StatusList: React.FC<StatusListProps> = ({ title, items, type }) =>
|
|||||||
{isAchieved ? "✔️" : "❌"}
|
{isAchieved ? "✔️" : "❌"}
|
||||||
</span>
|
</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}
|
{item.description || item.label || item.norm}
|
||||||
</span>
|
</span>
|
||||||
</li>
|
</li>
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ const MonitoringPage: React.FC = () => {
|
|||||||
// Can be used to block actions until feedback from CB.
|
// Can be used to block actions until feedback from CB.
|
||||||
const [loading, setLoading] = React.useState(false);
|
const [loading, setLoading] = React.useState(false);
|
||||||
const [activeIds, setActiveIds] = React.useState<Record<string, boolean>>({});
|
const [activeIds, setActiveIds] = React.useState<Record<string, boolean>>({});
|
||||||
|
const [goalIndex, setGoalIndex] = React.useState(0);
|
||||||
|
|
||||||
const phaseIds = getPhaseIds();
|
const phaseIds = getPhaseIds();
|
||||||
const [phaseIndex, setPhaseIndex] = React.useState(0);
|
const [phaseIndex, setPhaseIndex] = React.useState(0);
|
||||||
@@ -29,11 +30,25 @@ const MonitoringPage: React.FC = () => {
|
|||||||
const newIndex = allIds.indexOf(data.phase_id);
|
const newIndex = allIds.indexOf(data.phase_id);
|
||||||
if (newIndex !== -1) {
|
if (newIndex !== -1) {
|
||||||
setPhaseIndex(newIndex);
|
setPhaseIndex(newIndex);
|
||||||
|
setGoalIndex(0); //when phase change we reset the index
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
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' || data.type === 'goal_update') {
|
else if (data.type === 'trigger_update') {
|
||||||
setActiveIds((prev) => ({
|
setActiveIds((prev) => ({
|
||||||
...prev,
|
...prev,
|
||||||
[data.id]: data.achieved // data.id is de key, achieved is true/false
|
[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 {
|
try {
|
||||||
const parsedData = JSON.parse(event.data);
|
const parsedData = JSON.parse(event.data);
|
||||||
if (onUpdate) {
|
if (onUpdate) {
|
||||||
|
console.log(event.data);
|
||||||
onUpdate(parsedData);
|
onUpdate(parsedData);
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|||||||
Reference in New Issue
Block a user