mirror of
https://github.com/roleypoly/roleypoly.git
synced 2025-06-14 16:49:10 +00:00
chore: remove PreauthSecretCode
Signed-off-by: Katalina Okano <git@kat.cafe>
This commit is contained in:
parent
91c27f6b9a
commit
d11e29d4f5
5 changed files with 0 additions and 103 deletions
|
@ -1,37 +0,0 @@
|
|||
jest.unmock('roleypoly/design-system/atoms/text-input');
|
||||
jest.unmock('./PreauthSecretCode');
|
||||
|
||||
import { shallow } from 'enzyme';
|
||||
import * as React from 'react';
|
||||
import { Button } from 'roleypoly/design-system/atoms/button';
|
||||
import { FaderOpacity } from 'roleypoly/design-system/atoms/fader';
|
||||
import { TextInputWithIcon } from 'roleypoly/design-system/atoms/text-input';
|
||||
import { PreauthSecretCode } from './PreauthSecretCode';
|
||||
|
||||
const value = 'unfathomable fishy sticks';
|
||||
const onSubmit = jest.fn();
|
||||
|
||||
it('sends the secret code when submitted', () => {
|
||||
const view = shallow(<PreauthSecretCode onSubmit={onSubmit} />);
|
||||
|
||||
view.find(TextInputWithIcon).simulate('change', { target: { value } });
|
||||
|
||||
view.find(Button).simulate('click');
|
||||
expect(onSubmit).toBeCalledWith(value);
|
||||
});
|
||||
|
||||
it('shows the submit button when secret code is not empty', () => {
|
||||
const view = shallow(<PreauthSecretCode onSubmit={onSubmit} />);
|
||||
|
||||
view.find(TextInputWithIcon).simulate('change', { target: { value } });
|
||||
|
||||
expect(view.find(FaderOpacity).props().isVisible).toBe(true);
|
||||
});
|
||||
|
||||
it('hides the submit button when secret code is empty', () => {
|
||||
const view = shallow(<PreauthSecretCode onSubmit={onSubmit} />);
|
||||
|
||||
view.find(TextInputWithIcon).simulate('change', { target: { value: '' } });
|
||||
|
||||
expect(view.find(FaderOpacity).props().isVisible).toBe(false);
|
||||
});
|
|
@ -1,9 +0,0 @@
|
|||
import * as React from 'react';
|
||||
import { PreauthSecretCode } from './PreauthSecretCode';
|
||||
|
||||
export default {
|
||||
title: 'Molecules/Preauth/Secret Code',
|
||||
component: PreauthSecretCode,
|
||||
};
|
||||
|
||||
export const SecretCode = (args) => <PreauthSecretCode {...args} />;
|
|
@ -1,46 +0,0 @@
|
|||
import * as React from 'react';
|
||||
import { FiKey } from 'react-icons/fi';
|
||||
import { Button } from 'roleypoly/design-system/atoms/button';
|
||||
import { FaderOpacity } from 'roleypoly/design-system/atoms/fader';
|
||||
import { Space } from 'roleypoly/design-system/atoms/space';
|
||||
import { TextInputWithIcon } from 'roleypoly/design-system/atoms/text-input';
|
||||
|
||||
type PreauthProps = {
|
||||
onSubmit: (code: string) => void;
|
||||
};
|
||||
|
||||
export const PreauthSecretCode = (props: PreauthProps) => {
|
||||
const [secretCode, setSecretCode] = React.useState('');
|
||||
|
||||
const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
|
||||
setSecretCode(event.target.value);
|
||||
};
|
||||
|
||||
const handleKeyPress = (event: React.KeyboardEvent<HTMLInputElement>) => {
|
||||
if (event.key === 'Enter') {
|
||||
props.onSubmit(secretCode);
|
||||
}
|
||||
};
|
||||
|
||||
const handleSubmit = () => {
|
||||
props.onSubmit(secretCode);
|
||||
};
|
||||
|
||||
return (
|
||||
<div>
|
||||
<TextInputWithIcon
|
||||
icon={<FiKey />}
|
||||
value={secretCode}
|
||||
placeholder="Super secret code..."
|
||||
onChange={handleChange}
|
||||
onKeyDown={handleKeyPress}
|
||||
/>
|
||||
<Space />
|
||||
<FaderOpacity isVisible={secretCode.length > 0}>
|
||||
<Button color="muted" onClick={handleSubmit}>
|
||||
Submit Code →
|
||||
</Button>
|
||||
</FaderOpacity>
|
||||
</div>
|
||||
);
|
||||
};
|
|
@ -1 +0,0 @@
|
|||
export * from './PreauthSecretCode';
|
|
@ -3,9 +3,7 @@ import * as React from 'react';
|
|||
import { FaDiscord } from 'react-icons/fa';
|
||||
import { GuildSlug } from 'roleypoly/common/types';
|
||||
import { Button } from 'roleypoly/design-system/atoms/button';
|
||||
import { Space } from 'roleypoly/design-system/atoms/space';
|
||||
import { PreauthGreeting } from 'roleypoly/design-system/molecules/preauth-greeting';
|
||||
import { PreauthSecretCode } from 'roleypoly/design-system/molecules/preauth-secret-code';
|
||||
import styled from 'styled-components';
|
||||
|
||||
export type PreauthProps = {
|
||||
|
@ -48,14 +46,6 @@ export const Preauth = (props: PreauthProps) => {
|
|||
</Button>
|
||||
</Link>
|
||||
</WidthContainer>
|
||||
<Space />
|
||||
<WidthContainer>
|
||||
<p>
|
||||
Or, send a message saying "login" to{' '}
|
||||
<b>{props.botName || 'roleypoly'}</b>
|
||||
</p>
|
||||
<PreauthSecretCode onSubmit={props.onSendSecretCode} />
|
||||
</WidthContainer>
|
||||
</Centered>
|
||||
);
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue