MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / ChartPanel

Function ChartPanel

console/src/platform/billing/UsagePage.tsx:151–199  ·  view source on GitHub ↗
({
  dailyCosts,
  regionFilter,
  isLoading,
  isError,
  error,
}: ChartPanelProps)

Source from the content-addressed store, hash-verified

149};
150
151const ChartPanel = ({
152 dailyCosts,
153 regionFilter,
154 isLoading,
155 isError,
156 error,
157}: ChartPanelProps) => {
158 const totalSpend = useMemo(
159 () => getTotalSpend(dailyCosts, regionFilter),
160 [dailyCosts, regionFilter],
161 );
162
163 return (
164 <Box data-testid="chart-panel">
165 <HStack justifyContent="space-between" my={3}>
166 <Text
167 as="h4"
168 textStyle="heading-md"
169 data-testid={`${regionFilter}-spend-amount`}
170 >
171 {formatCurrency(totalSpend)}
172 </Text>
173 </HStack>
174 <Flex
175 minHeight={legendHeightPx + chartHeightPx}
176 data-testid="chart-container"
177 >
178 {isLoading && (
179 <Spinner
180 data-testid="chart-loading-spinner"
181 size="xl"
182 margin="auto"
183 />
184 )}
185 {isError && (
186 <ErrorBox
187 data-testid="chart-error"
188 message={
189 error?.message || "There was an error fetching your usage."
190 }
191 />
192 )}
193 {!isLoading && !isError && dailyCosts && (
194 <DailyUsageChart region={regionFilter} data={dailyCosts} />
195 )}
196 </Flex>
197 </Box>
198 );
199};
200
201const UsagePage = () => {
202 const { organization } = useCurrentOrganization();

Callers

nothing calls this directly

Calls 2

formatCurrencyFunction · 0.90
getTotalSpendFunction · 0.85

Tested by

no test coverage detected