Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(settings): add battle notifier settings #162

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 49 additions & 1 deletion src/pages/settings/Notifications.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useStoreState, useStoreActions } from 'easy-peasy';
import Header from 'components/Header';
import { Row, Text } from 'components/Containers';
import styled from 'styled-components';
import { Grid } from '@material-ui/core';
import { Grid, Tooltip } from '@material-ui/core';
import { Paper } from 'components/Paper';
import Button from 'components/Buttons';
import queryString from 'query-string';
Expand Down Expand Up @@ -168,11 +168,59 @@ const Notifications = () => {
</>
)}
</Paper>
<Paper top padding width="auto">
<Header h2>Battle Notifier</Header>
{notifSettings?.DiscordId ? (
<Text t="Medium">
To manage your battle notifications, go to Discord Elma Online and
write <CopyToClipboard text="!bn" /> in any channel.
</Text>
) : (
<Text t="Medium">
You can get notifications as PMs from the @ElmaOnline Discord bot
when a battle is started.
<ol>
<li>Join Discord Elma Online.</li>
<li>
In this page, click{' '}
<Button little naked onClick={() => authDiscord()}>
Log in to discord
</Button>{' '}
to connect your Discord account.
</li>
<li>
Finally, go back to Discord Elma Online and write{' '}
<CopyToClipboard text="!bn" /> in any channel.
<br /> You will get a PM from the bot with the instructions to
get started.
</li>
</ol>
</Text>
)}
</Paper>
</Grid>
</Grid>
);
};

const CopyToClipboard = ({ text }) => {
const [copied, setCopied] = React.useState(false);
const copy = () => {
navigator.clipboard.writeText(text);
setCopied(true);
setTimeout(() => setCopied(false), 2000);
};
return (
<Tooltip title="Copy to clipboard" placement="top" arrow>
<span>
<Button little naked onClick={copy}>
{copied ? 'Copied!' : text}
</Button>
</span>
</Tooltip>
);
};

const Avatar = styled.img`
height: 80px;
width: 80px;
Expand Down