Skip to content

Commit

Permalink
Merge branch 'develop' into patch-4
Browse files Browse the repository at this point in the history
  • Loading branch information
nihal467 authored Oct 10, 2024
2 parents 96bfec5 + ca2c92a commit 9817d04
Show file tree
Hide file tree
Showing 5 changed files with 990 additions and 986 deletions.
78 changes: 37 additions & 41 deletions src/Components/Form/Form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ type Props<T extends FormDetails> = {
className?: string;
defaults: T;
asyncGetDefaults?: (() => Promise<T>) | false;
onlyChild?: boolean;
validate?: (form: T) => FormErrors<T>;
onSubmit: (form: T) => Promise<FormErrors<T> | void>;
onCancel?: () => void;
Expand All @@ -23,6 +22,7 @@ type Props<T extends FormDetails> = {
cancelLabel?: string;
onDraftRestore?: (newState: FormState<T>) => void;
children: (props: FormContextValue<T>) => React.ReactNode;
hideRestoreDraft?: boolean;
};

const Form = <T extends FormDetails>({
Expand Down Expand Up @@ -87,47 +87,43 @@ const Form = <T extends FormDetails>({
props.onDraftRestore?.(newState);
}}
formData={state.form}
/>
<Provider
value={(name: keyof T, validate?: FieldValidator<T[keyof T]>) => {
return {
name,
id: name,
onChange: ({ name, value }: FieldChangeEvent<T[keyof T]>) =>
dispatch({
type: "set_field",
name,
value,
error: validate?.(value),
}),
value: state.form[name],
error: state.errors[name],
disabled,
};
}}
hidden={props.hideRestoreDraft}
>
{props.onlyChild ? (
<Consumer>{props.children}</Consumer>
) : (
<>
<div className="my-6">
<Consumer>{props.children}</Consumer>
</div>
<div className="flex flex-col-reverse justify-end gap-3 sm:flex-row">
<Cancel
onClick={props.onCancel}
label={props.cancelLabel ?? "Cancel"}
/>
<Submit
data-testid="submit-button"
type="submit"
disabled={disabled}
label={props.submitLabel ?? "Submit"}
/>
</div>
</>
)}
</Provider>
<Provider
value={(name: keyof T, validate?: FieldValidator<T[keyof T]>) => {
return {
name,
id: name,
onChange: ({ name, value }: FieldChangeEvent<T[keyof T]>) =>
dispatch({
type: "set_field",
name,
value,
error: validate?.(value),
}),
value: state.form[name],
error: state.errors[name],
disabled,
};
}}
>
<div className="my-6">
<Consumer>{props.children}</Consumer>
</div>
<div className="flex flex-col-reverse justify-end gap-3 sm:flex-row">
<Cancel
onClick={props.onCancel}
label={props.cancelLabel ?? "Cancel"}
/>
<Submit
data-testid="submit-button"
type="submit"
disabled={disabled}
label={props.submitLabel ?? "Submit"}
/>
</div>
</Provider>
</DraftSection>
</form>
);
};
Expand Down
4 changes: 2 additions & 2 deletions src/Components/Patient/PatientHome.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -318,11 +318,11 @@ export const PatientHome = (props: any) => {
/>
<div>
<AlertTitle className="flex items-center">
{t("consultation_not_found")}
{t("consultation_not_filed")}
</AlertTitle>
<AlertDescription>
<span className="text-gray-700">
{t("consultation_not_found_description")}
{t("consultation_not_filed_description")}
</span>
</AlertDescription>
</div>
Expand Down
Loading

0 comments on commit 9817d04

Please sign in to comment.