Refresh home and more navigation
This commit is contained in:
@@ -105,7 +105,6 @@ export function TimeClockPanel({
|
||||
const [featuredClientIds, setFeaturedClientIds] = useState<string[]>([]);
|
||||
const [storedLastClientId, setStoredLastClientId] = useState<string | null>(null);
|
||||
const [prefsLoaded, setPrefsLoaded] = useState(false);
|
||||
const [initialClientResolved, setInitialClientResolved] = useState(Boolean(defaultClientId));
|
||||
|
||||
const running = runningQuery.data;
|
||||
const elapsed = useRunningElapsed(running?.startedAt);
|
||||
@@ -210,32 +209,6 @@ export function TimeClockPanel({
|
||||
setRateText((current) => current.trim() || clientRateText(client));
|
||||
}, [clientId, clients, running]);
|
||||
|
||||
useEffect(() => {
|
||||
if (running || defaultClientId || initialClientResolved) return;
|
||||
if (!prefsLoaded || clients.length === 0) return;
|
||||
|
||||
const preferredId =
|
||||
storedLastClientId && clients.some((client) => client.id === storedLastClientId)
|
||||
? storedLastClientId
|
||||
: recentClientIds.find((id) => clients.some((client) => client.id === id)) ?? null;
|
||||
|
||||
if (preferredId) {
|
||||
const client = clients.find((c) => c.id === preferredId);
|
||||
setClientId(preferredId);
|
||||
setRateText(clientRateText(client));
|
||||
}
|
||||
|
||||
setInitialClientResolved(true);
|
||||
}, [
|
||||
clients,
|
||||
defaultClientId,
|
||||
initialClientResolved,
|
||||
prefsLoaded,
|
||||
recentClientIds,
|
||||
running,
|
||||
storedLastClientId,
|
||||
]);
|
||||
|
||||
useEffect(() => {
|
||||
if (featuredClientIds.length > 0 || !prefsLoaded || clients.length === 0) return;
|
||||
|
||||
@@ -332,10 +305,12 @@ export function TimeClockPanel({
|
||||
setClientId(nextClientId);
|
||||
setInvoiceId("");
|
||||
setRateText(clientRateText(client));
|
||||
if (!featuredClientIds.includes(nextClientId)) {
|
||||
if (nextClientId && !featuredClientIds.includes(nextClientId)) {
|
||||
setClientsExpanded(true);
|
||||
}
|
||||
void persistClientChoice(nextClientId);
|
||||
if (nextClientId) {
|
||||
void persistClientChoice(nextClientId);
|
||||
}
|
||||
}
|
||||
|
||||
function selectInvoice(nextInvoiceId: string) {
|
||||
@@ -596,6 +571,11 @@ export function TimeClockPanel({
|
||||
) : (
|
||||
<>
|
||||
<View style={styles.chipWrap}>
|
||||
<FilterChip
|
||||
label="No client"
|
||||
active={!clientId}
|
||||
onPress={() => selectClient("")}
|
||||
/>
|
||||
{featuredClients.map((client) => renderClientChip(client))}
|
||||
{moreClients.length > 0 ? (
|
||||
<FilterChip
|
||||
@@ -617,7 +597,9 @@ export function TimeClockPanel({
|
||||
<View style={styles.setupSection}>
|
||||
<Text style={styles.sectionLabel}>Invoice (optional)</Text>
|
||||
{!clientId ? (
|
||||
<Text style={styles.emptyClients}>Pick a client to attach a draft invoice.</Text>
|
||||
<Text style={styles.emptyClients}>
|
||||
No invoice for now. Add a client and invoice later if this becomes billable.
|
||||
</Text>
|
||||
) : (
|
||||
<View style={styles.chipWrap}>
|
||||
<FilterChip label="Entry only" active={!invoiceId} onPress={() => setInvoiceId("")} />
|
||||
|
||||
Reference in New Issue
Block a user