Skip to content

Commit

Permalink
description auto populating in work (bcgov#1550)
Browse files Browse the repository at this point in the history
  • Loading branch information
dinesh-aot authored Jan 5, 2024
1 parent 4a8b0d4 commit 4e12943
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
1 change: 0 additions & 1 deletion epictrack-web/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import { Loader } from "./components/shared/loader";

export function App() {
const dispatch = useAppDispatch();
UserService.initKeycloak(dispatch);
const isLoggedIn = useAppSelector(
(state) => state.user?.authentication.authenticated
);
Expand Down
15 changes: 12 additions & 3 deletions epictrack-web/src/components/work/WorkForm/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { EPDSpecialField } from "./EPDSpecialField";
import icons from "../../icons";
import { WorkLeadSpecialField } from "./WorkLeadSpecialField";
import { MIN_WORK_START_DATE } from "../../../constants/application-constant";
import { Project } from "../../../models/project";

const schema = yup.object<Work>().shape({
ea_act_id: yup.number().required("EA Act is required"),
Expand Down Expand Up @@ -165,6 +166,13 @@ export default function WorkForm({ ...props }) {
}
};

const getProject = async (id: string) => {
const projectResult = await projectService.getById(id);
if (projectResult.status === 200) {
return projectResult.data as Project;
}
};

React.useEffect(() => {
const promises: any[] = [];
Object.keys(codeTypes).forEach(async (key) => {
Expand Down Expand Up @@ -194,8 +202,9 @@ export default function WorkForm({ ...props }) {
const selectedProject: any = projects.filter((project) => {
return project.id.toString() === id;
});
setSelectedProject(selectedProject[0]);
setValue("epic_description", selectedProject[0]?.description);
const project = await getProject(selectedProject[0].id);
setSelectedProject(project);
setValue("epic_description", String(project?.description));
};

const handleWorktypeChange = async (id: string) => {
Expand Down Expand Up @@ -335,7 +344,7 @@ export default function WorkForm({ ...props }) {
fullWidth
multiline
rows={4}
disabled={isSpecialFieldLocked}
disabled
/>
</Grid>
<Grid item xs={12}>
Expand Down
2 changes: 1 addition & 1 deletion epictrack-web/src/services/userService/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const KeycloakData: Keycloak = new Keycloak({
url: `${AppConfig.keycloak.url}/auth`,
});
const doLogout = KeycloakData.logout;
let refreshInterval: NodeJS.Timer;
let refreshInterval: NodeJS.Timeout;
/**
* Logout function
*/
Expand Down

0 comments on commit 4e12943

Please sign in to comment.