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: add PAT & account sharing setting #1907

Merged
merged 10 commits into from
Nov 1, 2023
Merged
Show file tree
Hide file tree
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
98 changes: 98 additions & 0 deletions src/components/Settings/SharingSettings.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
/* eslint-disable jsx-a11y/interactive-supports-focus */

/* eslint-disable jsx-a11y/click-events-have-key-events */
import { useState } from 'react';
import { useSelector } from 'react-redux';

import {
Button,
TextField,
Paper,
Grid,
CircularProgress,
Typography,
} from '@material-ui/core';

import { useStyles } from './Settings.styles';

import i18n from 'src/locale';
import { RootState } from 'src/reducers';

const SharingSetting = () => {
const styles = useStyles();
const loading = useSelector<RootState>(
({ configState: { loading } }) => loading,
);
const [tokenValue, setToken] = useState('');
const [error, setError] = useState({
isError: false,
message: '',
});

const onChangeToken = (event: React.ChangeEvent<HTMLInputElement>) => {
const input = event.target.value;

if (!input.length) {
setError({ isError: false, message: '' });
}
setToken(event.target.value);
};

const onClickAddToken = () => {
setToken('');
};

if (loading)
return (
<Grid container justifyContent="center">
<CircularProgress />
</Grid>
);

return (
<Paper elevation={0} className={styles.root}>
<Typography className={styles.subtitle}>Input Code Here</Typography>
<div
className={styles.option}
style={{
display: 'flex',
justifyContent: 'space-between',
alignItems: 'center',
}}>
<>
<TextField
variant="outlined"
fullWidth
label={i18n.t('Setting.List_Menu.Token_Code')}
placeholder={i18n.t('Setting.List_Menu.Token_Code')}
value={tokenValue}
style={{ marginBottom: 'unset' }}
onChange={onChangeToken}
error={error.isError}
helperText={error.isError ? error.message : ''}
/>
<Button
size="small"
variant="contained"
color="primary"
style={{ marginLeft: '24px', marginRight: '17px' }}
onClick={onClickAddToken}>
Add
</Button>
</>
</div>
<div>
<Button
size="medium"
variant="contained"
color="primary"
style={{ marginLeft: '24px', marginRight: '17px', marginTop: '15px' }}
onClick={onClickAddToken}>
Generate Token
</Button>
</div>
</Paper>
);
};

export default SharingSetting;
8 changes: 8 additions & 0 deletions src/components/Settings/hooks/use-setting-list.hook.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { AccountSettingsContainer } from '../AccountSettingsContainer';
import EmailSettings from '../EmailSettings';
import { LanguageSettingsContainer } from '../LanguageSettingsContainer';
import { NotificationSettingsContainer } from '../NotificationSettings.container';
import SharingSetting from '../SharingSettings';
import { BlockListContainer } from '../render/BlockList';
import { HelpComponent } from '../render/Help';

Expand All @@ -20,6 +21,7 @@ export type SettingsType =
| 'account'
| 'notification'
| 'email'
| 'sharing'
| 'block'
| 'language'
| 'about'
Expand Down Expand Up @@ -90,6 +92,12 @@ export const useSettingList = (): SettingsOption<SettingsType>[] => {
subtitle: i18n.t('Setting.List_Menu.Notification_Subtitle'),
component: <NotificationSettingsContainer />,
},
{
id: 'sharing',
title: i18n.t('Setting.List_Menu.Sharing_Title'),
subtitle: i18n.t('Setting.List_Menu.Sharing_Subtitle'),
component: <SharingSetting />,
},
{
id: 'block',
title: i18n.t('Setting.List_Menu.Blocked_Title'),
Expand Down
5 changes: 4 additions & 1 deletion src/locale/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1016,6 +1016,8 @@
},
"Notification_Title": "Notification Settings",
"Notification_Subtitle": "Manage your notification",
"Sharing_Title": "Account Sharing Setting",
"Sharing_Subtitle": "TBA",
"Notification_Setting": {
"Comments": "Comments",
"Mention": "Mention",
Expand Down Expand Up @@ -1051,7 +1053,8 @@
"Email_Title": "Email Configuration",
"Email_Subtitle": "Set email address for another method of login",
"Email_Address": "Email Address",
"Email_Placeholder": "Add Email Address"
"Email_Placeholder": "Add Email Address",
"Token_Code": "Add Token Code"
}
},
"SocialMedia": {
Expand Down
5 changes: 4 additions & 1 deletion src/locale/fra.json
Original file line number Diff line number Diff line change
Expand Up @@ -1016,6 +1016,8 @@
},
"Notification_Title": "Paramètres de notification",
"Notification_Subtitle": "Gérer votre notification",
"Sharing_Title": "Account Sharing Setting",
"Sharing_Subtitle": "TBA",
"Notification_Setting": {
"Comments": "Commentaires",
"Mention": "Mention",
Expand Down Expand Up @@ -1047,7 +1049,8 @@
"About_Subtitle": "En savoir plus sur Myriad",
"Feedback_Title": "Soumettre des commentaires",
"Feedback_Subtitle": "N'hésitez pas à nous faire part de vos commentaires en nous envoyant un e-mail.",
"Version_Title": "Version Myriad"
"Version_Title": "Version Myriad",
"Token_Code": "Add Token Code"
}
},
"SocialMedia": {
Expand Down
5 changes: 4 additions & 1 deletion src/locale/id.json
Original file line number Diff line number Diff line change
Expand Up @@ -1011,6 +1011,8 @@
},
"Notification_Title": "Notifikasi",
"Notification_Subtitle": "Pengaturan notifikasi",
"Sharing_Title": "Account Sharing Setting",
"Sharing_Subtitle": "TBA",
"Notification_Setting": {
"Comments": "Komentar",
"Mention": "Sebutan",
Expand Down Expand Up @@ -1046,7 +1048,8 @@
"Email_Title": "Pengaturan Email",
"Email_Subtitle": "Atur alamat email sebagai metode lain untuk login",
"Email_Address": "Alamat Email",
"Email_Placeholder": "Tambah Alamat Email"
"Email_Placeholder": "Tambah Alamat Email",
"Token_Code": "Add Token Code"
}
},
"SocialMedia": {
Expand Down
5 changes: 4 additions & 1 deletion src/locale/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -998,6 +998,8 @@
},
"Notification_Title": "Настройка уведомлений",
"Notification_Subtitle": "Управление уведомлениями",
"Sharing_Title": "Account Sharing Setting",
"Sharing_Subtitle": "TBA",
"Notification_Setting": {
"Comments": "Комментарии",
"Mention": "Упоминания",
Expand Down Expand Up @@ -1033,7 +1035,8 @@
"Email_Title": "Email Configuration",
"Email_Subtitle": "Set email address for another method of login",
"Email_Address": "Email Address",
"Email_Placeholder": "Add Email Address"
"Email_Placeholder": "Add Email Address",
"Token_Code": "Add Token Code"
}
},
"SocialMedia": {
Expand Down
Loading