Skip to content

Commit

Permalink
prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
sdankel committed May 2, 2024
1 parent 26f83fa commit fb49a28
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 26 deletions.
3 changes: 1 addition & 2 deletions app/src/features/tokens/components/TokenCard.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React from 'react';
import { Button, Card, CardHeader, IconButton } from '@mui/material';
import ContentCopyIcon from '@mui/icons-material/ContentCopy';
import { Button } from '@mui/material';
import { Token } from '../hooks/useApiTokens';
import CopyableToken from './CopyableToken';

Expand Down
4 changes: 0 additions & 4 deletions app/src/features/tokens/hooks/useApiTokens.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
import { useCallback, useEffect, useState } from 'react';
import { useSearchParams } from 'react-router-dom';
import { SERVER_URI } from '../../../constants';
import { useGithubAuth } from '../../toolbar/hooks/useGithubAuth';
import axios from 'axios';
import HTTP, {
CreateTokenResponse,
RawToken,
TokensResponse,
} from '../../../utils/http';

export interface Token {
Expand Down
27 changes: 11 additions & 16 deletions app/src/features/toolbar/hooks/useGithubAuth.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
import { useCallback, useEffect, useState } from 'react';
import { useSearchParams } from 'react-router-dom';
import { useLocalSession } from '../../../utils/localStorage';
import { SERVER_URI } from '../../../constants';
import useCookie from 'react-use-cookie';
import axios from 'axios';
import HTTP, {
AuthenticatedUser,
LoginResponse,
UserResponse,
} from '../../../utils/http';
import HTTP, { AuthenticatedUser } from '../../../utils/http';

export function useGithubAuth(): [
AuthenticatedUser | null,
Expand All @@ -23,7 +17,7 @@ export function useGithubAuth(): [
await HTTP.post(`/logout`);
setSessionId('');
setGithubUser(null);
}, [setGithubUser]);
}, [setGithubUser, setSessionId]);

// If this was a redirect from Github, we have a code to log in with.
useEffect(() => {
Expand All @@ -41,16 +35,18 @@ export function useGithubAuth(): [
return;
}

HTTP.post(`/login`, { code: githubCode }).then(({ data }) => {
clearGithubCode();
if (data.user) {
setGithubUser(data.user);
}
}).catch(() => clearGithubCode());
HTTP.post(`/login`, { code: githubCode })
.then(({ data }) => {
clearGithubCode();
if (data.user) {
setGithubUser(data.user);
}
})
.catch(() => clearGithubCode());
}, [githubCode, setGithubUser, clearGithubCode]);

useEffect(() => {
// Attempt to fetch the logged in user info if the session cookie is set and the user hasn't been fetched.
// Attempt to fetch the logged in user info if the session cookie is set and the user hasn't been fetched.
if (!!githubUser || !sessionId) {
return;
}
Expand All @@ -62,4 +58,3 @@ export function useGithubAuth(): [

return [githubUser, logout];
}

6 changes: 3 additions & 3 deletions app/src/pages/ApiTokens.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useEffect } from 'react';
import { Token, useApiTokens } from '../features/tokens/hooks/useApiTokens';
import React from 'react';
import { useApiTokens } from '../features/tokens/hooks/useApiTokens';
import { useIsMobile } from '../features/toolbar/hooks/useIsMobile';
import { Button, TextField } from '@mui/material';
import TokenCard from '../features/tokens/components/TokenCard';
Expand Down Expand Up @@ -34,7 +34,7 @@ function ApiTokens() {
size='large'
style={{ float: 'right' }}
onClick={async () => {
let { token } = await createToken(tokenName);
await createToken(tokenName);
setTokenName('');
setShowTokenForm(false);
}}>
Expand Down
1 change: 0 additions & 1 deletion app/src/utils/localStorage.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { useLocalStorage } from "usehooks-ts";

const STORAGE_GH_CODE_KEY = 'gh_code';
const STORAGE_FP_SESSION_KEY = 'fp_session';

export function useLocalSession() {
function clear<T>(key: string, handleSave: (value: T | null) => void) {
Expand Down

0 comments on commit fb49a28

Please sign in to comment.