-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
12 changed files
with
385 additions
and
67 deletions.
There are no files selected for viewing
90 changes: 90 additions & 0 deletions
90
frontend/src/components/search/SearchResultListItemStatus.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
import clsx from "clsx"; | ||
import { formatDate } from "src/utils/dateUtil"; | ||
|
||
interface StatusItemProps { | ||
description: string; | ||
showDate?: boolean; | ||
date?: string | null; | ||
tag?: boolean; | ||
orange?: boolean; | ||
} | ||
|
||
const StatusItem = ({ | ||
description, | ||
date = null, | ||
orange = false, | ||
showDate = true, | ||
tag = false, | ||
}: StatusItemProps) => { | ||
return ( | ||
<span | ||
className=" | ||
tablet:padding-x-1 | ||
tablet:margin-left-neg-1 | ||
tablet:margin-right-1 | ||
tablet:border-base-lighter" | ||
> | ||
<span | ||
className={clsx("display-flex", { | ||
"usa-tag margin-right-2 tablet:margin-0": tag, | ||
"bg-accent-warm-dark": orange, | ||
})} | ||
> | ||
<strong>{description}</strong> | ||
{showDate && ( | ||
<span className="text-no-uppercase"> | ||
{date ? formatDate(date) : "--"} | ||
</span> | ||
)} | ||
</span> | ||
</span> | ||
); | ||
}; | ||
|
||
interface SearchResultListItemStatusProps { | ||
status: string | null; | ||
archivedString: string; | ||
closedString: string; | ||
forecastedString: string; | ||
postedString: string; | ||
archiveDate: string | null; | ||
closedDate: string | null; | ||
} | ||
|
||
const SearchResultListItemStatus = ({ | ||
status, | ||
archiveDate, | ||
closedDate, | ||
archivedString, | ||
closedString, | ||
forecastedString, | ||
postedString, | ||
}: SearchResultListItemStatusProps) => { | ||
return ( | ||
<> | ||
{status === "archived" && ( | ||
<StatusItem date={archiveDate} description={archivedString} /> | ||
)} | ||
{(status === "archived" || status === "closed") && closedDate && ( | ||
<StatusItem description={closedString} date={closedDate} /> | ||
)} | ||
{status === "posted" && ( | ||
<StatusItem | ||
description={postedString} | ||
date={closedDate} | ||
orange={true} | ||
tag={true} | ||
/> | ||
)} | ||
{status === "forecasted" && ( | ||
<StatusItem | ||
description={forecastedString} | ||
showDate={false} | ||
tag={true} | ||
/> | ||
)} | ||
</> | ||
); | ||
}; | ||
|
||
export default SearchResultListItemStatus; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.