Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default toggles to true #1064

Merged
merged 8 commits into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions epictrack-web/src/components/project/ProjectForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import * as yup from "yup";
import { yupResolver } from "@hookform/resolvers/yup";
import { ETFormLabel } from "../shared/index";
import codeService, { Code } from "../../services/codeService";
import { Project } from "../../models/project";
import { Project, defaultProject } from "../../models/project";
import { Proponent } from "../../models/proponent";
import { Region } from "../../models/region";
import { Type } from "../../models/type";
Expand Down Expand Up @@ -66,7 +66,6 @@ export default function ProjectForm({ ...props }) {

React.useEffect(() => {
ctx.setFormId("project-form");
reset({ is_active: true });
}, []);

React.useEffect(() => {
Expand All @@ -90,7 +89,7 @@ export default function ProjectForm({ ...props }) {
const formValues = useWatch({ control });

React.useEffect(() => {
reset(ctx.item);
reset(ctx.item ?? defaultProject);
}, [ctx.item]);

React.useEffect(() => {
Expand Down
5 changes: 2 additions & 3 deletions epictrack-web/src/components/proponent/ProponentForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import * as yup from "yup";
import { yupResolver } from "@hookform/resolvers/yup";
import { ETFormLabel } from "../shared/index";
import { Staff } from "../../models/staff";
import { Proponent } from "../../models/proponent";
import { Proponent, defaultProponent } from "../../models/proponent";
import staffService from "../../services/staffService/staffService";
import ControlledSelectV2 from "../shared/controlledInputComponents/ControlledSelectV2";
import { MasterContext } from "../shared/MasterContext";
Expand Down Expand Up @@ -40,7 +40,6 @@ export default function ProponentForm({ ...props }) {

React.useEffect(() => {
ctx.setFormId("proponent-form");
reset({ is_active: true });
}, []);
React.useEffect(() => {
const name = (ctx?.item as Proponent)?.name;
Expand All @@ -65,7 +64,7 @@ export default function ProponentForm({ ...props }) {
} = methods;

React.useEffect(() => {
reset(ctx.item);
reset(ctx.item ?? defaultProponent);
}, [ctx.item]);

const getStaffs = async () => {
Expand Down
1 change: 1 addition & 0 deletions epictrack-web/src/components/shared/MasterContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ export const MasterProvider = ({
type: "success",
});
setItem(undefined);
setId(undefined);
setBackdrop(false);
callback();
}
Expand Down
4 changes: 4 additions & 0 deletions epictrack-web/src/models/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,7 @@ export interface Project {
fte_positions_construction: number;
fte_positions_operation: number;
}

export const defaultProject = {
is_active: true,
};
4 changes: 4 additions & 0 deletions epictrack-web/src/models/proponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,7 @@ export interface Proponent extends ListType, MasterBase {
relationship_holder_id?: number;
relationship_holder?: Staff;
}

export const defaultProponent = {
is_active: true,
};