diff --git a/src/pages/Hub.tsx b/src/pages/Hub.tsx index 722a0a2..93de021 100644 --- a/src/pages/Hub.tsx +++ b/src/pages/Hub.tsx @@ -13,6 +13,7 @@ import { CopyOutlined, StarOutlined, ArrowRightOutlined, + EditOutlined, } from '@ant-design/icons'; import { useCallback, @@ -39,6 +40,7 @@ import { UsersRecordFull, } from '../types/dbData'; import { formatTime } from '../utils/time'; +import { useAuth } from '../contexts/AuthContext'; const { useBreakpoint } = Grid; const { Text, Title } = Typography; @@ -56,6 +58,10 @@ const Hub = () => { const [pageSize, setPageSize] = useState(5); const [total, setTotal] = useState(0); const searchRef = useRef(null); + const { currentUser } = useAuth(); + const goToEdit = (tuneId: string) => navigate(generatePath(Routes.UPLOAD_WITH_TUNE_ID, { + tuneId, + })); const loadData = debounce(async (searchText: string) => { setIsLoading(true); @@ -66,7 +72,7 @@ const Hub = () => { ...tune, key: tune.tuneId, year: tune.year, - author: (tune.expand.author as unknown as UsersRecordFull).username, + authorUsername: (tune.expand.author as unknown as UsersRecordFull).username, displacement: `${tune.displacement}l`, aspiration: aspirationMapper[tune.aspiration], published: formatTime(tune.updated), @@ -83,7 +89,7 @@ const Hub = () => { const debounceLoadData = useCallback((value: string) => { setSearchQuery(value); loadData(value); - // eslint-disable-next-line react-hooks/exhaustive-deps + // eslint-disable-next-line react-hooks/exhaustive-deps }, []); const handleGlobalKeyboard = useCallback((e: KeyboardEvent) => { @@ -157,8 +163,8 @@ const Hub = () => { }, { title: 'Author', - dataIndex: 'author', - key: 'author', + dataIndex: 'authorUsername', + key: 'authorUsername', responsive: ['sm'], }, { @@ -182,12 +188,18 @@ const Hub = () => { { dataIndex: 'tuneId', fixed: 'right', - render: (tuneId: string) => ( - - {isClipboardSupported &&