diff --git a/components/Profile/MyGroup/index.jsx b/components/Profile/MyGroup/index.jsx index 39154cfb..e9cb6f35 100644 --- a/components/Profile/MyGroup/index.jsx +++ b/components/Profile/MyGroup/index.jsx @@ -29,21 +29,11 @@ const MyGroup = ({ hasTitle = true, sx, userId }) => { if (!userId) { return 趕快發起屬於你的揪團吧~; } - // TODO: 待優化 - const me = useSelector((state) => state.user); const [response, setResponse] = useState(null); - const { isFetching } = useFetch( - `${GROUP_API_URL}/${userId}`, - { - headers: { - Authorization: `Bearer ${me.token}`, - }, - }, - { - onSuccess: setResponse, - }, - ); + const { isFetching } = useFetch(`${GROUP_API_URL}/user/${userId}`, { + onSuccess: setResponse, + }); const getTargetIndexById = (data, id) => { if (!Array.isArray(data)) return -1; diff --git a/hooks/useFetch.jsx b/hooks/useFetch.jsx index dbdc4676..82e8e97d 100644 --- a/hooks/useFetch.jsx +++ b/hooks/useFetch.jsx @@ -1,6 +1,6 @@ import { useEffect, useReducer, useState } from 'react'; -const useFetch = (url, options = {}, { initialValue, onSuccess } = {}) => { +const useFetch = (url, { initialValue, onSuccess } = {}) => { const [render, refetch] = useReducer((pre) => !pre, true); const [data, setData] = useState(initialValue); const [isFetching, setIsFetching] = useState(true); diff --git a/pages/group/detail/index.jsx b/pages/group/detail/index.jsx index 0b496451..bf40d11b 100644 --- a/pages/group/detail/index.jsx +++ b/pages/group/detail/index.jsx @@ -12,12 +12,7 @@ import { BASE_URL } from '@/constants/common'; function GroupPage() { const router = useRouter(); const { id } = router.query; - const me = useSelector((state) => state.user); - const { data, isFetching, isError } = useFetch(`${BASE_URL}/activity/${id}`, { - headers: { - Authorization: `Bearer ${me.token}`, - }, - }); + const { data, isFetching, isError } = useFetch(`${BASE_URL}/activity/${id}`); const source = data?.data?.[0]; const SEOData = useMemo( diff --git a/pages/group/edit/index.jsx b/pages/group/edit/index.jsx index 1c78ac85..e47135e2 100644 --- a/pages/group/edit/index.jsx +++ b/pages/group/edit/index.jsx @@ -17,11 +17,7 @@ function EditGroupPage() { const router = useRouter(); const me = useSelector((state) => state.user); const { id } = router.query; - const { data, isFetching } = useFetch(`${BASE_URL}/activity/${id}`, { - headers: { - Authorization: `Bearer ${me.token}`, - }, - }); + const { data, isFetching } = useFetch(`${BASE_URL}/activity/${id}`); const source = data?.data?.[0]; const SEOData = useMemo(