Skip to content

Commit

Permalink
Chore: NPM Run Format in Frontend (#748)
Browse files Browse the repository at this point in the history
  • Loading branch information
erikataot authored Nov 16, 2023
1 parent 980a4ea commit 19b8055
Show file tree
Hide file tree
Showing 191 changed files with 3,868 additions and 3,147 deletions.
22 changes: 10 additions & 12 deletions frontend/src/common/apiManager/httpRequestHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ const getUserStorage = () => {
const getAccessToken = () => {
const parsedSessionObject = getDefaultRequiredVal(
{ token_type: "", access_token: "" },
getUserStorage()
getUserStorage(),
);
const tokenType = String(
getDefaultRequiredVal("", parsedSessionObject["token_type"])
getDefaultRequiredVal("", parsedSessionObject["token_type"]),
);
const accessToken = String(
getDefaultRequiredVal("", parsedSessionObject["access_token"])
getDefaultRequiredVal("", parsedSessionObject["access_token"]),
);
return tokenType.trim() !== "" && accessToken.trim() !== ""
? `${parsedSessionObject["token_type"]} ${parsedSessionObject["access_token"]}`
Expand Down Expand Up @@ -64,7 +64,7 @@ export const getCompanyIdFromSession = (): string | null => {
export const getUserGuidFromSession = (): string | null => {
const parsedSessionObject = getDefaultRequiredVal(
{ profile: { bceid_user_guid: "" } },
getUserStorage()
getUserStorage(),
);

return parsedSessionObject.profile?.bceid_user_guid ?? null;
Expand All @@ -77,11 +77,11 @@ export const getUserGuidFromSession = (): string | null => {
export const getCompanyNameFromSession = (): string | undefined => {
const parsedSessionObject = getDefaultRequiredVal(
{ profile: { bceid_business_name: "" } },
getUserStorage()
getUserStorage(),
);

return getDefaultNullableVal(
parsedSessionObject.profile?.bceid_business_name
parsedSessionObject.profile?.bceid_business_name,
);
};

Expand All @@ -93,7 +93,7 @@ export const getLoginUsernameFromSession = (): string => {
const parsedSessionObject = getUserStorage();
if (!parsedSessionObject) return "";
return getDefaultRequiredVal(
"",
"",
parsedSessionObject.profile?.bceid_username,
parsedSessionObject.profile?.idir_username,
);
Expand All @@ -106,12 +106,10 @@ export const getLoginUsernameFromSession = (): string => {
export const getCompanyEmailFromSession = (): string | undefined => {
const parsedSessionObject = getDefaultRequiredVal(
{ profile: { email: "" } },
getUserStorage()
getUserStorage(),
);

return getDefaultNullableVal(
parsedSessionObject.profile?.email
);
return getDefaultNullableVal(parsedSessionObject.profile?.email);
};

/**
Expand All @@ -135,7 +133,7 @@ export const httpGETRequest = (url: string) => {
export const httpGETRequestStream = (url: string) => {
return fetch(url, {
headers: {
"Authorization": getAccessToken(),
Authorization: getAccessToken(),
},
});
};
Expand Down
4 changes: 1 addition & 3 deletions frontend/src/common/authentication/LoginRedirect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,5 @@ export const LoginRedirect = () => {
return <Loading />;
}

return (
<></>
)
return <></>;
};
4 changes: 3 additions & 1 deletion frontend/src/common/authentication/OnRouteBCContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ export type OnRouteBCContextType = {
setCompanyLegalName?: Dispatch<SetStateAction<string | undefined>>;
companyLegalName?: string;
idirUserDetails?: IDIRUserDetailContext;
setIDIRUserDetails?: Dispatch<SetStateAction<IDIRUserDetailContext | undefined>>;
setIDIRUserDetails?: Dispatch<
SetStateAction<IDIRUserDetailContext | undefined>
>;
};

const defaultBehaviour: OnRouteBCContextType = {};
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/common/authentication/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import OnRouteBCContext from "./OnRouteBCContext";
*/
export const DoesUserHaveRole = (
userRoles: string[] | null | undefined,
requiredRole: string | undefined
requiredRole: string | undefined,
) => {
return (
requiredRole &&
Expand All @@ -34,7 +34,7 @@ export const DoesUserHaveRole = (
* @returns A boolean indicating if the user has the role to access a page or feature.
*/
export const DoesUserHaveRoleWithContext = (
requiredRole: string | undefined
requiredRole: string | undefined,
) => {
const { userRoles } = useContext(OnRouteBCContext);
return (
Expand Down
10 changes: 5 additions & 5 deletions frontend/src/common/components/banners/AlertBanners.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import {
faExclamationCircle,
faExclamationTriangle,
faInfoCircle,
faCheckCircle,
import {
faExclamationCircle,
faExclamationTriangle,
faInfoCircle,
faCheckCircle,
} from "@fortawesome/free-solid-svg-icons";

import "./AlertBanners.scss";
Expand Down
20 changes: 4 additions & 16 deletions frontend/src/common/components/banners/CompanyBanner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,30 +13,18 @@ export const CompanyBanner = ({
return (
<div className="company-banner">
<div className="company-banner__company-name">
<Typography
variant="h5"
data-testid="company-banner-name-label"
>
<Typography variant="h5" data-testid="company-banner-name-label">
COMPANY NAME
</Typography>
<Typography
variant="h4"
data-testid="company-banner-name"
>
<Typography variant="h4" data-testid="company-banner-name">
{getDefaultRequiredVal("", companyName)}
</Typography>
</div>
<div className="company-banner__client-number">
<Typography
variant="h5"
data-testid="company-banner-client-label"
>
<Typography variant="h5" data-testid="company-banner-client-label">
onRouteBC CLIENT NUMBER
</Typography>
<Typography
variant="h4"
data-testid="company-banner-client"
>
<Typography variant="h4" data-testid="company-banner-client">
{getDefaultRequiredVal("", clientNumber)}
</Typography>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@ export const PermitExpiryDateBanner = ({
<Box className="permit-expiry-date-banner">
<div>
<Typography variant="h5">PERMIT EXPIRY DATE</Typography>
<Typography
variant="h4"
data-testid="permit-expiry-date"
>
<Typography variant="h4" data-testid="permit-expiry-date">
{expiryDate}
</Typography>
</div>
Expand Down
50 changes: 23 additions & 27 deletions frontend/src/common/components/banners/UserInfoBanner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,28 @@ import { Box, Typography } from "@mui/material";
import { UserInformation } from "../../../features/manageProfile/types/manageProfile";
import { BC_COLOURS } from "../../../themes/bcGovStyles";

export const UserInfoBanner = memo(({
userInfo
}: {
userInfo?: UserInformation;
}) => {
return userInfo ? (
<Box
sx={{
height: 100,
backgroundColor: BC_COLOURS.banner_grey,
color: BC_COLOURS.bc_primary_blue,
marginTop: "20px",
px: 3,
display: "flex",
alignItems: "center",
justifyContent: "space-between",
}}
>
<div>
<Typography variant="h5">USER GROUP</Typography>
<Typography variant="h4">
{userInfo.userAuthGroup}
</Typography>
</div>
</Box>
) : null;
});
export const UserInfoBanner = memo(
({ userInfo }: { userInfo?: UserInformation }) => {
return userInfo ? (
<Box
sx={{
height: 100,
backgroundColor: BC_COLOURS.banner_grey,
color: BC_COLOURS.bc_primary_blue,
marginTop: "20px",
px: 3,
display: "flex",
alignItems: "center",
justifyContent: "space-between",
}}
>
<div>
<Typography variant="h5">USER GROUP</Typography>
<Typography variant="h4">{userInfo.userAuthGroup}</Typography>
</div>
</Box>
) : null;
},
);

UserInfoBanner.displayName = "UserInfoBanner";
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import { defaultCompanyInfo, renderTestComponent } from "./helpers/CompanyBanner/prepare";
import {
companyClientLabel,
companyClientNumber,
companyName,
import {
defaultCompanyInfo,
renderTestComponent,
} from "./helpers/CompanyBanner/prepare";
import {
companyClientLabel,
companyClientNumber,
companyName,
companyNameLabel,
} from "./helpers/CompanyBanner/access";

Expand All @@ -14,7 +17,9 @@ describe("CompanyBanner display", () => {
// Assert
expect(await companyNameLabel()).toHaveTextContent("COMPANY NAME");
expect(await companyName()).toHaveTextContent("");
expect(await companyClientLabel()).toHaveTextContent("onRouteBC CLIENT NUMBER");
expect(await companyClientLabel()).toHaveTextContent(
"onRouteBC CLIENT NUMBER",
);
expect(await companyClientNumber()).toHaveTextContent("");
});

Expand All @@ -26,7 +31,9 @@ describe("CompanyBanner display", () => {
const { legalName, clientNumber } = defaultCompanyInfo;
expect(await companyNameLabel()).toHaveTextContent("COMPANY NAME");
expect(await companyName()).toHaveTextContent(legalName);
expect(await companyClientLabel()).toHaveTextContent("onRouteBC CLIENT NUMBER");
expect(await companyClientLabel()).toHaveTextContent(
"onRouteBC CLIENT NUMBER",
);
expect(await companyClientNumber()).toHaveTextContent(clientNumber);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ export const renderTestComponent = (companyInfo?: CompanyProfile) => {
<CompanyBanner
companyName={companyInfo?.legalName}
clientNumber={companyInfo?.clientNumber}
/>
/>,
);
};
4 changes: 2 additions & 2 deletions frontend/src/common/components/breadcrumb/Breadcrumb.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const Breadcrumb = ({
return (
<Box className="breadcrumb">
{links.map((link, i) => {
const isCurrent = i === (links.length - 1);
const isCurrent = i === links.length - 1;
return isCurrent ? (
<Typography
key={link.text}
Expand All @@ -41,4 +41,4 @@ export const Breadcrumb = ({
})}
</Box>
);
};
};
6 changes: 1 addition & 5 deletions frontend/src/common/components/dashboard/Banner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,7 @@ export const Banner = ({
className={`layout-banner ${extendHeight ? "layout-banner--extend" : ""}`}
>
<Grid container>
<Grid
xs={12}
item
className="layout-banner__text-section"
>
<Grid xs={12} item className="layout-banner__text-section">
<h2>{bannerText}</h2>
<Box className="banner-button">
{bannerButton ? bannerButton : null}
Expand Down
17 changes: 5 additions & 12 deletions frontend/src/common/components/dashboard/TabLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,19 +70,12 @@ const DisplayTabs = ({
<Tab
key={label}
className="display-tab"
label={(
label={
<div className="tab">
<div className="tab__label">
{label}
</div>
{count ? (
<Chip
className="tab__count"
label={count}
/>
) : null}
<div className="tab__label">{label}</div>
{count ? <Chip className="tab__count" label={count} /> : null}
</div>
)}
}
{...TabProps(index)}
/>
);
Expand Down Expand Up @@ -156,7 +149,7 @@ export const TabLayout = React.memo(
<DisplayTabPanels value={value} componentList={componentList} />
</>
);
}
},
);

TabLayout.displayName = "TabLayout";
27 changes: 10 additions & 17 deletions frontend/src/common/components/dialog/DeleteConfirmationDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export const DeleteConfirmationDialog = ({
* A caption string showing on title of the Dialog box.
* @returns string
*/
caption: string
caption: string;
}) => {
const title = caption;

Expand All @@ -49,41 +49,34 @@ export const DeleteConfirmationDialog = ({
aria-labelledby="confirmation-dialog-title"
open={isOpen}
>
<DialogTitle
className="delete-confirmation-dialog__title"
>
<DialogTitle className="delete-confirmation-dialog__title">
<span className="delete-confirmation-dialog__icon">
<FontAwesomeIcon icon={faTrashCan} />
</span> &nbsp;
</span>{" "}
&nbsp;
<strong>Delete {title}(s)? </strong>
</DialogTitle>

<DialogContent
className="delete-confirmation-dialog__content"
dividers
>
<Typography
className="delete-confirmation-dialog__msg"
gutterBottom
>
<DialogContent className="delete-confirmation-dialog__content" dividers>
<Typography className="delete-confirmation-dialog__msg" gutterBottom>
Are you sure you want to delete this? This action cannot be undone.
</Typography>
</DialogContent>

<DialogActions className="delete-confirmation-dialog__actions">
<Button
className="delete-confirmation-btn delete-confirmation-btn--cancel"
variant="contained"
color="secondary"
variant="contained"
color="secondary"
onClick={onClickCancel}
>
Cancel
</Button>

<Button
className="delete-confirmation-btn delete-confirmation-btn--delete"
variant="contained"
color="error"
variant="contained"
color="error"
onClick={onClickDelete}
>
Delete
Expand Down
Loading

0 comments on commit 19b8055

Please sign in to comment.