• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

CBIIT / crdc-datahub-ui / 16006182009

01 Jul 2025 05:32PM UTC coverage: 62.703% (-8.6%) from 71.278%
16006182009

Pull #756

github

web-flow
Merge pull request #755 from CBIIT/revert-omb-date

revert: OMB expiration update
Pull Request #756: Sync 3.4.0 with 3.3.0

3560 of 6102 branches covered (58.34%)

Branch coverage included in aggregate %.

4920 of 7422 relevant lines covered (66.29%)

227.7 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

90.0
/src/hooks/useFormMode.ts
1
import { useEffect, useState } from "react";
2
import { Status as AuthStatus, useAuthContext } from "../components/Contexts/AuthContext";
3
import { Status as FormStatus, useFormContext } from "../components/Contexts/FormContext";
4
import { FormMode, FormModes, getFormMode, Logger } from "../utils";
5

6
const useFormMode = () => {
2✔
7
  const { user, status: authStatus } = useAuthContext();
138✔
8
  const { data, status } = useFormContext();
138✔
9
  const [formMode, setFormMode] = useState<FormMode>(undefined);
138✔
10
  const [readOnlyInputs, setReadOnlyInputs] = useState<boolean>(false);
138✔
11

12
  useEffect(() => {
138✔
13
    if (status === FormStatus.LOADING || authStatus === AuthStatus.LOADING) {
46!
14
      return;
×
15
    }
16

17
    const updatedFormMode: FormMode = getFormMode(user, data);
46✔
18
    if (updatedFormMode === FormModes.UNAUTHORIZED) {
46✔
19
      Logger.error("useFormMode: User is unauthorized to view this Submission Request.", {
30✔
20
        user,
21
        data,
22
      });
23
    }
24

25
    setFormMode(updatedFormMode);
46✔
26
    setReadOnlyInputs(updatedFormMode !== FormModes.EDIT);
46✔
27
  }, [user, data]);
28

29
  return { formMode, readOnlyInputs };
138✔
30
};
31

32
export default useFormMode;
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc