Document using lightbox and checkOff

PHOTO EMBED

Sun Aug 23 2020 17:17:20 GMT+0000 (UTC)

Saved by @oakfernsara

export function documentation(event, type, lesson, sticky) {
	let $item = $w.at(event.context)
	let data = {
		type: type,
		id: event.context.itemId,
		lesson: lesson,
		sticky: sticky
	}

	console.log('[todo-helper.js documentation] data is', data)

	if (event.target.checked === true) {
		console.log('[todo-helper.js documentation] event.target.checked is true')
		wixWindow.openLightbox('Submit Activities', data)
		.then(result => {
			console.log('[todo-helper.js documentation] returning from lightbox', result)
			if (result.checkOriginal === true) {
				checkOff(event, type)
				.then(() => {
					wixLocation.to('/current-quests')
				})
				
			}
		})
	} else {
		checkOff(event, type)
	}
	
	
}
content_copyCOPY

Takes event, type (db name), data from this item, and optional sticky. If event.target.checked is true, opens Submit Activities lightbox that returns data. If data.checkOriginal is true, the referring item will also be checked off and the user will be redirected to the Current Quests page. If event.target.checked is not true, checkOff is run to mark the item as not done.