Add document unsubscribe link in email footer (#5762)
This commit is contained in:
31
app/hooks/useQueryNotices.ts
Normal file
31
app/hooks/useQueryNotices.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
import * as React from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { QueryNotices } from "@shared/types";
|
||||
import useQuery from "./useQuery";
|
||||
import useToasts from "./useToasts";
|
||||
|
||||
/**
|
||||
* 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 { showToast } = useToasts();
|
||||
const notice = query.get("notice") as QueryNotices;
|
||||
|
||||
React.useEffect(() => {
|
||||
switch (notice) {
|
||||
case QueryNotices.UnsubscribeDocument: {
|
||||
showToast(
|
||||
t("Unsubscribed from document", {
|
||||
type: "success",
|
||||
})
|
||||
);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
}
|
||||
}, [t, showToast, notice]);
|
||||
}
|
||||
Reference in New Issue
Block a user