diff --git a/.env.development b/.env.development index ec7dc94e1..a59c70dc5 100644 --- a/.env.development +++ b/.env.development @@ -1,4 +1,4 @@ NEXT_PUBLIC_BASE_URL='https://staging-api.realdevsquad.com' NEXT_PUBLIC_GITHUB_IMAGE_URL='https://raw.githubusercontent.com/Real-Dev-Squad/website-static/main/members' -NEXT_PUBLIC_API_MOCKING='OFF' +NEXT_PUBLIC_API_MOCKING='ON' diff --git a/src/pages/mine.tsx b/src/pages/mine.tsx index 67527d085..b41514b44 100644 --- a/src/pages/mine.tsx +++ b/src/pages/mine.tsx @@ -9,18 +9,27 @@ import task from '@/interfaces/task.type'; import { LOGIN_URL, MINE_TASKS_URL } from '@/components/constants/url'; function CardList(tasks: task[]) { - return tasks.map((item: task) => ( + return tasks.map( + (item: task) => ( - )); -} + ) + ); + } + const Mine: FC = () => { const [tasks, setTasks] = useState([]); + const { + response, + error, + isLoading, + callAPI + } = useFetch(TASKS_URL, {}, false); const { response, error, isLoading, callAPI } = useFetch( MINE_TASKS_URL, {}, @@ -29,11 +38,12 @@ const Mine: FC = () => { const { state } = useAppContext(); const { isLoading: isAuthenticating, isLoggedIn } = state; useEffect(() => { - if (isLoggedIn && !Object.keys(response).length) { + if (JSON.stringify(response) === "{}") { callAPI(); + } else { setTasks(response); - } - }, [isLoggedIn, response]); + } + }, [isLoggedIn, response]) return ( @@ -50,10 +60,10 @@ const Mine: FC = () => {

) : ( <> - {tasks.length > 0 ? ( -
{CardList(tasks)}
+ {response?.length > 0 ? ( +
{CardList(tasks)}
) : ( -

No Tasks Found

+

No Tasks Found

)} )