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

sprint17 #31

Merged
merged 5 commits into from
Jun 18, 2024
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
56 changes: 56 additions & 0 deletions src/api/emailTemplates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,62 @@ const emailTemplates = {
<a href="${_spPageContextInfo.webAbsoluteUrl}/app/index.aspx#/Request/${request.requestId}">${_spPageContextInfo.webAbsoluteUrl}/app/index.aspx#/Request/${request.requestId}</a>`,
};
break;

case "SelectionPackageCSFApproval":
email = {
To: allRoles.flatMap((role) => {
GregoryForrest marked this conversation as resolved.
Show resolved Hide resolved
if (role.Title === "CSF") {
return role.user.EMail;
}
return [];
}),
CC: [requestData.supervisor.EMail],
Subject: `CSF Action: An incentive package for RPA ${requestData.positionTitle} is ready for CSF review/approval.`,
Body: `This email is to inform you that an incentive package Request for Personnel Action (RPA) ${requestData.positionTitle} is pending CSF approval.

To action this request, follow the below link:
<a href="${_spPageContextInfo.webAbsoluteUrl}/app/index.aspx#/Request/${request.requestId}">${_spPageContextInfo.webAbsoluteUrl}/app/index.aspx#/Request/${request.requestId}</a>`,
};
break;

case "SelectionPackageHQApproval":
email = {
To: allRoles.flatMap((role) => {
if (role.Title === "HQ") {
return role.user.EMail;
}
return [];
}),
CC: [requestData.supervisor.EMail],
Subject: `HQ Action: An incentive package for RPA ${requestData.positionTitle} is ready for HQ review/approval.`,
Body: `This email is to inform you that an incentive package Request for Personnel Action (RPA) ${requestData.positionTitle} is pending HQ approval.

To action this request, follow the below link:
<a href="${_spPageContextInfo.webAbsoluteUrl}/app/index.aspx#/Request/${request.requestId}">${_spPageContextInfo.webAbsoluteUrl}/app/index.aspx#/Request/${request.requestId}</a>`,
};
break;

case "SelectionPackageCAApproval":
email = {
To: [
requestData.hrl?.EMail ||
OSFs.find((osf) => osf.Title === requestData.osf)
?.defaultHRLEmail ||
"",
],
CC: allRoles.flatMap((role) => {
if (role.Title === "COS HR Supervisor") {
return role.user.EMail;
}
return [];
}).concat([requestData.supervisor.EMail]),
Subject: `CA Action: An incentive package for RPA ${requestData.positionTitle} is ready for CA review/approval.`,
Body: `This email is to inform you that an incentive package Request for Personnel Action (RPA) ${requestData.positionTitle} is pending CA approval.

To action this request, follow the below link:
<a href="${_spPageContextInfo.webAbsoluteUrl}/app/index.aspx#/Request/${request.requestId}">${_spPageContextInfo.webAbsoluteUrl}/app/index.aspx#/Request/${request.requestId}</a>`,
};
break;
}
break;

Expand Down
16 changes: 11 additions & 5 deletions src/api/requestsApi.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,8 @@ export const usePagedRequests = (
page = 0,
sortParams = defaultSortParams,
filterParams: RequestFilter[],
allOpen = false
allOpen = false,
allItems = false
) => {
const queryClient = useQueryClient();
const myRoles = useMyRoles();
Expand All @@ -156,6 +157,7 @@ export const usePagedRequests = (
filterParams,
page,
allOpen,
allItems,
myRoles.roles,
],
enabled: OSFs.isFetched, // wait until OSFs are fetched
Expand All @@ -170,6 +172,7 @@ export const usePagedRequests = (
filterParams,
page - 1,
allOpen,
allItems,
myRoles.roles,
]) || [];

