| 1 | "use client"; |
| 2 | |
| 3 | import { Bell, BellOff |
| 4 | import { useAction } |
| 5 | import { toast } |
| 6 | |
| 7 | import { Button } |
| 8 | import { Spinner } |
| 9 | |
| 10 | import { setThreadSubscription } |
| 11 | |
| 12 | export function SubscribeButton({ |
| 13 | username, |
| 14 | repo, |
| 15 | number, |
| 16 | subscribed, |
| 17 | }: { |
| 18 | username: string |
| 19 | repo: string |
| 20 | number: number |
| 21 | subscribed: boolean |
| 22 | }) { |
| 23 | const { execute, |
| 24 | onError: ({ error |
| 25 | toast.error(error |
| 26 | }); |
| 27 | const Icon = |
| 28 | |
| 29 | return ( |
| 30 | <Button |
| 31 | variant="outline" |
| 32 | size="sm" |
| 33 | disabled={isExecuting} |
| 34 | title={ |
| 35 | subscribed |
| 36 | ? "You are notified about activity here." |
| 37 | : "You are notified here only when mentioned or assigned." |
| 38 | } |
| 39 | onClick={() => |
| 40 | execute({ username, |
| 41 | } |
| 42 | > |
| 43 | {isExecuting ? <Spinner |
| 44 | {subscribed ? "Unsubscribe |
| 45 | </Button> |
| 46 | ); |
| 47 | } |