Files
outline/app/hooks/useQueryNotices.ts
T
Tom Moor a48f6c7a85 fix: Unsubscribe link for collection subscriptions (#8734)
* fix: Cannot unsubscribe from collection subscriptions via email token

* tests

* Separate redirect for pass through

* Delete both subscriptions

* Test draft documents
2025-03-22 08:22:20 -07:00

39 lines
1012 B
TypeScript

import * as React from "react";
import { useTranslation } from "react-i18next";
import { toast } from "sonner";
import { QueryNotices } from "@shared/types";
import useQuery from "./useQuery";
/**
* Display a toast message based on a notice in the query string. This is usually
* used when redirecting from an external source to the client, such as OAuth,
* or emails.
*/
export default function useQueryNotices() {
const query = useQuery();
const { t } = useTranslation();
const notice = query.get("notice") as QueryNotices;
React.useEffect(() => {
switch (notice) {
case QueryNotices.UnsubscribeDocument: {
toast.success(
t("Unsubscribed from document", {
type: "success",
})
);
break;
}
case QueryNotices.UnsubscribeCollection: {
toast.success(
t("Unsubscribed from collection", {
type: "success",
})
);
break;
}
default:
}
}, [t, notice]);
}