Skip to content

Commit

Permalink
Show arrival date in ambassador cards
Browse files Browse the repository at this point in the history
  • Loading branch information
MattIPv4 committed Jan 12, 2024
1 parent 9b9fe4c commit 3c7f0e0
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
9 changes: 9 additions & 0 deletions src/components/ambassadorCard/AmbassadorCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,15 @@ export default function AmbassadorCard(props: AmbassadorCardProps) {
<p>{ambassador.native.text}</p>
</div>

<div>
<h3>Arrived at Alveus</h3>
<p>
{ambassador.arrival
? formatDate(ambassador.arrival, false)
: "Unknown"}
</p>
</div>

<div className={styles.site}>
<p>
Learn more about {ambassador.name} on the{" "}
Expand Down
4 changes: 4 additions & 0 deletions src/components/ambassadorCard/ambassadorCard.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,10 @@
display: flex;
flex-wrap: wrap;
gap: 0.25rem 1.5rem;

> * {
margin-right: auto;
}
}

.info {
Expand Down
6 changes: 3 additions & 3 deletions src/utils/dateManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export function calculateAge(dateOfBirth: string): string {
* @param date date in the format YYYY-MM-DD or YYYY-MM or YYYY
* @returns a string of the date in the format Month DD, YYYY or Month YYYY or YYYY
*/
export function formatDate(date: string): string {
export function formatDate(date: string, approximate = true): string {
const dateArray = date.split("-");
let day = dateArray[2];
let month = dateArray[1];
Expand All @@ -60,9 +60,9 @@ export function formatDate(date: string): string {
}

if (day && month && year) return `${month} ${day}, ${year}`;
else if (month && year) return `~${month}, ${year}`;
else if (month && year) return `${approximate ? "~" : ""}${month}, ${year}`;

return `~${year}`;
return `${approximate ? "~" : ""}${year}`;
}

/**
Expand Down

0 comments on commit 3c7f0e0

Please sign in to comment.