diff --git a/src/components/GoalActivity.tsx b/src/components/GoalActivity.tsx index 08cb7d9ab..f06af74db 100644 --- a/src/components/GoalActivity.tsx +++ b/src/components/GoalActivity.tsx @@ -135,6 +135,7 @@ export const GoalActivity = forwardRef( )} {value.subject === 'criteria' && ( diff --git a/src/components/HistoryRecord/HistoryRecord.tsx b/src/components/HistoryRecord/HistoryRecord.tsx index 72f25c718..820ce5369 100644 --- a/src/components/HistoryRecord/HistoryRecord.tsx +++ b/src/components/HistoryRecord/HistoryRecord.tsx @@ -443,17 +443,46 @@ export const HistoryRecordParticipant: React.FC ); +type CriteriaItem = GoalAchieveCriteria & { + goalAsCriteria: (Goal & { state: StateData | null }) | null; + strike?: boolean; +}; + +const HistoryRecordCriteriaItem: React.FC = ({ goalAsCriteria, title, strike }) => { + if (goalAsCriteria) { + return ( + + ); + } + + return ( + + {title} + + ); +}; + export const HistoryRecordCriteria: React.FC< - HistoryChangeProps & { + HistoryChangeProps & { action: HistoryAction; + strike?: boolean; } -> = ({ to, action }) => { +> = ({ from, to, action }) => { const recordCtx = useContext(RecordCtx); const isChangeAction = ['complete', 'uncomplete'].includes(action); recordCtx.setSubjectText((prev) => { - if (to?.goalAsCriteria != null) { + const target = from || to; + if (target?.goalAsCriteria != null) { if (isChangeAction) { if (action === 'complete') { return 'goalComplete'; @@ -470,43 +499,23 @@ export const HistoryRecordCriteria: React.FC< return prev; }); - return nullable(to, (t) => { - if (t?.goalAsCriteria) { - return ( - - - {tr('as criteria')} - - } - /> - ); - } - - return ( - - - {t.title} - - {nullable(isChangeAction, () => ( - {tr(action === 'complete' ? 'as completed' : 'as uncompleted')} - ))} - - } - /> - ); - }); + return ( + ( + + ))} + to={nullable(to, (val) => ( + <> + + {val?.goalAsCriteria && {tr('as criteria')}} + {nullable(isChangeAction, () => ( + + {tr(action === 'complete' ? 'as completed' : 'as uncompleted')} + + ))} + + ))} + /> + ); };