diff --git a/frontend-plataforma-tutoriais/.gitignore b/frontend-plataforma-tutoriais/.gitignore index a547bf3..a0377b4 100644 --- a/frontend-plataforma-tutoriais/.gitignore +++ b/frontend-plataforma-tutoriais/.gitignore @@ -10,6 +10,7 @@ lerna-debug.log* node_modules dist dist-ssr +.env *.local # Editor directories and files diff --git a/frontend-plataforma-tutoriais/src/components/header/index.tsx b/frontend-plataforma-tutoriais/src/components/header/index.tsx index a8211e7..e95d431 100644 --- a/frontend-plataforma-tutoriais/src/components/header/index.tsx +++ b/frontend-plataforma-tutoriais/src/components/header/index.tsx @@ -1,3 +1,4 @@ +import API_URL from "../../config/api"; import styles from "./styles.module.css"; import { LuUser, LuMenu, LuSearch, LuLogOut, LuUsers, LuMail, LuGraduationCap, LuTvMinimalPlay, LuLayoutDashboard, LuCircleUser, LuPanelLeftClose, LuClock3, LuCalendar } from "react-icons/lu"; import { useEffect, useState } from "react"; @@ -13,7 +14,8 @@ import { PiCheckCircleFill } from "react-icons/pi"; import { useGetWorkshopsSearch } from "../../hooks/useGetWorkshopsSearch"; import { imageSkeletonFadeStyle, onImageSkeletonLoad } from "../../utils/imageSkeleton"; import { motion, AnimatePresence } from "framer-motion"; -import { useGetCurrentUser } from "../../hooks/useGetCurrentUser"; +/* import { useGetCurrentUser } from "../../hooks/useGetCurrentUser"; */ + export default function Header() { const [showMenu, setShowMenu] = useState(false); @@ -28,7 +30,7 @@ export default function Header() { const { getVideos } = useGetVideos(); const { getVideosSearch } = useGetVideosSearch(); const { getWorkshopsSearch } = useGetWorkshopsSearch(); - const { getCurrentUser } = useGetCurrentUser(); + /* const { getCurrentUser } = useGetCurrentUser(); */ const [role, setRole] = useState(0); const [videosWatched, setVideosWatched] = useState(0); const [videosCount, setVideosCount] = useState(0); @@ -41,8 +43,8 @@ export default function Header() { setVideosWatched(videosWatched ? parseInt(videosWatched) : 0); const videosCount = localStorage.getItem("videosCount"); setVideosCount(videosCount ? parseInt(videosCount) : 0); - const userData = await getCurrentUser(); - setRole(userData.data.role_id); + /* const userData = await getCurrentUser(); + setRole(userData.data.role_id); */ }; fetchAll(); }, []); @@ -235,7 +237,7 @@ export default function Header() {
{video.title}
{workshop.title} { - const response = await fetch("http://127.0.0.1:8000/api/me", { + const response = await fetch(`${API_URL}/api/me`, { method: "GET", headers: { Accept: "application/json", diff --git a/frontend-plataforma-tutoriais/src/hooks/useGetVideos.ts b/frontend-plataforma-tutoriais/src/hooks/useGetVideos.ts index 7845c82..911b5f6 100644 --- a/frontend-plataforma-tutoriais/src/hooks/useGetVideos.ts +++ b/frontend-plataforma-tutoriais/src/hooks/useGetVideos.ts @@ -1,3 +1,4 @@ +import API_URL from "../config/api"; import type { ApiErrorResponse, Category, Video } from "../types"; type GetVideosParams = { @@ -18,7 +19,7 @@ export function useGetVideos() { if (params.status) query.append("status", params.status); if (params.watched !== undefined) query.append("watched", params.watched.toString()); - const response = await fetch(`http://127.0.0.1:8000/api/videos?${query.toString()}`, { + const response = await fetch(`${API_URL}/api/videos?${query.toString()}`, { method: "GET", headers: { Accept: "application/json", diff --git a/frontend-plataforma-tutoriais/src/hooks/useGetVideosLength.ts b/frontend-plataforma-tutoriais/src/hooks/useGetVideosLength.ts index db1f9fd..b5789ba 100644 --- a/frontend-plataforma-tutoriais/src/hooks/useGetVideosLength.ts +++ b/frontend-plataforma-tutoriais/src/hooks/useGetVideosLength.ts @@ -1,9 +1,10 @@ +import API_URL from "../config/api"; import type { ApiErrorResponse } from "../types"; export function useGetVideosLength() { async function getVideosLength() { try { - const response = await fetch("http://127.0.0.1:8000/api/videos-length", { + const response = await fetch(`${API_URL}/api/videos-length`, { method: "GET", headers: { Accept: "application/json", diff --git a/frontend-plataforma-tutoriais/src/hooks/useGetVideosSearch.ts b/frontend-plataforma-tutoriais/src/hooks/useGetVideosSearch.ts index 53b115d..a329b9a 100644 --- a/frontend-plataforma-tutoriais/src/hooks/useGetVideosSearch.ts +++ b/frontend-plataforma-tutoriais/src/hooks/useGetVideosSearch.ts @@ -1,9 +1,10 @@ +import API_URL from "../config/api"; import type { ApiErrorResponse, Video } from "../types"; export function useGetVideosSearch() { async function getVideosSearch(searchQuery: string = "") { const response = await fetch( - `http://127.0.0.1:8000/api/videos-search?search=${encodeURIComponent(searchQuery)}`, + `${API_URL}/api/videos-search?search=${encodeURIComponent(searchQuery)}`, { method: "GET", headers: { diff --git a/frontend-plataforma-tutoriais/src/hooks/useGetWorkshops.ts b/frontend-plataforma-tutoriais/src/hooks/useGetWorkshops.ts index 5a290f3..3a27ab7 100644 --- a/frontend-plataforma-tutoriais/src/hooks/useGetWorkshops.ts +++ b/frontend-plataforma-tutoriais/src/hooks/useGetWorkshops.ts @@ -1,3 +1,4 @@ +import API_URL from "../config/api"; import type { ApiErrorResponse, Workshop } from "../types"; type GetWorkshopsParams = { @@ -16,7 +17,7 @@ export function useGetWorkshops() { if (params.page) query.append("page", params.page.toString()); if (params.per_page) query.append("per_page", params.per_page.toString()); - const response = await fetch(`http://127.0.0.1:8000/api/workshops?${query.toString()}`, { + const response = await fetch(`${API_URL}/api/workshops?${query.toString()}`, { method: "GET", headers: { Accept: "application/json", diff --git a/frontend-plataforma-tutoriais/src/hooks/useGetWorkshopsLength.ts b/frontend-plataforma-tutoriais/src/hooks/useGetWorkshopsLength.ts index ff911e9..514fa10 100644 --- a/frontend-plataforma-tutoriais/src/hooks/useGetWorkshopsLength.ts +++ b/frontend-plataforma-tutoriais/src/hooks/useGetWorkshopsLength.ts @@ -1,9 +1,10 @@ +import API_URL from "../config/api"; import type { ApiErrorResponse } from "../types"; export function useGetWorkshopsLength() { async function getWorkshopsLength() { try { - const response = await fetch("http://127.0.0.1:8000/api/workshops-length", { + const response = await fetch(`${API_URL}/api/workshops-length`, { method: "GET", headers: { Accept: "application/json", diff --git a/frontend-plataforma-tutoriais/src/hooks/useGetWorkshopsSearch.ts b/frontend-plataforma-tutoriais/src/hooks/useGetWorkshopsSearch.ts index 1cfeee2..530779b 100644 --- a/frontend-plataforma-tutoriais/src/hooks/useGetWorkshopsSearch.ts +++ b/frontend-plataforma-tutoriais/src/hooks/useGetWorkshopsSearch.ts @@ -1,9 +1,10 @@ +import API_URL from "../config/api"; import type { ApiErrorResponse, Workshop } from "../types"; export function useGetWorkshopsSearch() { async function getWorkshopsSearch(searchQuery: string = "") { const response = await fetch( - `http://127.0.0.1:8000/api/workshops-search?search=${encodeURIComponent(searchQuery)}`, + `${API_URL}/api/workshops-search?search=${encodeURIComponent(searchQuery)}`, { method: "GET", headers: { diff --git a/frontend-plataforma-tutoriais/src/hooks/useNextVideos.ts b/frontend-plataforma-tutoriais/src/hooks/useNextVideos.ts index 8c91421..2468a52 100644 --- a/frontend-plataforma-tutoriais/src/hooks/useNextVideos.ts +++ b/frontend-plataforma-tutoriais/src/hooks/useNextVideos.ts @@ -1,8 +1,9 @@ +import API_URL from "../config/api"; import type { ApiErrorResponse, Video } from "../types"; export function useNextVideos() { async function getNextVideos() { - const response = await fetch("http://127.0.0.1:8000/api/next-videos", { + const response = await fetch(`${API_URL}/api/next-videos`, { method: "GET", headers: { Accept: "application/json", diff --git a/frontend-plataforma-tutoriais/src/hooks/useNextWorkshops.ts b/frontend-plataforma-tutoriais/src/hooks/useNextWorkshops.ts index e681fad..ce84179 100644 --- a/frontend-plataforma-tutoriais/src/hooks/useNextWorkshops.ts +++ b/frontend-plataforma-tutoriais/src/hooks/useNextWorkshops.ts @@ -1,8 +1,9 @@ +import API_URL from "../config/api"; import type { ApiErrorResponse, NextWorkshopsResponse } from "../types"; export function useNextWorkshops() { async function getNextWorkshops() { - const response = await fetch("http://127.0.0.1:8000/api/next-workshops", { + const response = await fetch(`${API_URL}/api/next-workshops`, { method: "GET", headers: { Accept: "application/json", diff --git a/frontend-plataforma-tutoriais/src/hooks/useVideoWatch.ts b/frontend-plataforma-tutoriais/src/hooks/useVideoWatch.ts index 4cab5c4..b94a06f 100644 --- a/frontend-plataforma-tutoriais/src/hooks/useVideoWatch.ts +++ b/frontend-plataforma-tutoriais/src/hooks/useVideoWatch.ts @@ -1,3 +1,4 @@ +import API_URL from "../config/api"; import { useState, useRef } from "react"; export function useVideoWatch(videoId: number, initialWatched: boolean) { @@ -10,7 +11,7 @@ export function useVideoWatch(videoId: number, initialWatched: boolean) { alreadySent.current = true; try { - await fetch(`http://127.0.0.1:8000/api/video/${videoId}/watch`, { + await fetch(`${API_URL}/api/video/${videoId}/watch`, { method: "POST", headers: { Accept: "application/json", diff --git a/frontend-plataforma-tutoriais/src/pages/private/admin/createUser/index.tsx b/frontend-plataforma-tutoriais/src/pages/private/admin/createUser/index.tsx index fdb0745..c437ece 100644 --- a/frontend-plataforma-tutoriais/src/pages/private/admin/createUser/index.tsx +++ b/frontend-plataforma-tutoriais/src/pages/private/admin/createUser/index.tsx @@ -1,3 +1,4 @@ +import API_URL from "../../../../config/api"; import { useState } from "react"; import { Link } from "react-router"; import styles from "./styles.module.css"; @@ -71,7 +72,7 @@ export default function CreateUser() { role_id: role_id, }; - const response = await fetch("http://127.0.0.1:8000/api/create-user", { + const response = await fetch(`${API_URL}/api/create-user`, { method: "POST", headers: { Accept: "application/json", diff --git a/frontend-plataforma-tutoriais/src/pages/private/admin/createVideo/index.tsx b/frontend-plataforma-tutoriais/src/pages/private/admin/createVideo/index.tsx index eb9c352..280ec14 100644 --- a/frontend-plataforma-tutoriais/src/pages/private/admin/createVideo/index.tsx +++ b/frontend-plataforma-tutoriais/src/pages/private/admin/createVideo/index.tsx @@ -1,3 +1,4 @@ +import API_URL from "../../../../config/api"; import { useEffect, useState } from "react"; import { Link } from "react-router"; import type { Category } from "../../../../types"; @@ -25,7 +26,7 @@ export default function CreateVideo() { }, []); async function getCategories() { - const response = await fetch("http://127.0.0.1:8000/api/categories", { + const response = await fetch(`${API_URL}/api/categories`, { method: "GET", headers: { Accept: "application/json", @@ -75,7 +76,7 @@ export default function CreateVideo() { const xhr = new XMLHttpRequest(); - xhr.open("POST", "http://127.0.0.1:8000/api/create-video"); + xhr.open("POST", `${API_URL}/api/create-video`); xhr.setRequestHeader("Authorization", `Bearer ${localStorage.getItem("token")}`); xhr.setRequestHeader("Accept", "application/json"); xhr.upload.onprogress = (event) => { @@ -167,7 +168,7 @@ export default function CreateVideo() { } async function createCategory(categoryName: string) { - const response = await fetch("http://127.0.0.1:8000/api/categories", { + const response = await fetch(`${API_URL}/api/categories`, { method: "POST", headers: { Accept: "application/json", diff --git a/frontend-plataforma-tutoriais/src/pages/private/admin/createWorkshop/index.tsx b/frontend-plataforma-tutoriais/src/pages/private/admin/createWorkshop/index.tsx index 45bca75..66b5d8a 100644 --- a/frontend-plataforma-tutoriais/src/pages/private/admin/createWorkshop/index.tsx +++ b/frontend-plataforma-tutoriais/src/pages/private/admin/createWorkshop/index.tsx @@ -1,3 +1,4 @@ +import API_URL from "../../../../config/api"; import { useState } from "react"; import { Link } from "react-router"; import styles from "./styles.module.css"; @@ -50,7 +51,7 @@ export default function CreateWorkshop() { formData.append("time_start", time_start.toTimeString().slice(0, 5)); formData.append("time_end", time_end.toTimeString().slice(0, 5)); - const response = await fetch("http://127.0.0.1:8000/api/create-workshop", { + const response = await fetch(`${API_URL}/api/create-workshop`, { method: "POST", headers: { 'Accept': 'application/json', diff --git a/frontend-plataforma-tutoriais/src/pages/private/admin/editVideo/[id].tsx b/frontend-plataforma-tutoriais/src/pages/private/admin/editVideo/[id].tsx index 5eb6be2..07b27b1 100644 --- a/frontend-plataforma-tutoriais/src/pages/private/admin/editVideo/[id].tsx +++ b/frontend-plataforma-tutoriais/src/pages/private/admin/editVideo/[id].tsx @@ -1,3 +1,4 @@ +import API_URL from "../../../../config/api"; import { useEffect, useState } from "react"; import { Link, useNavigate, useParams } from "react-router"; import type { ApiErrorResponse, Category, Video } from "../../../../types"; @@ -35,7 +36,7 @@ export default function editVideo() { setLoading(true); try { - const response = await fetch(`http://127.0.0.1:8000/api/video/${id}`, { + const response = await fetch(`${API_URL}/api/video/${id}`, { method: "GET", headers: { Accept: "application/json", @@ -61,7 +62,7 @@ export default function editVideo() { } async function destroy(id: number) { - const response = await fetch(`http://127.0.0.1:8000/api/delete-video/${id}`, { + const response = await fetch(`${API_URL}/api/delete-video/${id}`, { method: "DELETE", headers: { Accept: "application/json", @@ -124,7 +125,7 @@ export default function editVideo() { // quando a rota aceita PATCH (method spoofing) formData.append("_method", "PATCH"); - const response = await fetch(`http://127.0.0.1:8000/api/edit-video/${id}`, { + const response = await fetch(`${API_URL}/api/edit-video/${id}`, { method: "POST", headers: { Accept: "application/json", @@ -157,7 +158,7 @@ export default function editVideo() { } async function getCategories() { - const response = await fetch("http://127.0.0.1:8000/api/categories", { + const response = await fetch(`${API_URL}/api/categories`, { method: "GET", headers: { Accept: "application/json", @@ -206,7 +207,7 @@ export default function editVideo() { } async function createCategory(categoryName: string) { - const response = await fetch("http://127.0.0.1:8000/api/categories", { + const response = await fetch(`${API_URL}/api/categories`, { method: "POST", headers: { Accept: "application/json", diff --git a/frontend-plataforma-tutoriais/src/pages/private/admin/editWorkshop/[id].tsx b/frontend-plataforma-tutoriais/src/pages/private/admin/editWorkshop/[id].tsx index f9c4bc3..347e82c 100644 --- a/frontend-plataforma-tutoriais/src/pages/private/admin/editWorkshop/[id].tsx +++ b/frontend-plataforma-tutoriais/src/pages/private/admin/editWorkshop/[id].tsx @@ -1,3 +1,4 @@ +import API_URL from "../../../../config/api"; import { useEffect, useState } from "react"; import { Link, useParams } from "react-router"; import { CgSpinner } from "react-icons/cg"; @@ -47,7 +48,7 @@ export default function Workshop() { async function getWorkshop() { setLoading(true); try { - const response = await fetch(`http://127.0.0.1:8000/api/edit-workshop/${id}`, { + const response = await fetch(`${API_URL}/api/edit-workshop/${id}`, { method: "GET", headers: { Accept: "application/json", @@ -93,7 +94,7 @@ export default function Workshop() { formData.append("image", image); } - const response = await fetch(`http://127.0.0.1:8000/api/edit-workshop/${id}`, { + const response = await fetch(`${API_URL}/api/edit-workshop/${id}`, { method: "POST", headers: { Accept: "application/json", @@ -146,7 +147,7 @@ export default function Workshop() { } /* async function destroy(id: number) { - const response = await fetch(`http://127.0.0.1:8000/api/workshop/${id}`, { + const response = await fetch(`${API_URL}/api/workshop/${id}`, { method: "DELETE", headers: { Accept: "application/json", @@ -205,7 +206,7 @@ export default function Workshop() {
{workshop.title}
{workshop.title} )} {video.title}
{workshop.title} )} {video.title}
{workshop.title}
{workshop.title}
{workshop.title}
diff --git a/frontend-plataforma-tutoriais/src/pages/private/videos/index.tsx b/frontend-plataforma-tutoriais/src/pages/private/videos/index.tsx index cd31c09..3573808 100644 --- a/frontend-plataforma-tutoriais/src/pages/private/videos/index.tsx +++ b/frontend-plataforma-tutoriais/src/pages/private/videos/index.tsx @@ -1,3 +1,4 @@ +import API_URL from "../../../config/api"; import { useEffect, useState } from "react"; import type { ApiErrorResponse, Category, Video } from "../../../types"; import { Link } from "react-router"; @@ -228,7 +229,7 @@ export default function Videos() { )} {video.title}
{workshop.title}
{workshop.title} [],