Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const Auth = props => {
const [status, setStatus] = useState(null)
const [loading, setLoading] = useState(false)
const login = useMutation(LOGIN)
const { enqueueSnackbar } = useSnackbar()
const client = useApolloClient()
const handleLogin = async () => {
setLoading(true)
try {
const urlParams = new URLSearchParams(window.location.search)
const code = urlParams.get('code')
const state = urlParams.get('state')
const { data, errors } = await login({ variables: { code, state } })
if (errors) {
console.error('[Error logging in]', errors)
enqueueSnackbar('Error logging in', { variant: 'error' })
setStatus(false)
}
if (data && data.login && data.login.token) {
const jwt = data.login.token
enqueueSnackbar(`Welcome to Together`)
const SettingsMenu = ({ classes }) => {
const client = useApolloClient()
const [anchorEl, setAnchorEl] = useState(null)
const [localState, setLocalState] = useLocalState()
const { user } = useUser()
const channel = useCurrentChannel()
const logout = e => {
window.localStorage.removeItem('token')
client.resetStore()
window.location.href = '/'
}
return (
{user && user.photo ? (
export const Menu: React.FunctionComponent = props => {
const classes = useStyles();
const themeContext = React.useContext(ThemeContext);
const client = useApolloClient();
const {
anchorEl,
onClose,
history: { push },
match
} = props;
return (
onClose()}
const LoginPage: React.FunctionComponent = props => {
const classes = useStyles();
const [username, setUsername] = React.useState('');
const [password, setPassword] = React.useState('');
const [errorText, setErrorText] = React.useState('');
const [loading, loadingAction] = useToggle(false);
const login = LoginMutation.useMutation();
const client = useApolloClient();
const onSubmit = React.useCallback(async () => {
setErrorText('');
loadingAction.toggleOn();
if (!username && !password) return;
try {
const variables: LoginMutation.Variables = { password };
if (username && username.includes('@')) {
variables.email = username;
} else {
variables.username = username;
}
const response = await login({ variables });
loadingAction.toggleOff();
function EditCmsLayout({ match, history }) {
const { data, error } = useQuerySuspended(CmsLayoutsAdminQuery);
const initialLayout = error
? null
: data.cmsLayouts.find((p) => match.params.id === p.id.toString());
const [layout, dispatch] = useReducer(layoutReducer, initialLayout);
const [updateMutate] = useMutation(UpdateLayout);
const [updateLayout, updateError, updateInProgress] = useAsyncFunction(updateMutate);
const apolloClient = useApolloClient();
usePageTitle(useValueUnless(() => `Editing “${initialLayout.name}”`, error));
if (error) {
return ;
}
const formSubmitted = async (event) => {
event.preventDefault();
await updateLayout({
variables: {
id: initialLayout.id,
cmsLayout: buildLayoutInput(layout),
},
});
await apolloClient.resetStore();