-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
Copy pathApiErrors.tsx
118 lines (113 loc) · 3.66 KB
/
ApiErrors.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
import * as React from "react"
import CodeArea from "./CodeArea"
import errorCode from "./codeExamples/errorCode"
import errorCodeTs from "./codeExamples/errorCodeTs"
import errorCodeTypes from "./codeExamples/ErrorCodeTypes"
import generic from "../data/generic"
import multipleErrorCode from "./codeExamples/multipleErrorCode"
import multipleErrorCodeTs from "./codeExamples/multipleErrorCodeTs"
import TabGroup from "./TabGroup"
import * as typographyStyles from "../styles/typography.module.css"
import * as tableStyles from "../styles/table.module.css"
export default React.memo(
({
api,
currentLanguage,
goToSection,
}: {
api: any
currentLanguage: string
goToSection: (name: string, animate?: boolean) => void
}) => {
return (
<>
<code className={typographyStyles.codeHeading}>
<h2>
errors:{" "}
<span
className={typographyStyles.typeText}
>{`Record<string, object>`}</span>
</h2>
</code>
{api.errors.description(currentLanguage)}
<div className={tableStyles.tableWrapper}>
<table className={tableStyles.table}>
<tbody>
<tr>
<th>{generic.name[currentLanguage]}</th>
<th
style={{
minWidth: 250,
}}
>
{generic.type[currentLanguage]}
</th>
<th>{generic.description[currentLanguage]}</th>
</tr>
<tr>
<td>
<code>type</code>
</td>
<td>
<span className={typographyStyles.typeText}>string</span>
</td>
<td>
Error {generic.type[currentLanguage]}. eg: required, min, max,
minLength
</td>
</tr>
<tr>
<td>
<code>types</code>
</td>
<td>
<span
className={typographyStyles.typeText}
>{`Record<{ string, string | boolean }>`}</span>
</td>
<td>{api.errors.types}</td>
</tr>
<tr>
<td>
<code>message</code>
</td>
<td>
<span className={typographyStyles.typeText}>
string | React.ReactElement
</span>
</td>
<td>{api.errors.message}</td>
</tr>
<tr>
<td>
<code>ref</code>
</td>
<td>
<span className={typographyStyles.typeText}>React.Ref</span>
</td>
<td>{api.errors.ref}</td>
</tr>
</tbody>
</table>
{api.errors.note(goToSection)}
</div>
<TabGroup buttonLabels={["First error detected", "Display all errors"]}>
<CodeArea
rawData={errorCode}
tsRawData={errorCodeTs}
rawTypes={errorCodeTypes}
url="https://codesandbox.io/s/react-hook-form-error-v6-rcpm8"
tsUrl="https://codesandbox.io/s/react-hook-form-error-ts-v6-500eo"
/>
<CodeArea
rawData={multipleErrorCode}
tsRawData={multipleErrorCodeTs}
url="https://codesandbox.io/s/react-hook-form-validatecriteriamode-v6-tixtl"
tsUrl="https://codesandbox.io/s/react-hook-form-validatecriteriamode-v6-ts-r51li"
/>
</TabGroup>
<hr />
</>
)
}
)