@@ -21,10 +21,8 @@ type SearchParamNames = keyof SearchQuery;
const GenerateProjectPotentialDelayReport: React.FC<Props> = ({ teams, clients, subsidiaries }) => {
const { t } = useTranslation("report");
const teamCombo = teams.map(team => ({
value: team.id,
label: `${team.code} - ${team.name}`,
}))
const teamCombo = teams.map(team => `${team.code} - ${team.name}`)
const clientCombo = clients.map(client => ({
value: `client: ${client.id}` ,
label: `${client.code} - ${client.name}`,
@@ -44,7 +42,7 @@ const GenerateProjectPotentialDelayReport: React.FC<Props> = ({ teams, clients,
const searchCriteria: Criterion<SearchParamNames>[] = useMemo(
() => [
{ label: t("Team"), paramName: "team", type: "autocomplete ", options: teamCombo },
{ label: t("Team"), paramName: "team", type: "select ", options: teamCombo },
{ label: t("Client"), paramName: "client", type: "autocomplete", options: [...subsidiaryCombo, ...clientCombo] },
{ label: t("Number Of Days"), paramName: "numberOfDays", type: "text", textType: "number", error: errors.numberOfDays, helperText: t("Can not be null and decimal, and should be >= 0") },
{ label: t("Project Completion (<= %)"), paramName: "projectCompletion", type: "text", textType: "number", error: errors.projectCompletion, helperText: t("Can not be null and decimal, and should be in range of 0 - 100") },
@@ -75,11 +73,12 @@ const GenerateProjectPotentialDelayReport: React.FC<Props> = ({ teams, clients,
if (hasError) return false
const teamIndex = teamCombo.findIndex(team => team === query.team)
const clientIndex = clientCombo.findIndex(client => client.value === query.client)
const subsidiaryIndex = subsidiaryCombo.findIndex(subsidiary => subsidiary.value === query.client)
const response = await fetchProjectPotentialDelayReport({
teamId: typeof query.team === "number" ? query.team : "All",
teamId: teamIndex >= 0 ? teams[teamIndex].id : "All",
clientId: clientIndex >= 0 ? clients[clientIndex].id : subsidiaryIndex >= 0 ? subsidiaries[subsidiaryIndex].id : "All",
numberOfDays: parseInt(query.numberOfDays),
projectCompletion: parseInt(query.projectCompletion),