Skip to content

Commit

Permalink
Support changing Merge tags suggestion
Browse files Browse the repository at this point in the history
  • Loading branch information
Rustem Mussabekov committed May 14, 2024
1 parent a32f933 commit 87edb4d
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions src/routes/suggestions/predictions/mergetags.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,32 @@ function Destination({ _id, status, onApply }) {
)
}

export default forwardRef(function MySuggestionsPredictionsMergetags({ prediction: { _id, tags }, status, onApply }, ref) {
export default forwardRef(function MySuggestionsPredictionsMergetags({ prediction: { _id, tags }, status, onUpdate, onApply }, ref) {
//events
const onRemoveClick = useCallback(e=>{
e.preventDefault()
const index = parseInt(e.currentTarget.getAttribute('data-index'))
onUpdate({
_id,
tags: tags.filter((_,i)=>i != index)
})
}, [onUpdate, _id, tags])

if (!tags.length)
return null

return (
<div ref={ref} className={s.prediction} data-status={status}>
<Destination _id={_id} status={status} onApply={onApply} />

<ul>
{tags.map(([original, ...dups])=>(
{tags.map(([original, ...dups], index)=>(
<li key={original}>
Replace {dups.map(tag=><React.Fragment key={tag}><s>#{tag}</s>, </React.Fragment>)} with <b>#{original}</b>
<span>
Replace {dups.map(tag=><React.Fragment key={tag}><s>#{tag}</s>, </React.Fragment>)} with <b>#{original}</b>
</span>
&nbsp;
<a href='' data-index={index} onClick={onRemoveClick}><Icon name='close' size='micro' /></a>
</li>
))}
</ul>
Expand Down

0 comments on commit 87edb4d

Please sign in to comment.