import React from 'react'; import {Text, TouchableOpacity, View} from 'react-native'; import Icon from 'react-native-vector-icons/Feather'; import {opacity, ph, pv, SIZE, WEIGHT} from '../../common/common'; import {useTracked} from '../../provider'; import NavigationService from '../../services/NavigationService'; import {ToastEvent, w} from '../../utils/utils'; import {ActionSheetEvent, moveNoteHideEvent} from '../DialogManager'; import {db} from '../../../App'; export const NotebookItem = ({ item, index, hideMore = false, topic, isTopic = false, isMove = false, noteToMove = null, notebookID, numColumns, isTrash, customStyle, onLongPress, navigation, }) => { const [state, dispatch] = useTracked(); const {colors, selectedItemsList} = state; const navigate = () => { isTopic ? NavigationService.navigate('Notes', { ...item, notebookID, }) : navigation.navigate('Notebook', { notebook: item, title: hideMore ? 'Select Topic' : item.title, isMove: isMove, hideMore: hideMore, }); }; return ( {item.title} {isTopic || !item.description ? null : ( {item.description} )} {isTopic ? null : ( {item && item.topics ? item.topics.slice(1, 4).map(topic => ( {topic.title} )) : null} )} {isTrash ? ( {'Deleted on: ' + new Date(item.dateDeleted).toISOString().slice(0, 10) + ' '} {item.type[0].toUpperCase() + item.type.slice(1) + ' '} ) : null} {isTopic || isTrash ? null : ( {item.favorite ? ( ) : null} {new Date(item.dateCreated).toDateString().substring(4)} )} {isTopic && item.totalNotes > 0 ? ( {item && item.totalNotes && item.totalNotes > 1 ? item.totalNotes + ' notes' : item.totalNotes === 1 ? item.totalNotes + ' note' : null} ) : null} {hideMore || (item.title === 'General' && item.type === 'topic') ? null : ( { let rowItems = isTrash ? ['Restore', 'Remove'] : [ item.type == 'topic' ? 'Edit Topic' : 'Edit Notebook', 'Delete', ]; let columnItems = item.type === 'topic' ? [] : ['Pin', 'Favorite']; ActionSheetEvent(item, false, false, rowItems, columnItems, { notebookID: notebookID, }); }}> )} {hideMore && isTopic ? ( { console.log(selectedItemsList, item); /* let noteIds = []; selectedItemsList.forEach(item => noteIds.push(item.dateCreated)); if (!noteToMove.notebook.notebook) { await db.moveNotes(null, { topic: item.title, id: item.notebookId, }); await db.addNoteToTopic( notebookID, item.title, noteToMove.dateCreated, ); } else if (selectedItemsList) { await db.moveNotes(null, { topic: item.title, id: item.notebookId, }); await db.moveNote(noteToMove.dateCreated, noteToMove.notebook, { notebook: notebookID, topic: item.title, }); }*/ moveNoteHideEvent(); ToastEvent.show( `Note moved to ${item.title}`, 'success', 3000, () => {}, '', ); }} style={{ borderWidth: 1, borderRadius: 5, width: '20%', paddingHorizontal: ph - 5, borderColor: colors.nav, paddingVertical: pv - 5, flexDirection: 'row', justifyContent: 'center', alignItems: 'center', backgroundColor: colors.accent, }}> Move ) : null} ); };