diff --git a/src/views/Chores/SortAndGrouping.jsx b/src/views/Chores/SortAndGrouping.jsx index 608fa05..09b86a0 100644 --- a/src/views/Chores/SortAndGrouping.jsx +++ b/src/views/Chores/SortAndGrouping.jsx @@ -83,6 +83,8 @@ const SortAndGrouping = ({ { name: 'Due Date', value: 'due_date' }, { name: 'Priority', value: 'priority' }, { name: 'Labels', value: 'labels' }, + { name: 'Created Date', value: 'created_date' }, + { name: 'Updated Date', value: 'updated_date' }, ] const filterItems = [ @@ -332,6 +334,8 @@ const SortAndGrouping = ({ { name: 'Due Date', value: 'due_date' }, { name: 'Priority', value: 'priority' }, { name: 'Labels', value: 'labels' }, + { name: 'Created Date', value: 'created_date' }, + { name: 'Updated Date', value: 'updated_date' }, ].map((item, index) => ( + {isWaiting && ( + <> + + + + )} + + {isSuccess ? ( + + ) : isError ? ( + + ) : ( + + )} + + + ) +} + function WriteNFCModal({ config }) { const { ResponsiveModal } = useResponsiveModal() - const [nfcStatus, setNfcStatus] = useState('idle') // 'idle' | 'writing' | 'waiting_for_tag' | 'success' | 'error' + const [nfcStatus, setNfcStatus] = useState('idle') const [errorMessage, setErrorMessage] = useState('') const [isAutoCompleteWhenScan, setIsAutoCompleteWhenScan] = useState(false) + const [copied, setCopied] = useState(false) const cancelScanRef = useRef(null) const isNative = Capacitor.isNativePlatform() @@ -45,6 +147,12 @@ function WriteNFCModal({ config }) { setNfcStatus('idle') } + const handleCopy = () => { + navigator.clipboard.writeText(getURL()) + setCopied(true) + setTimeout(() => setCopied(false), 2000) + } + const writeToNFC = async () => { const url = getURL() @@ -78,99 +186,182 @@ function WriteNFCModal({ config }) { } else { setNfcStatus('error') setErrorMessage( - 'NFC is not supported by this browser. You can still copy the URL and write it to an NFC tag using a compatible device.', + 'NFC is not supported by this browser. Copy the URL and write it to an NFC tag using a compatible device.', ) } } } - const renderBody = () => { - if (nfcStatus === 'success') { - return ( - - URL written to NFC tag successfully! - - ) - } + const isWaiting = nfcStatus === 'waiting_for_tag' || nfcStatus === 'writing' + const isSuccess = nfcStatus === 'success' + const isError = nfcStatus === 'error' - if (nfcStatus === 'waiting_for_tag') { - return ( - <> - - - - Hold your device near the NFC tag - - - - - ) - } + const title = isSuccess + ? 'Tag written!' + : isError + ? 'Something went wrong' + : isWaiting + ? 'Hold near NFC tag' + : 'Write to NFC' - return ( - <> - - {nfcStatus === 'error' - ? errorMessage - : 'Press the button below to write to NFC.'} - - { - navigator.clipboard.writeText(getURL()) - alert('URL copied to clipboard!') - }} - /> - } - /> - - setIsAutoCompleteWhenScan(e.target.checked)} - label='Auto-complete when scanned' - /> - - - - - - ) - } + const subtitle = isSuccess + ? 'Your NFC tag is ready to use.' + : isError + ? errorMessage + : isWaiting + ? 'Keep your device near the tag until complete.' + : 'Encode this task link onto any NFC tag.' return ( - - - {nfcStatus === 'success' ? 'Success!' : 'Write to NFC'} - - {renderBody()} - + <> + + + + {/* Icon */} + + + {/* Heading */} + + {title} + + + {subtitle} + + + {/* Idle / Error: URL + toggle + CTA */} + {!isWaiting && !isSuccess && ( + <> + + + Tag URL + + + + + } + /> + {copied && ( + + Copied! + + )} + + + + + + Auto-complete on scan + + + Mark task done when tag is tapped + + + setIsAutoCompleteWhenScan(e.target.checked)} + size='sm' + /> + + + + + + + + )} + + {/* Waiting state */} + {isWaiting && ( + + )} + + {/* Success state */} + {isSuccess && ( + + )} + + + ) }