|
|
|
@ -1,26 +1,8 @@ |
|
|
|
|
import React, { Component } from 'react'; |
|
|
|
|
import React, { Component, useEffect } from 'react'; |
|
|
|
|
import { SortableContainer, SortableElement } from 'react-sortable-hoc'; |
|
|
|
|
import arrayMove from 'array-move'; |
|
|
|
|
import ArrowRightAltIcon from '@material-ui/icons/ArrowRightAlt'; |
|
|
|
|
|
|
|
|
|
const SortableItem = SortableElement(({ row }) => ( |
|
|
|
|
<div className="message-2d__options--row d-flex"> |
|
|
|
|
{row.map((item) => ( |
|
|
|
|
<div>{item.text}</div> |
|
|
|
|
))} |
|
|
|
|
</div> |
|
|
|
|
)); |
|
|
|
|
|
|
|
|
|
const SortableList = SortableContainer(({ items }) => { |
|
|
|
|
return ( |
|
|
|
|
<div className="message-2d__options d-flex flex-column"> |
|
|
|
|
{items.map((row, index) => ( |
|
|
|
|
<SortableItem key={`item-${index}`} index={index} value={row} /> |
|
|
|
|
))} |
|
|
|
|
</div> |
|
|
|
|
); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
export default class DraggableMessage extends Component { |
|
|
|
|
state = { |
|
|
|
|
items: ['استقلال', 'پرسپولیس', 'سپاهان'], |
|
|
|
@ -31,6 +13,7 @@ export default class DraggableMessage extends Component { |
|
|
|
|
items: arrayMove(items, oldIndex, newIndex), |
|
|
|
|
})); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
render() { |
|
|
|
|
const { message, user, isSelf } = this.props; |
|
|
|
|
return ( |
|
|
|
@ -53,7 +36,7 @@ export default class DraggableMessage extends Component { |
|
|
|
|
</p> |
|
|
|
|
) : null} |
|
|
|
|
</div> |
|
|
|
|
<SortableList items={this.state.items} onSortEnd={this.onSortEnd} /> |
|
|
|
|
<SortableList items={message.options} onSortEnd={this.onSortEnd} /> |
|
|
|
|
<button className="message-2d__submit"> |
|
|
|
|
ثبت |
|
|
|
|
<ArrowRightAltIcon style={{ color: 'white', width: 32, height: 32, marginLeft: 10 }} /> |
|
|
|
@ -62,3 +45,21 @@ export default class DraggableMessage extends Component { |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const SortableList = SortableContainer(({ items }) => { |
|
|
|
|
return ( |
|
|
|
|
<div className="message-2d__options d-flex flex-column"> |
|
|
|
|
{items.map((row, index) => ( |
|
|
|
|
<SortableItem key={`item-${index}`} index={index} value={row} /> |
|
|
|
|
))} |
|
|
|
|
</div> |
|
|
|
|
); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
const SortableItem = SortableElement(({ value }) => ( |
|
|
|
|
<div className="message-2d__options--row d-flex"> |
|
|
|
|
{value.map((item) => ( |
|
|
|
|
<div>{item.text}</div> |
|
|
|
|
))} |
|
|
|
|
</div> |
|
|
|
|
)); |
|
|
|
|