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

CBIIT / crdc-datahub-ui / 18789341118

24 Oct 2025 06:57PM UTC coverage: 78.178% (+15.5%) from 62.703%
18789341118

push

github

web-flow
Merge pull request #888 from CBIIT/3.4.0

3.4.0 Release

4977 of 5488 branches covered (90.69%)

Branch coverage included in aggregate %.

8210 of 9264 new or added lines in 257 files covered. (88.62%)

6307 existing lines in 120 files now uncovered.

30203 of 39512 relevant lines covered (76.44%)

213.36 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";
1✔
2

3
import { Status as AuthStatus, useAuthContext } from "../components/Contexts/AuthContext";
1✔
4
import { Status as FormStatus, useFormContext } from "../components/Contexts/FormContext";
1✔
5
import { FormMode, FormModes, getFormMode, Logger } from "../utils";
1✔
6

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

13
  useEffect(() => {
156✔
14
    if (status === FormStatus.LOADING || authStatus === AuthStatus.LOADING) {
52!
15
      return;
×
UNCOV
16
    }
×
17

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

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

30
  return { formMode, readOnlyInputs };
156✔
31
};
156✔
32

33
export default useFormMode;
1✔
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