chore: codify React component style
This commit is contained in:
@@ -22,20 +22,20 @@ import {
|
||||
type PositionSectionKind = "stocks" | "bonds" | "other";
|
||||
type AccountPageReturnTone = "positive" | "negative";
|
||||
|
||||
export type AccountPagePosition = Portfolio["positions"][number] & {
|
||||
type AccountPagePosition = Portfolio["positions"][number] & {
|
||||
shareText: string | null;
|
||||
returnText: string | null;
|
||||
returnTone?: AccountPageReturnTone;
|
||||
logoSrc: string | null;
|
||||
};
|
||||
|
||||
export type AccountPagePositionSection = {
|
||||
type AccountPagePositionSection = {
|
||||
kind: PositionSectionKind;
|
||||
wide: boolean;
|
||||
positions: AccountPagePosition[];
|
||||
};
|
||||
|
||||
export type AccountPageRecentOperations =
|
||||
type AccountPageRecentOperations =
|
||||
| {
|
||||
state: "loading" | "error" | "empty";
|
||||
to: string;
|
||||
@@ -46,7 +46,7 @@ export type AccountPageRecentOperations =
|
||||
items: BrokerageOperation[];
|
||||
};
|
||||
|
||||
export type AccountPageRecentEvents =
|
||||
type AccountPageRecentEvents =
|
||||
| {
|
||||
state: "loading" | "error" | "empty";
|
||||
to: string;
|
||||
@@ -77,13 +77,13 @@ type AccountPageEmptyViewModel = AccountPageContent & {
|
||||
state: "empty";
|
||||
};
|
||||
|
||||
export type AccountPageViewModel =
|
||||
type AccountPageViewModel =
|
||||
| { state: "loading" }
|
||||
| { state: "error"; code?: string; retry: () => void }
|
||||
| AccountPageEmptyViewModel
|
||||
| AccountPageLoadedViewModel;
|
||||
|
||||
export function useAccountPageViewModel(): AccountPageViewModel {
|
||||
function useAccountPageViewModel(): AccountPageViewModel {
|
||||
const { accountId } = useParams();
|
||||
const portfolio = usePortfolio(accountId);
|
||||
const operations = useBrokerageOperations(accountId, {
|
||||
@@ -153,7 +153,7 @@ function toRecentEvents(
|
||||
return { state: "loaded", to, items };
|
||||
}
|
||||
|
||||
export function toAccountPagePositionSections(
|
||||
function toAccountPagePositionSections(
|
||||
portfolio: Portfolio,
|
||||
): AccountPagePositionSection[] {
|
||||
const denominators = new Map<string, number>();
|
||||
@@ -221,3 +221,12 @@ function toPosition(
|
||||
logoSrc: wide ? instrumentLogoUrl(position.logoName) : null,
|
||||
};
|
||||
}
|
||||
|
||||
export {
|
||||
type AccountPagePosition,
|
||||
type AccountPagePositionSection,
|
||||
type AccountPageRecentEvents,
|
||||
type AccountPageRecentOperations,
|
||||
toAccountPagePositionSections,
|
||||
useAccountPageViewModel,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user