Skip to content

Commit

Permalink
Merge pull request #80 from skorphil/72-error-ui-state-if-fetching-error
Browse files Browse the repository at this point in the history
fixed bug not receiving initial values
  • Loading branch information
skorphil authored Mar 12, 2024
2 parents bd0964d + 0a057a8 commit 7db4240
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion components/InstitutionsList/InstitutionsList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function InstitutionsList({
variant="grid"
padding={isInstitutionOpen || 2}
>
<TabPanels flexGrow={1} flexShrink={1} minH="200px">
<TabPanels flexGrow={1} flexShrink={1} h="200px">
{institutions.map((institution, index) => (
<TabPanel p={0} key={institution.id} h="100%">
<InstitutionContainer
Expand Down
6 changes: 4 additions & 2 deletions components/RecordForm/RecordForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Root element of the form
import { useForm, FormProvider, useFieldArray } from "react-hook-form";
import classes from "./RecordForm.module.css";
import { Button, Progress, useToast } from "@chakra-ui/react";
import { useState } from "react";
import { useState, useEffect } from "react";

import { InstitutionsList } from "components/InstitutionsList";
import { FormHeader } from "~/FormHeader";
Expand All @@ -22,13 +22,15 @@ export function RecordForm() {
const [isInstitutionOpen, setIsInstitutionOpen] = useState(false);
const [selectedInstitutionIndex, setSelectedInstitutionIndex] = useState(0);
const [errorState, setErrorState] = useState(false);

const router = useRouter();
const arrayName = "institutions";

const { control, ...form } = useForm({
defaultValues: async () => {
try {
await getLatestRecord();
const initialValues = await getLatestRecord();
return initialValues;
} catch (error) {
setErrorState(error.stack);
}
Expand Down

0 comments on commit 7db4240

Please sign in to comment.