-
Notifications
You must be signed in to change notification settings - Fork 649
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into encounter-info-card
- Loading branch information
Showing
31 changed files
with
941 additions
and
528 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import { t } from "i18next"; | ||
|
||
import { cn } from "@/lib/utils"; | ||
|
||
import { | ||
Table, | ||
TableBody, | ||
TableCell, | ||
TableHead, | ||
TableHeader, | ||
TableRow, | ||
} from "@/components/ui/table"; | ||
|
||
type HeaderRow = { | ||
key: string; | ||
width?: number; | ||
}; | ||
|
||
type TableRowType = Record<string, string | undefined>; | ||
interface GenericTableProps { | ||
headers: HeaderRow[]; | ||
rows: TableRowType[] | undefined; | ||
} | ||
|
||
export default function PrintTable({ headers, rows }: GenericTableProps) { | ||
return ( | ||
<div className="overflow-hidden rounded-lg border border-gray"> | ||
<Table className="w-full"> | ||
<TableHeader> | ||
<TableRow className="bg-transparent hover:bg-transparent divide-x divide-gray border-b-gray"> | ||
{headers.map(({ key, width }, index) => ( | ||
<TableHead | ||
className={cn( | ||
index == 0 && "first:rounded-l-md", | ||
"h-auto py-1 pl-2 pr-2 text-black text-center ", | ||
width && `w-${width}`, | ||
)} | ||
key={key} | ||
> | ||
{t(key)} | ||
</TableHead> | ||
))} | ||
</TableRow> | ||
</TableHeader> | ||
<TableBody> | ||
{!!rows && | ||
rows.map((row, index) => ( | ||
<TableRow | ||
key={index} | ||
className="bg-transparent hover:bg-transparent divide-x divide-gray" | ||
> | ||
{headers.map(({ key }) => ( | ||
<TableCell | ||
className="break-words whitespace-normal text-center" | ||
key={key} | ||
> | ||
{row[key] || "-"} | ||
</TableCell> | ||
))} | ||
</TableRow> | ||
))} | ||
</TableBody> | ||
</Table> | ||
</div> | ||
); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { SquareArrowOutUpRight } from "lucide-react"; | ||
import { Link } from "raviger"; | ||
import { useTranslation } from "react-i18next"; | ||
|
||
import { getMapUrl, isAndroidDevice } from "@/Utils/utils"; | ||
|
||
const isValidLatitude = (latitude: string) => { | ||
const lat = parseFloat(latitude.trim()); | ||
return Number.isFinite(lat) && lat >= -90 && lat <= 90; | ||
}; | ||
|
||
const isValidLongitude = (longitude: string) => { | ||
const long = parseFloat(longitude.trim()); | ||
return Number.isFinite(long) && long >= -180 && long <= 180; | ||
}; | ||
|
||
export const FacilityMapsLink = ({ | ||
latitude, | ||
longitude, | ||
}: { | ||
latitude: string; | ||
longitude: string; | ||
}) => { | ||
const { t } = useTranslation(); | ||
|
||
if (!isValidLatitude(latitude) || !isValidLongitude(longitude)) { | ||
return null; | ||
} | ||
const target = isAndroidDevice ? "_self" : "_blank"; | ||
|
||
return ( | ||
<Link | ||
className="text-primary flex items-center gap-1 w-max" | ||
href={getMapUrl(latitude, longitude)} | ||
target={target} | ||
rel="noreferrer" | ||
> | ||
{t("show_on_map")} | ||
<SquareArrowOutUpRight className="h-3 w-3" /> | ||
</Link> | ||
); | ||
}; |
Oops, something went wrong.