Skip to content

Commit

Permalink
migrate to strict
Browse files Browse the repository at this point in the history
  • Loading branch information
Cloud11PL committed Apr 23, 2024
1 parent ec7c35f commit 9652a06
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
11 changes: 5 additions & 6 deletions src/components/Timeline/TimelineNote.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// @ts-strict-ignore
import { GiftCardEventFragment, OrderEventFragment } from "@dashboard/graphql";
import { getUserInitials, getUserName } from "@dashboard/misc";
import { Card, CardContent, Typography } from "@material-ui/core";
Expand Down Expand Up @@ -55,12 +54,12 @@ interface TimelineNoteProps {
}

interface NoteMessageProps {
message: string;
message: string | null;
}

const NoteMessage: React.FC<NoteMessageProps> = ({ message }) => (
<>
{message.split("\n").map(string => {
{message?.split("\n").map(string => {
if (string === "") {
return <br key={`break-${string}`} />;
}
Expand Down Expand Up @@ -92,8 +91,8 @@ const TimelineAvatar = ({
if (app) {
return (
<UserAvatar
initials={app.name.slice(0, 2)}
url={app?.brand?.logo?.default}
initials={app.name?.slice(0, 2)}
url={app.brand?.logo?.default}
className={className}
/>
);
Expand All @@ -111,7 +110,7 @@ export const TimelineNote: React.FC<TimelineNoteProps> = ({
}) => {
const classes = useStyles();

const userDisplayName = getUserName(user, true) ?? app.name;
const userDisplayName = getUserName(user, true) ?? app?.name;

return (
<div className={classes.root}>
Expand Down
5 changes: 4 additions & 1 deletion src/misc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,10 @@ interface User {
lastName?: string;
}

export function getUserName(user?: User, returnEmail?: boolean) {
export function getUserName(
user: User | null | undefined,
returnEmail?: boolean,
) {
return user && (user.email || (user.firstName && user.lastName))
? user.firstName && user.lastName
? [user.firstName, user.lastName].join(" ")
Expand Down

0 comments on commit 9652a06

Please sign in to comment.