♻️ Switch to turborepo (#532)

This commit is contained in:
Luke Vella 2023-03-01 14:10:06 +00:00 committed by GitHub
parent 41ef81aa75
commit 0a836aeec7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
419 changed files with 2300 additions and 2504 deletions

View file

@ -0,0 +1,75 @@
import { Trans, useTranslation } from "next-i18next";
import * as React from "react";
import { Button } from "@/components/button";
import Bell from "@/components/icons/bell.svg";
import BellCrossed from "@/components/icons/bell-crossed.svg";
import { usePoll } from "../poll-context";
import Tooltip from "../tooltip";
import { useUpdatePollMutation } from "./mutations";
const NotificationsToggle: React.FunctionComponent = () => {
const { poll, urlId } = usePoll();
const { t } = useTranslation("app");
const [isUpdatingNotifications, setIsUpdatingNotifications] =
React.useState(false);
const { mutate: updatePollMutation } = useUpdatePollMutation();
return (
<Tooltip
content={
poll.verified ? (
poll.notifications ? (
<div>
<div className="text-primary-300 font-medium">
{t("notificationsOn")}
</div>
<div className="max-w-sm">
<Trans
t={t}
i18nKey="notificationsOnDescription"
values={{
email: poll.user.email,
}}
components={{
b: (
<span className="text-primary-300 whitespace-nowrap font-mono font-medium " />
),
}}
/>
</div>
</div>
) : (
t("notificationsOff")
)
) : (
t("notificationsVerifyEmail")
)
}
>
<Button
loading={isUpdatingNotifications}
icon={poll.verified && poll.notifications ? <Bell /> : <BellCrossed />}
disabled={!poll.verified}
onClick={() => {
setIsUpdatingNotifications(true);
updatePollMutation(
{
urlId,
notifications: !poll.notifications,
},
{
onSuccess: () => {
setIsUpdatingNotifications(false);
},
},
);
}}
/>
</Tooltip>
);
};
export default NotificationsToggle;