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

PIMS-1951 Remove pimshelp Email #2597

Merged
merged 2 commits into from
Aug 2, 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
4 changes: 2 additions & 2 deletions .env-template
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ CSS_API_CLIENT_SECRET= # Keycloak CSS API Service Account client_secret
# BC Geocoder
GEOCODER_KEY=

# Error Report
ERROR_REPORT_TO=
# Contact
CONTACT_EMAIL=

# CHES Settings
CHES_USERNAME=
Expand Down
2 changes: 1 addition & 1 deletion express-api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Recommended values used with this API that match with the current API and Docker
|SSO_INTEGRATION_ID|1234|See Keycloak integration. Used for CSS API.|
|SSO_ENVIRONMENT|dev|Target environment of Keycloak integration. Used for CSS API.|
|GEOCODER_KEY|abc123|API key for BC Geocoder use.|
|ERROR_REPORT_TO|<[email protected]>|Destination email for frontend error reporting.|
|CONTACT_EMAIL|<[email protected]>|Destination email for frontend error reporting and help.|
|CHES_USERNAME|abc123|Username for CHES service.|
|CHES_PASSWORD|def456|Password for CHES service.|
|CHES_AUTH_URL|https://...|URL where authorization tokens for CHES are obtained.|
Expand Down
4 changes: 2 additions & 2 deletions express-api/src/constants/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ const config = {
notificationTemplate: 15,
notificationTemplateRPD: 17,
},
errorReport: {
toEmail: process.env.ERROR_REPORT_TO,
contact: {
toEmail: process.env.CONTACT_EMAIL,
},
notificationTemplate: {
title: 'PIMS',
Expand Down
5 changes: 5 additions & 0 deletions express-api/src/controllers/lookup/lookupController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import { Role } from '@/typeorm/Entities/Role';
import { Agency } from '@/typeorm/Entities/Agency';
import { AdministrativeArea } from '@/typeorm/Entities/AdministrativeArea';
import { Workflow } from '@/typeorm/Entities/Workflow';
import getConfig from '@/constants/config';

/**
* @description Get all property classification entries.
Expand Down Expand Up @@ -233,6 +234,7 @@ export const lookupTimestampTypes = async (req: Request, res: Response) => {
* @returns {Response} A 200 status and a list entries.
*/
export const lookupAll = async (req: Request, res: Response) => {
const cfg = getConfig();
const Risks = await AppDataSource.getRepository(ProjectRisk).find({
select: {
Id: true,
Expand Down Expand Up @@ -407,6 +409,9 @@ export const lookupAll = async (req: Request, res: Response) => {
a.Name.toLowerCase().localeCompare(b.Name.toLowerCase()),
),
Workflows,
Config: {
contactEmail: cfg.contact.toEmail,
},
};
return res.status(200).send(returnObj);
};
2 changes: 1 addition & 1 deletion express-api/src/controllers/reports/reportsController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export const submitErrorReport = async (req: Request, res: Response) => {
});
const config = getConfig();
const email: IEmail = {
to: [config.errorReport.toEmail],
to: [config.contact.toEmail],
cc: [req.user.email],
from: '[email protected]', // Made up for this purpose.
bodyType: EmailBody.Html,
Expand Down
64 changes: 40 additions & 24 deletions react-app/src/constants/jsxSnippets.tsx
Original file line number Diff line number Diff line change
@@ -1,32 +1,48 @@
import React from 'react';
import { LookupContext } from '@/contexts/lookupContext';
import React, { useContext } from 'react';

export const accessPendingBlurb = (
<>
We have received your request. We will notify you via email when your request has been reviewed.
If you haven&apos;t heard from us within five business days, please feel free to reach out to us
at <a href="mailto: [email protected]">[email protected]</a>.
</>
);
export const accessPendingBlurb = () => {
const lookup = useContext(LookupContext);

export const accountInactiveBlurb = (
<>
This account is currently inactive and cannot access PIMS. If you believe this is an error or
require the account to be reactivated, please feel free to reach out to us at{' '}
<a href="mailto: [email protected]">[email protected]</a>.
</>
);
return (
<>
We have received your request. We will notify you via email when your request has been
reviewed. If you haven&apos;t heard from us within five business days, please feel free to
reach out to us at{' '}
<a href={`mailto: ${lookup.data.Config.contactEmail}`}>{lookup.data.Config.contactEmail}</a>.
</>
);
};

export const accountInactiveBlurb = () => {
const lookup = useContext(LookupContext);

return (
<>
This account is currently inactive and cannot access PIMS. If you believe this is an error or
require the account to be reactivated, please feel free to reach out to us at{' '}
<a href={`mailto: ${lookup.data.Config.contactEmail}`}>{lookup.data.Config.contactEmail}</a>.
</>
);
};

export const signupTermsAndConditionsClaim = (
<>
By signing up, you agree to the <a href="#">Terms and Conditions</a> and confirm that you have
read the <a href="#">Privacy Policy</a>.
By signing up, you agree to the{' '}
<a href="https://www2.gov.bc.ca/gov/content/home/disclaimer">Terms and Conditions</a> and
confirm that you have read the{' '}
<a href="https://www2.gov.bc.ca/gov/content/home/privacy">Privacy Policy</a>.
</>
);

export const awaitingRoleBlurb = (
<>
This account is currently active but has not been assigned a role. If you believe this is an
error or require assistance, please feel free to reach out to us at{' '}
<a href="mailto: [email protected]">[email protected]</a>.
</>
);
export const awaitingRoleBlurb = () => {
const lookup = useContext(LookupContext);

return (
<>
This account is currently active but has not been assigned a role. If you believe this is an
error or require assistance, please feel free to reach out to us at{' '}
<a href={`mailto: ${lookup.data.Config.contactEmail}`}>{lookup.data.Config.contactEmail}</a>.
</>
);
};
10 changes: 6 additions & 4 deletions react-app/src/contexts/lookupContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,12 @@ export const LookupContextProvider: React.FC<React.PropsWithChildren> = (props)
const ret = {};
if (data) {
for (const k of Object.keys(data)) {
ret[k] = (data[k] as Record<string, any>[]).reduce(
(acc, curr) => ({ ...acc, [curr.Id]: curr }),
{},
);
if (Array.isArray(data[k])) {
ret[k] = (data[k] as Record<string, any>[]).reduce(
(acc, curr) => ({ ...acc, [curr.Id]: curr }),
{},
);
}
}
return ret;
} else {
Expand Down
3 changes: 3 additions & 0 deletions react-app/src/hooks/api/useLookupApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ export interface LookupAll {
AdministrativeAreas: Partial<AdministrativeArea>[];
RegionalDistricts: Partial<RegionalDistrict>[];
Workflows: Partial<Workflow>[];
Config: {
contactEmail: string;
};
}

const useLookupApi = (absoluteFetch: IFetch) => {
Expand Down
10 changes: 6 additions & 4 deletions react-app/src/pages/AccessRequest.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { Navigate } from 'react-router-dom';
import TextFormField from '@/components/form/TextFormField';
import { useGroupedAgenciesApi } from '@/hooks/api/useGroupedAgenciesApi';
import { SnackBarContext } from '@/contexts/snackbarContext';
import { LookupContext } from '@/contexts/lookupContext';

interface StatusPageTemplateProps {
blurb: JSX.Element;
Expand Down Expand Up @@ -114,14 +115,15 @@ export const AccessRequest = () => {
const api = usePimsApi();
const auth = useContext(AuthContext);
const snackbar = useContext(SnackBarContext);
const lookup = useContext(LookupContext);

const onSubmit = (data: AccessRequestType) => {
api.users.submitAccessRequest(data).then((response) => {
if (response.status === 201) {
auth.pimsUser.refreshData();
} else {
snackbar.setMessageState({
text: 'Could not create account. Contact [email protected] for assistance.',
text: `Could not create account. Contact ${lookup.data.Config.contactEmail} for assistance.`,
open: true,
style: snackbar.styles.warning,
});
Expand All @@ -144,7 +146,7 @@ export const AccessRequest = () => {
<Typography mb={'2rem'} variant="h2">
Awaiting Role
</Typography>
<StatusPageTemplate blurb={awaitingRoleBlurb} />
<StatusPageTemplate blurb={awaitingRoleBlurb()} />
</>
);
}
Expand All @@ -155,7 +157,7 @@ export const AccessRequest = () => {
<Typography mb={'2rem'} variant="h2">
Access Pending
</Typography>
<StatusPageTemplate blurb={accessPendingBlurb} />
<StatusPageTemplate blurb={accessPendingBlurb()} />
</>
);
case 'Disabled':
Expand All @@ -165,7 +167,7 @@ export const AccessRequest = () => {
<Typography mb={'2rem'} variant="h2">
Account Inactive
</Typography>
<StatusPageTemplate blurb={accountInactiveBlurb} />
<StatusPageTemplate blurb={accountInactiveBlurb()} />
</>
);
default:
Expand Down
Loading