Skip to content

Commit

Permalink
feat: handled many issues about implementing hotsurf
Browse files Browse the repository at this point in the history
  • Loading branch information
yungblud committed Jan 31, 2024
1 parent 9a22ec2 commit 67446b2
Show file tree
Hide file tree
Showing 56 changed files with 483 additions and 826 deletions.
13 changes: 0 additions & 13 deletions packages/accounts-ui/.eslintrc

This file was deleted.

2 changes: 0 additions & 2 deletions packages/accounts-ui/.gitignore

This file was deleted.

6 changes: 0 additions & 6 deletions packages/accounts-ui/.prettierrc.json

This file was deleted.

53 changes: 0 additions & 53 deletions packages/accounts-ui/package.json

This file was deleted.

96 changes: 0 additions & 96 deletions packages/accounts-ui/src/LoginForm.tsx

This file was deleted.

30 changes: 0 additions & 30 deletions packages/accounts-ui/src/LoginFormLoader.tsx

This file was deleted.

2 changes: 0 additions & 2 deletions packages/accounts-ui/src/index.ts

This file was deleted.

3 changes: 0 additions & 3 deletions packages/accounts-ui/tsconfig.json

This file was deleted.

79 changes: 76 additions & 3 deletions packages/billets-admin-client/app/auth/signin/page.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,80 @@
'use client'

import LoginForm from '../../../ui/LoginForm'
import {
LoginForm as LoginFormUI,
type LoginFormRefHandle,
} from '@coldsurfers/hotsurf'
import { useRouter } from 'next/navigation'
import { useCallback, useEffect, useState, useRef } from 'react'
import useLoginMutation from '@hooks/useLoginMutation'
import { ME_QUERY } from '@hooks/useMeQuery'
import storage from '@utils/storage/storage'
import Loader from '@ui/Loader'

const SignInPage = () => <LoginForm />
const SigninPage = () => {
const router = useRouter()
const formRef = useRef<LoginFormRefHandle>(null)
const [mutate, { data, loading, client }] = useLoginMutation()
const [errorMessage, setErrorMessage] = useState<string>('')

export default SignInPage
const login = useCallback(
(params: { email: string; password: string }) =>
mutate({
variables: {
input: params,
},
}),
[mutate]
)

useEffect(() => {
if (!data?.login) return
// eslint-disable-next-line no-shadow
const { login } = data
switch (login.__typename) {
case 'HttpError':
setErrorMessage(login.message)
break
case 'UserWithToken':
storage.set('@billets/token', login.token)
client.refetchQueries({
include: [ME_QUERY],
})
break
default:
break
}
}, [client, data, router])

useEffect(() => {
const onKeypress = (e: KeyboardEvent) => {
if (e.key === 'Enter') {
const currentInputValue = formRef.current?.currentInputValue()
if (currentInputValue) {
login(currentInputValue)
}
}
}
document.addEventListener('keypress', onKeypress)

return () => {
document.removeEventListener('keypress', onKeypress)
}
}, [login])

return (
<LoginFormUI
ref={formRef}
onPressLoginButton={login}
withRequestButtonUI
onPressRequestButtonUI={useCallback(() => {
router.push('/auth/request')
}, [router])}
isLoading={loading}
LoadingUI={<Loader />}
errorMessage={errorMessage}
/>
)
}

export default SigninPage
8 changes: 6 additions & 2 deletions packages/billets-admin-client/app/concert/[id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,9 @@ const Thumbnail = styled.img`
border-radius: 8px;
margin-top: 12px;
object-fit: contain;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24);
box-shadow:
0 1px 3px rgba(0, 0, 0, 0.12),
0 1px 2px rgba(0, 0, 0, 0.24);
transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
`

Expand Down Expand Up @@ -341,7 +343,9 @@ const SectionList = styled.div`
const SectionCard = styled.div`
margin-top: 6px;
margin-bottom: 12px;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24);
box-shadow:
0 1px 3px rgba(0, 0, 0, 0.12),
0 1px 2px rgba(0, 0, 0, 0.24);
transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
background-color: ${palette.white};
padding: 16px;
Expand Down
3 changes: 1 addition & 2 deletions packages/billets-admin-client/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ export default function Page() {
}}
/>
</TableBottom>
{loading && <Loader />}
{/* {loading && <Loader />} */}
</Wrapper>
)
}
Expand Down Expand Up @@ -301,7 +301,6 @@ const Td = styled.td`
padding-right: 8px;
background-color: ${palette.white};
&:hover {
/* background-color: ${palette.pink}; */
}
& + & {
border-left: 1px solid ${palette.yellow};
Expand Down
Loading

0 comments on commit 67446b2

Please sign in to comment.