implementiran share by link
This commit is contained in:
@@ -7,7 +7,7 @@ import { BillingLocation } from "../lib/db-types";
|
||||
import { formatYearMonth } from "../lib/format";
|
||||
import { formatCurrency } from "../lib/formatStrings";
|
||||
import Link from "next/link";
|
||||
import { useTranslations } from "next-intl";
|
||||
import { useLocale, useTranslations } from "next-intl";
|
||||
import { toast, useToast } from "react-toastify";
|
||||
|
||||
export interface LocationCardProps {
|
||||
@@ -17,13 +17,14 @@ export interface LocationCardProps {
|
||||
export const LocationCard:FC<LocationCardProps> = ({location: { _id, name, yearMonth, bills }}) => {
|
||||
|
||||
const t = useTranslations("home-page.location-card");
|
||||
const currentLocale = useLocale();
|
||||
|
||||
// sum all the billAmounts
|
||||
const monthlyExpense = bills.reduce((acc, bill) => bill.paid ? acc + (bill.payedAmount ?? 0) : acc, 0);
|
||||
|
||||
const handleCopyLinkClick = () => {
|
||||
// copy URL to clipboard
|
||||
const url = `${window.location.origin}/share/location/${_id}`;
|
||||
const url = `${window.location.origin}/${currentLocale}/share/location/${_id}`;
|
||||
navigator.clipboard.writeText(url);
|
||||
|
||||
// use NextJS toast to notiy user that the link was copied
|
||||
|
||||
Reference in New Issue
Block a user