Expand All @@ -181,6 +184,7 @@ export const usePagedRequests = (
sortParams,
filterParams,
allOpen,
allItems,
myRoles,
OSFs.data || []
);
Expand Down Expand Up @@ -227,6 +231,7 @@ const getPagedRequests = async (
sortParams: SortParams,
filterParams: RequestFilter[],
allOpen: boolean,
allItems: boolean,
myRoles: MYROLES,
OSFs: OSF[]
) => {
Expand All @@ -235,13 +240,14 @@ const getPagedRequests = async (
"Author/Id,Author/EMail,Author/Title";
const expandedFields = "Author";

let queryString =
"ContentType eq 'RPADocSet' and stage ne 'Complete'" +
" and stage ne 'Cancelled'";
let queryString = "ContentType eq 'RPADocSet'";
if (!allItems) {
queryString += " and stage ne 'Complete' and stage ne 'Cancelled'";
}

// if not showing all open requests, filter for those items relevant to current user
// current user may have multiple roles!
if (!allOpen) {
if (!allOpen && !allItems) {
// if current user is a CSF or COSF, they may see all post-draft requests
// no other filters need be added
if (myRoles.isCSF || myRoles.isCOSF) {
Expand Down
10 changes: 3 additions & 7 deletions src/components/RequestsTable/RequestsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,8 @@ const RequestsTable = () => {
page,
sortState,
filterState,
checkedValues.filterOptions.includes("openItems")
checkedValues.filterOptions.includes("openItems"),
checkedValues.filterOptions.includes("allItems")
);
const refMap = useRef<Record<string, HTMLElement | null>>({});
const [columnSizingOptions, setColumnSizingOptions] =
Expand Down Expand Up @@ -261,12 +262,7 @@ const RequestsTable = () => {
>
Open Items
</ToolbarRadioButton>
<ToolbarRadioButton
as="button"
name="filterOptions"
value="allItems"
disabled
>
<ToolbarRadioButton as="button" name="filterOptions" value="allItems">
All Items
</ToolbarRadioButton>
</ToolbarRadioGroup>
Expand Down
18 changes: 13 additions & 5 deletions src/components/ViewRequest/HiringPanel.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Label, Switch, Text } from "@fluentui/react-components";
import { useAddNote } from "api/notesApi";
import { usePostRequest } from "api/postRequestApi";
import { useRequest } from "api/requestsApi";
import { STAGES } from "consts/Stages";
Expand All @@ -7,17 +8,24 @@ import { useParams } from "react-router-dom";

const HiringPanel = () => {
const params = useParams();
const request = useRequest(Number(params.requestId));
const postRequest = usePostRequest();
const requestId = Number(params.requestId);
const request = useRequest(requestId);
const { mutate: postRequestMutate, isLoading: postRequestIsLoading } =
usePostRequest();
const { mutate: addNoteMutate, isLoading: addNoteIsLoading } =
useAddNote(requestId);

const onChange = useCallback(
(ev: ChangeEvent<HTMLInputElement>) => {
postRequest.mutate({
postRequestMutate({
requestId: Number(params.requestId),
postRequest: { panelRequired: ev.currentTarget.checked ? "Yes" : "No" },
});
addNoteMutate(
`Set 'Panel Required' to ${ev.currentTarget.checked ? "Yes" : "No"}`
);
},
[params.requestId]
[postRequestMutate, addNoteMutate, params.requestId]
);

const selectionStageIndex = STAGES.findIndex(
Expand Down Expand Up @@ -55,7 +63,7 @@ const HiringPanel = () => {
id="panelRequired"
checked={request.data?.panelRequired === "Yes" ? true : false}
onChange={onChange}
disabled={postRequest.isLoading}
disabled={postRequestIsLoading || addNoteIsLoading}
/>
{request.data?.panelRequired === "Yes" && (
<Text weight="bold" style={{ color: "red" }}>
Expand Down
43 changes: 19 additions & 24 deletions src/components/ViewRequest/StatusBar.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
import { useRequest } from "api/requestsApi";
import { useParams } from "react-router-dom";
import { STAGES } from "consts/Stages";
import {
Popover,
PopoverSurface,
PopoverTrigger,
Title2,
Title3,
} from "@fluentui/react-components";
import { Title2, Title3 } from "@fluentui/react-components";

const StatusBar = () => {
const params = useParams();
Expand All @@ -33,8 +27,8 @@ const StatusBar = () => {
<Title3>Current Stage: {currentStage}</Title3>
<ul className="request-status">
{STAGES.map((stage, index) => (
<Popover withArrow openOnHover>
<PopoverTrigger>
<>
{stage.showStage(request.data) && (
<li
key={stage.key}
className={
Expand All @@ -45,11 +39,8 @@ const StatusBar = () => {
>
<div>{stage.text}</div>
</li>
</PopoverTrigger>
<PopoverSurface tabIndex={-1}>
<>Some text</>
</PopoverSurface>
</Popover>
)}
</>
))}
</ul>
{subStageIndex !== undefined &&
Expand All @@ -58,16 +49,20 @@ const StatusBar = () => {
<hr />
<ul className="request-status">
{STAGES[stageIndex].subStages?.map((stage, index) => (
<li
key={stage.key}
className={
(index < subStageIndex ? "completed-stage" : "") ||
(index === subStageIndex ? "active-stage" : "") ||
(index > subStageIndex ? "inactive-stage" : "")
}
>
<div>{stage.text}</div>
</li>
<>
{stage.showStage(request.data) && (
<li
key={stage.key}
className={
(index < subStageIndex ? "completed-stage" : "") ||
(index === subStageIndex ? "active-stage" : "") ||
(index > subStageIndex ? "inactive-stage" : "")
}
>
<div>{stage.text}</div>
</li>
)}
</>
))}
</ul>
</>
Expand Down
Loading