-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathEditableName.tsx
65 lines (59 loc) · 1.77 KB
/
EditableName.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// import {
// Editable,
// EditableInput,
// EditablePreview,
// useEditableControls,
// } from '@chakra-ui/editable'
// import { EditIcon } from '@chakra-ui/icons'
// import { useAuth } from '@src/context/AuthContext'
// import { http } from '@src/context/HttpClient'
// import { useErrorToast } from '@src/hooks/useErrorToast'
// import { useMutation } from '@src/hooks/useMutation'
// import { IconButton } from '@src/ui/IconButton'
// import { editShowname } from '@src/user/queries'
import { UserProfile } from '@src/user/types'
interface EditableNameProps {
userData: UserProfile
}
// export const EditableName = (props: EditableNameProps) => {
// const { userData } = props
// const { user } = useAuth()
// // TODO: refractor refreshToken
// const onError = useErrorToast()
// const editShownameMutation = useMutation(editShowname)
// const onSubmit = async (showName: string) => {
// if (!user) return
// try {
// await editShownameMutation(user.id, showName)
// await http.refreshToken(null)
// } catch (e: any) {
// onError(e)
// }
// }
// function EditableControls() {
// const { isEditing, getEditButtonProps } = useEditableControls()
// return isEditing ? null : (
// <IconButton
// size="sm"
// icon={<EditIcon />}
// {...getEditButtonProps()}
// aria-label="edit"
// />
// )
// }
// return user?.id === userData.id ? (
// <Editable
// defaultValue={user?.showName}
// isPreviewFocusable={false}
// onSubmit={onSubmit}
// >
// <div className="flex gap-2">
// <EditablePreview />
// <EditableInput />
// <EditableControls />
// </div>
// </Editable>
// ) : (
// <>{userData?.showName}</>
// )
// }