Skip to content

Commit

Permalink
Handle undefined value
Browse files Browse the repository at this point in the history
  • Loading branch information
yuanchen233 committed Sep 12, 2024
1 parent ab78333 commit 31ac0d2
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/pages/Deployments/DeploymentCard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ const DeploymentCard = ({
() =>
deployment.participants
.map((participant) =>
participant.firstName !== null
participant.firstName
? `${participant.firstName} ${participant.lastName}`
: "",
)
Expand Down
2 changes: 1 addition & 1 deletion src/pages/Deployments/ParticipantRecord/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ const ParticipantRecord = ({

const lastDataUpload = useMemo(() => {
const lastData = participantData.dateOfLastDataUpload;
if (lastData === null || lastData === undefined) {
if (!lastData) {
return "";
}
const elapsedDays = calculateDaysPassedFromDate(
Expand Down
8 changes: 3 additions & 5 deletions src/pages/Participant/Deployment/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ const Deployment = () => {

const lastDataUpload = (lastData: Date
) => {
if (lastData === null || lastData === undefined) {
if (!lastData) {
return "";
}
if (
Expand Down Expand Up @@ -126,11 +126,9 @@ const Deployment = () => {
const getParticipantInitials = (participant: ParticipantData) => {
if (
participant.firstName === "" ||
participant.firstName === null ||
participant.firstName === undefined ||
participant.lastName === "" ||
participant.lastName === null ||
participant.lastName === undefined
!participant.firstName ||
!participant.lastName
) {
return participant.role ? participant.role[0] : "?";
}
Expand Down

0 comments on commit 31ac0d2

Please sign in to comment.