Skip to content

Commit

Permalink
refactor: set molecular formula modal
Browse files Browse the repository at this point in the history
  • Loading branch information
hamed-musallam committed Mar 26, 2024
1 parent ed82531 commit c7bdaac
Show file tree
Hide file tree
Showing 5 changed files with 170 additions and 240 deletions.
82 changes: 0 additions & 82 deletions src/component/elements/MolecularFormulaInput.tsx

This file was deleted.

7 changes: 2 additions & 5 deletions src/component/elements/formik/FormikError.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { CSSProperties, ReactNode } from 'react';

const styles: Record<'container' | 'text', CSSProperties> = {
container: {
padding: '0.4rem',
display: 'flex',
flexDirection: 'column',
},
Expand All @@ -22,15 +21,13 @@ export interface FormikErrorProps {
}

function FormikError({ style, name, children }: FormikErrorProps) {
const { errors, isValid, dirty, touched } = useFormikContext();
const { errors, isValid, dirty } = useFormikContext();

const errorText = lodashGet(errors, name);
const isTouched = lodashGet(touched, name);

return (
<div style={{ ...styles.container, ...style?.container }}>
{children}
{!isValid && dirty && isTouched && (
{!isValid && dirty && (
<span style={{ ...styles.text, ...style?.text }}>{errorText}</span>
)}
</div>
Expand Down
3 changes: 2 additions & 1 deletion src/component/elements/formik/FormikInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function FormikInput(props: FormikInputProps & InputProps) {
...resProps
} = props;

const { values, handleChange, errors, touched, setFieldValue } =
const { values, handleChange, errors, touched, setFieldValue, handleBlur } =
useFormikContext();

function changeHandler(e) {
Expand All @@ -51,6 +51,7 @@ function FormikInput(props: FormikInputProps & InputProps) {
name={name}
value={val}
onChange={changeHandler}
onBlur={handleBlur}
type={type}
style={{
...style,
Expand Down
Loading

0 comments on commit c7bdaac

Please sign in to comment.