feat:#16 added translation for button and toast

This commit is contained in:
Elmar Kresse
2024-11-06 14:11:50 +01:00
parent fd7f296a3a
commit 087c9550d9
3 changed files with 29 additions and 5 deletions

View File

@@ -23,6 +23,28 @@ import DynamicPage from "@/view/DynamicPage.vue";
import RoomOccupation from "@/components/RoomOccupation.vue";
import { computedAsync } from "@vueuse/core";
import { router } from "@/main";
import { useI18n } from "vue-i18n";
import { useToast } from "primevue/usetoast";
const { t } = useI18n({ useScope: "global" });
const toast = useToast();
const show = () => {
toast.add({
severity: "info",
summary: t("calendarLink.copyToastSummary"),
detail: t("calendarLink.copyToastNotification"),
life: 3000,
});
};
const failedClipboard = () => {
toast.add({
severity: "error",
summary: t("calendarLink.copyToastError"),
detail: t("calendarLink.copyToastErrorDetail"),
life: 3000,
});
};
type Room = {
name: string;
@@ -90,13 +112,13 @@ const getLink = (selectedRoom: string) =>
const button = computed(() => {
return {
label: "Copy iCal Link for" + selectedRoom.value.name,
icon: "pi pi-calendar",
label: t("roomFinderPage.roomIcal") + selectedRoom.value.name,
icon: "pi pi-clone",
disabled: selectedRoom.value.name === "",
onClick: () => {
// Copy iCal link to clipboard
// localhost/api/feed/room?id=selectedRoom.value.name
navigator.clipboard.writeText(getLink(selectedRoom.value.name));
navigator.clipboard.writeText(getLink(selectedRoom.value.name)).then(show, () => failedClipboard())
},
};
});