Skip to content

Commit

Permalink
chore(formErrorHeader): typescript typings
Browse files Browse the repository at this point in the history
  • Loading branch information
shindigira committed May 26, 2024
1 parent 4002027 commit 45d502c
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/components/FormErrorHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ import { Element, Link } from 'react-scroll';
import getAllProperties from 'utils/getAllProperties';
import type { FormErrorKeyType } from 'utils/getFormErrorKeyLogic';

interface FormErrorHeaderProperties<M extends FieldValues, T> {
interface FormErrorHeaderProperties<
M extends FieldValues,
T extends Record<string, string>,
> {
id: string;
keyLogicFunc: (key: string) => FormErrorKeyType;
errors?: FieldErrors<M>;
Expand All @@ -18,7 +21,10 @@ interface FormErrorHeaderProperties<M extends FieldValues, T> {
*
* @returns List of Schema Errors - for Step1Form
*/
function FormErrorHeader<M extends FieldValues, T = unknown>({
function FormErrorHeader<
M extends FieldValues,
T extends Record<string, string>,
>({
alertHeading,
errors,
id,
Expand Down Expand Up @@ -59,7 +65,9 @@ function FormErrorHeader<M extends FieldValues, T = unknown>({
};

const onHandleKeyPress = (
event: React.KeyboardEvent<HTMLButtonElement>,
event: React.KeyboardEvent<
HTMLAnchorElement | HTMLButtonElement
>,
): void => {
if (event.key === 'Enter' || event.key === ' ') {
focusKeyItem();
Expand All @@ -68,7 +76,7 @@ function FormErrorHeader<M extends FieldValues, T = unknown>({

const zodErrorMessage = (errors[keyField]?.message ??
errors[keyField]?.[keyIndex]?.[formFieldsHeaderErrorKey]
?.message) as FieldErrors<M>;
?.message) as string | undefined;

return (
<ListItem key={key}>
Expand Down

0 comments on commit 45d502c

Please sign in to comment.