Fix typecheck

pull/1967/head
Johan Girod 2022-01-12 14:18:41 +01:00 committed by Maxime Quandalle
parent d9cd522dd8
commit 3745f32f0a
7 changed files with 21 additions and 24 deletions

View File

@ -66,7 +66,7 @@ export default function PagesChart({ data, sync = true }: PagesChartProps) {
<XAxis dataKey="date" type="category" tickFormatter={formatMonth} />
<YAxis
tickFormatter={formatValue}
tickFormatter={(x) => formatValue(x)}
domain={['0', 'auto']}
type="number"
/>
@ -94,7 +94,10 @@ function formatMonth(date: string | Date) {
})
}
const CustomTooltip = ({ active, payload }: TooltipProps) => {
const CustomTooltip = ({
active,
payload,
}: TooltipProps<string | number, string>) => {
if (!active || !payload) {
return null
}
@ -111,7 +114,7 @@ const CustomTooltip = ({ active, payload }: TooltipProps) => {
<Strong>
{typeof value === 'number' ? formatValue(value) : value}
</Strong>{' '}
{formatLegend(name)}
{name && formatLegend(name)}
</ColoredLi>
))
.reverse()}

View File

@ -69,7 +69,6 @@ export default function MonEntrepriseRulePage() {
Head: Helmet,
Link: Link as React.ComponentType<{
to: string
children: React.ReactNode
}>,
References,
}}

View File

@ -2,7 +2,7 @@ import PDFElement from '@react-pdf/renderer'
import { EngineContext } from 'Components/utils/EngineContext'
import { formatValue, RuleNode } from 'publicodes'
import { useContext } from 'react'
const { StyleSheet, Text, View } = PDFElement;
const { StyleSheet, Text, View } = PDFElement
type FieldsPDFProps = {
fields: Array<RuleNode>
}

View File

@ -1,20 +1,11 @@
import PDFElement from '@react-pdf/renderer'
import PDFElement from '@react-pdf/renderer'
import urssafPng from 'Images/destinataires/Urssaf.png'
import { RuleNode } from 'publicodes'
import FieldsPDF, { styles as fieldStyles } from './FieldsPDF'
import montserratUrl from './Montserrat-SemiBold.ttf'
import robotoUrl from './Roboto-Regular.ttf'
const {
Document,
Font,
Image,
Link,
Page,
StyleSheet,
Text,
View,
} = PDFElement;
const { Document, Font, Image, Link, Page, StyleSheet, Text, View } = PDFElement
export type PDFDocumentProps = {
fields: Array<RuleNode>

View File

@ -3,11 +3,13 @@ import { Strong } from 'DesignSystem/typography'
import { Li, Ul } from 'DesignSystem/typography/list'
import { Body } from 'DesignSystem/typography/paragraphs'
import { formatValue } from 'publicodes'
import { ComponentProps } from 'react'
import { useContext } from 'react'
import {
Area,
Bar,
Brush,
BrushProps,
CartesianGrid,
ComposedChart,
Legend,
@ -32,12 +34,9 @@ type VisitsChartProps = {
grid?: boolean
colored?: boolean
layout?: 'horizontal' | 'vertical'
onDateChange?: ({
startIndex,
endIndex,
}: {
startIndex: number
endIndex: number
onDateChange?: (startEndIndex: {
startIndex?: number
endIndex?: number
}) => void
startIndex?: number
endIndex?: number
@ -111,7 +110,7 @@ export default function VisitsChart({
startIndex={startIndex}
endIndex={endIndex}
dataKey="date"
onChange={onDateChange}
onChange={onDateChange as BrushProps['onChange']} // https://github.com/recharts/recharts/issues/2480
tickFormatter={period === 'jours' ? formatDay : formatMonth}
/>
)}

View File

@ -0,0 +1,5 @@
declare module 'vite-plugin-shim-react-pdf' {
import { Plugin } from 'vite'
const plugin: () => Plugin
export default plugin
}

View File

@ -138,7 +138,7 @@ function multipleSPA(options: MultipleSPAOptions): Plugin {
},
resolveId(id) {
const pathname = id.split('/').at(-1)
const pathname = id.split('/').slice(-1)[0]
if (pathname?.startsWith('virtual:')) {
return pathname.replace('virtual:', '')
}