mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-05 10:24:05 +00:00
fix: one status tile list for both admin cards; clear the copied timer on unmount
- The mail import's status tiles (which, labels, tones) were written out in the desktop and the mobile card alike; statTiles in the shared model holds them, each card keeps its own look. - The journey share link set 'copied' back two seconds after a copy even when the dialog had closed, which also broke a client test run (window gone at teardown). useCopied, the trip share's hook, moves to hooks/ and serves both; it clears its timer on unmount. - PlanLlmConfig is not exported: only the union is used outside.
This commit is contained in:
@@ -7,7 +7,7 @@ import { useCanDo } from '../../store/permissionsStore'
|
||||
import { useTripStore } from '../../store/tripStore'
|
||||
import { useTranslation } from '../../i18n'
|
||||
import { getApiErrorMessage } from '../../types'
|
||||
import { copyText } from '../../utils/clipboard'
|
||||
import { useCopied } from '../../hooks/useCopied'
|
||||
import { refusedOffline } from '../../utils/needsConnection'
|
||||
|
||||
// The state behind the share dialog, shared by the desktop dialog and the one the
|
||||
@@ -37,20 +37,6 @@ export const SHARE_OPTIONS: { key: SharePerm; label: string }[] = [
|
||||
{ key: 'share_hide_images', label: 'share.optHideImages' },
|
||||
]
|
||||
|
||||
/** Copy text and show "Copied" for two seconds, the timer restarting on every copy. */
|
||||
function useCopied() {
|
||||
const [copied, setCopied] = useState(false)
|
||||
const timer = useRef<ReturnType<typeof setTimeout> | null>(null)
|
||||
useEffect(() => () => { if (timer.current) clearTimeout(timer.current) }, [])
|
||||
const copy = async (text: string | null) => {
|
||||
if (!text || !(await copyText(text))) return
|
||||
setCopied(true)
|
||||
if (timer.current) clearTimeout(timer.current)
|
||||
timer.current = setTimeout(() => setCopied(false), 2000)
|
||||
}
|
||||
return { copied, copy }
|
||||
}
|
||||
|
||||
/** The public read-only link and what it may show. */
|
||||
export function useShareLink(tripId: number) {
|
||||
const [token, setToken] = useState<string | null>(null)
|
||||
|
||||
Reference in New Issue
Block a user