Started working on the assignment complete engine
This commit is contained in:
parent
39b15af5b0
commit
408a5b6457
@ -1,12 +1,50 @@
|
||||
import React, { useCallback, useEffect, useState } from "react";
|
||||
import { useParams } from "react-router-dom";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { toast } from "react-toastify";
|
||||
import { Namespaces } from "../../../../i18n/i18n";
|
||||
import Loading from "../../../../components/common/Loading";
|
||||
import assignmentCompleteService, {
|
||||
GetAssignmentForCompletion,
|
||||
} from "./services/assignmentCompleteService";
|
||||
|
||||
const AssignmentComplete: React.FC = () => {
|
||||
const { assignmentId } = useParams<{ assignmentId: string }>();
|
||||
const { t } = useTranslation(Namespaces.Common);
|
||||
const [loaded, setLoaded] = useState(false);
|
||||
const [assignment, setAssignment] =
|
||||
useState<GetAssignmentForCompletion | null>(null);
|
||||
|
||||
return <>Complete Assignment goes here.</>;
|
||||
const loadAssignment = useCallback(async () => {
|
||||
if (assignmentId === undefined) {
|
||||
setLoaded(true);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const assignmentDetails =
|
||||
await assignmentCompleteService.getAssignmentForCompletion(
|
||||
BigInt(assignmentId),
|
||||
);
|
||||
if (assignmentDetails) {
|
||||
setAssignment(assignmentDetails);
|
||||
}
|
||||
setLoaded(true);
|
||||
} catch (ex: any) {
|
||||
toast.error(ex.message);
|
||||
setLoaded(true);
|
||||
}
|
||||
}, [assignmentId]);
|
||||
|
||||
useEffect(() => {
|
||||
void loadAssignment();
|
||||
}, [loadAssignment]);
|
||||
|
||||
return (
|
||||
<Loading loaded={loaded}>
|
||||
{assignment ? <>{assignment.taskName}</> : <>{t("CompleteAssignment")}</>}
|
||||
</Loading>
|
||||
);
|
||||
};
|
||||
|
||||
export default AssignmentComplete;
|
||||
|
||||
@ -0,0 +1,36 @@
|
||||
import httpService from "../../../../../services/httpService";
|
||||
import {
|
||||
GeneralIdRef,
|
||||
MakeGeneralIdRefParams,
|
||||
} from "../../../../../utils/GeneralIdRef";
|
||||
|
||||
const apiEndpoint = "/Tasks";
|
||||
|
||||
export interface GetAssignmentForCompletion {
|
||||
id: bigint;
|
||||
guid: string;
|
||||
taskType: string;
|
||||
taskName: string;
|
||||
activityId: GeneralIdRef;
|
||||
activityName: string;
|
||||
user?: GeneralIdRef;
|
||||
role?: GeneralIdRef;
|
||||
startDateTime?: Date;
|
||||
}
|
||||
|
||||
export async function getAssignmentForCompletion(
|
||||
assignmentId: bigint,
|
||||
): Promise<GetAssignmentForCompletion> {
|
||||
const params = MakeGeneralIdRefParams(assignmentId);
|
||||
|
||||
const response = await httpService.get<GetAssignmentForCompletion>(
|
||||
apiEndpoint + "/getAssignmentDetails?" + params,
|
||||
);
|
||||
return response?.data;
|
||||
}
|
||||
|
||||
const assignmentCompleteService = {
|
||||
getAssignmentForCompletion,
|
||||
};
|
||||
|
||||
export default assignmentCompleteService;
|
||||
Loading…
Reference in New Issue
Block a user