-
Joel Jeremy Marquez authored
* Hooks for frequently made operations * Release notes * Fix typecheck errors * Remove useGlobalPrefs * Add null checks * Fix showCleared pref * Add loaded flag for categories, accounts and payees state * Refactor to reduce unnecessary states * Fix eslint errors * Fix hooks deps * Add useEffect * Fix typecheck error * Set local and global pref hooks * Fix lint error * VRT * Fix typecheck error * Remove eager loading * Fix typecheck error * Fix typo * Fix typecheck error * Update useTheme * Typecheck errors * Typecheck error * defaultValue * Explicitly check undefined * Remove useGlobalPref and useLocalPref defaults * Fix default prefs * Default value * Fix lint error * Set default theme * Default date format in Account * Update packages/desktop-client/src/style/theme.tsx Co-authored-by:
Matiss Janis Aboltins <matiss@mja.lv> --------- Co-authored-by:
Matiss Janis Aboltins <matiss@mja.lv>
Joel Jeremy Marquez authored* Hooks for frequently made operations * Release notes * Fix typecheck errors * Remove useGlobalPrefs * Add null checks * Fix showCleared pref * Add loaded flag for categories, accounts and payees state * Refactor to reduce unnecessary states * Fix eslint errors * Fix hooks deps * Add useEffect * Fix typecheck error * Set local and global pref hooks * Fix lint error * VRT * Fix typecheck error * Remove eager loading * Fix typecheck error * Fix typo * Fix typecheck error * Update useTheme * Typecheck errors * Typecheck error * defaultValue * Explicitly check undefined * Remove useGlobalPref and useLocalPref defaults * Fix default prefs * Default value * Fix lint error * Set default theme * Default date format in Account * Update packages/desktop-client/src/style/theme.tsx Co-authored-by:
Matiss Janis Aboltins <matiss@mja.lv> --------- Co-authored-by:
Matiss Janis Aboltins <matiss@mja.lv>
DisplayId.tsx 1.08 KiB
// @ts-strict-ignore
import React from 'react';
import { useAccount } from '../../hooks/useAccount';
import { usePayee } from '../../hooks/usePayee';
import { theme } from '../../style';
import { Text } from '../common/Text';
type DisplayIdProps = {
type: 'accounts' | 'payees';
id: string;
noneColor?: string;
};
export function DisplayId({
type,
id,
noneColor = theme.pageTextSubdued,
}: DisplayIdProps) {
return type === 'accounts' ? (
<AccountDisplayId id={id} noneColor={noneColor} />
) : (
<PayeeDisplayId id={id} noneColor={noneColor} />
);
}
function AccountDisplayId({ id, noneColor }) {
const account = useAccount(id);
return (
<Text
style={account == null ? { color: noneColor } : null}
title={account ? account.name : 'None'}
>
{account ? account.name : 'None'}
</Text>
);
}
function PayeeDisplayId({ id, noneColor }) {
const payee = usePayee(id);
return (
<Text
style={payee == null ? { color: noneColor } : null}
title={payee ? payee.name : 'None'}
>
{payee ? payee.name : 'None'}
</Text>
);
}