react-icons/fi#FiBookOpen TypeScript Examples
The following examples show how to use
react-icons/fi#FiBookOpen.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: index.tsx From front-entenda-direito with GNU General Public License v3.0 | 5 votes |
Search: React.FC = () => {
const formRef = useRef<FormHandles>(null);
const { addToast, setDictionary, getDictionary } = useToast();
const handleSubmit = useCallback(
async (data: string) => {
try {
formRef.current?.setErrors({});
const schema = Yup.object().shape({
legalTerm: Yup.string().required('Campo obrigatório'),
});
await schema.validate(data, { abortEarly: false });
setDictionary();
} catch (err) {
if (err instanceof Yup.ValidationError) {
const errors = getValidationErrors(err);
formRef.current?.setErrors(errors);
return;
}
addToast({
type: 'error',
title: 'Erro no cadastro ?',
description: 'Ocorreu um erro ao fazer cadastro, tente novamente.',
});
}
},
[addToast, setDictionary],
);
return (
<>
<strong>Dicionário Jurídico</strong>
<FormStyled ref={formRef} onSubmit={handleSubmit}>
<Input
name="legalTerm"
icon={FiBookOpen}
maxLength={20}
placeholder="Digite: Carta"
/>
<p>
Digite o termo e clique no botão <FiSearch />.
</p>
<Button type="submit" style={{ width: 200 }}>
<FiSearch />
</Button>
</FormStyled>
<Section>{getDictionary() && <LegalTerm />}</Section>
</>
);
}
Example #2
Source File: index.tsx From front-entenda-direito with GNU General Public License v3.0 | 5 votes |
Search: React.FC = () => {
const formRef = useRef<FormHandles>(null);
const { addToast, getProcess, setProcess } = useToast();
const handleSubmit = useCallback(
async (data: SearchFormData) => {
try {
formRef.current?.setErrors({});
const schema = Yup.object().shape({
processNum: Yup.string()
.max(20, 'Nº de Processo tem no máximo 20 dígitos')
.required('Campo obrigatório'),
});
await schema.validate(data, { abortEarly: false });
addToast({
type: 'success',
title: 'Busca realizada! ⚖️',
});
setProcess();
} catch (err) {
if (err instanceof Yup.ValidationError) {
const errors = getValidationErrors(err);
formRef.current?.setErrors(errors);
return;
}
addToast({
type: 'error',
title: 'Erro no cadastro ?',
description: 'Ocorreu um erro ao fazer cadastro, tente novamente.',
});
}
},
[addToast, setProcess],
);
return (
<>
<strong>Pesquisa de Processos</strong>
<FormStyled ref={formRef} onSubmit={handleSubmit}>
<Input
name="processNum"
icon={FiBookOpen}
maxLength={20}
placeholder="Digite: 0000000-00.2020.0.00.0000"
/>
<p>
Digite o número do processo e clique no botão "Pesquisar".
</p>
<Button type="submit" style={{ width: 200 }}>
Pesquisar
</Button>
</FormStyled>
<Section>{getProcess() && <Process />}</Section>
</>
);
}