mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-10-21 22:46:32 +00:00
188d867aee
useDayPlanSidebar returned about 145 names, and DayPlanSidebar destructured the same list again, the largest copied block in the client. Most of it was the component's own props passed straight back, plus values nothing read any more. The optional props' fallbacks move into withDayPlanDefaults, which the hook and the view both read the props through, so they are written once. The hook now returns only what it computes. State that only the view reads (the context menu, the permission flags, the hover and expansion states, the pending note deletion) is declared in the view, and the day note handlers come back as one notes object. The values no one read are gone, which also drops their unused variable warnings. No behaviour changes: every value keeps its source and its fallback.
35 lines
841 B
TypeScript
35 lines
841 B
TypeScript
import type { DayPlanSidebarProps } from './DayPlanSidebar';
|
|
|
|
/**
|
|
* The day plan's props with the optional ones filled in. The plan's hook and its
|
|
* view both read the props through this, so the fallbacks are written once.
|
|
*/
|
|
export function withDayPlanDefaults(props: DayPlanSidebarProps) {
|
|
const {
|
|
accommodations = [],
|
|
reservations = [],
|
|
visibleConnectionIds = [],
|
|
allConnectionsShown = false,
|
|
routeShown = false,
|
|
routeProfile = 'driving',
|
|
canUndo = false,
|
|
lastActionLabel = null,
|
|
showRouteToolsWhenExpanded = false,
|
|
isMobile = false,
|
|
...rest
|
|
} = props;
|
|
return {
|
|
...rest,
|
|
accommodations,
|
|
reservations,
|
|
visibleConnectionIds,
|
|
allConnectionsShown,
|
|
routeShown,
|
|
routeProfile,
|
|
canUndo,
|
|
lastActionLabel,
|
|
showRouteToolsWhenExpanded,
|
|
isMobile,
|
|
};
|
|
}
|