From 26e19bdc496bf222a1385b280c93491242d9f02a Mon Sep 17 00:00:00 2001 From: Jobson Almeida Date: Wed, 28 Feb 2024 21:27:56 -0300 Subject: [PATCH] build: adjust environment variables --- src/app/(pages)/assessments/[id]/page.js | 9 +++++---- src/app/(pages)/assessments/page.js | 3 +-- src/app/(pages)/classrooms/page.js | 2 +- src/app/(pages)/courses/page.js | 2 +- src/app/(pages)/home/page.js | 2 +- src/app/(pages)/page.js | 1 + src/app/(pages)/questions/page.js | 2 +- src/app/(pages)/students/page.js | 3 ++- src/app/(pages)/teachers/page.js | 3 ++- src/app/actions/action-chart.js | 3 +-- src/app/api/assessments/[id]/route.js | 6 ++---- src/app/api/assessments/route.js | 6 ++---- src/app/api/chart_data/route.js | 4 +--- src/app/api/classrooms/[id]/route.js | 6 ++---- src/app/api/classrooms/route.js | 6 ++---- src/app/api/courses/[id]/route.js | 6 ++---- src/app/api/courses/route.js | 6 ++---- src/app/api/home/[id]/route.js | 6 ++---- src/app/api/home/route.js | 6 ++---- src/app/api/questions/[id]/route.js | 6 ++---- src/app/api/questions/route.js | 6 ++---- src/app/api/students/[id]/route.js | 6 ++---- src/app/api/students/route.js | 7 ++----- src/app/api/teachers/[id]/route.js | 6 ++---- src/app/api/teachers/route.js | 6 ++---- 25 files changed, 45 insertions(+), 74 deletions(-) diff --git a/src/app/(pages)/assessments/[id]/page.js b/src/app/(pages)/assessments/[id]/page.js index 834afa8..632796b 100644 --- a/src/app/(pages)/assessments/[id]/page.js +++ b/src/app/(pages)/assessments/[id]/page.js @@ -1,9 +1,10 @@ +import React from "react"; import Link from "next/link" import CoursesClassroomsListEdit from "../../../components/courses-classrooms-list-edit" import QuestionsListEdit from "../../../components/questions-list-edit" async function getAssessment(id) { - const response = await fetch(`http://localhost:3000/api/assessments/${id}`, { + const response = await fetch(`${process.env.APP_BASE_URL}/api/assessments/${id}`, { method: "GET", headers: { "Content-type": "application/json" @@ -14,7 +15,7 @@ async function getAssessment(id) { } async function getCourses() { - const response = await fetch("http://localhost:3000/api/courses", { + const response = await fetch(`${process.env.APP_BASE_URL}/api/courses`, { method: "GET", headers: { "Content-type": "application/json" @@ -25,7 +26,7 @@ async function getCourses() { } async function getClassrooms() { - const response = await fetch("http://localhost:3000/api/classrooms", { + const response = await fetch(`${process.env.APP_BASE_URL}/api/classrooms`, { method: "GET", headers: { "Content-type": "application/json" @@ -36,7 +37,7 @@ async function getClassrooms() { } async function getQuestions() { - const response = await fetch("http://localhost:3000/api/questions", { + const response = await fetch(`${process.env.APP_BASE_URL}/api/questions`, { method: "GET", headers: { "Content-type": "application/json" diff --git a/src/app/(pages)/assessments/page.js b/src/app/(pages)/assessments/page.js index c612c6b..738fcb7 100644 --- a/src/app/(pages)/assessments/page.js +++ b/src/app/(pages)/assessments/page.js @@ -2,8 +2,7 @@ import React from "react"; import AssessmentsList from "../../components/assessments-list"; async function getAssessments() { - - const response = await fetch("http://localhost:3000/api/assessments") + const response = await fetch(`${process.env.APP_BASE_URL}/api/assessments`) if (!response.ok) { return new Error("failed to load assessments") } diff --git a/src/app/(pages)/classrooms/page.js b/src/app/(pages)/classrooms/page.js index 34ee309..ad7b96d 100644 --- a/src/app/(pages)/classrooms/page.js +++ b/src/app/(pages)/classrooms/page.js @@ -2,7 +2,7 @@ import React from "react"; import ClassroomsList from "../../components/classroom-list"; async function getClassrooms() { - const response = await fetch("http://localhost:3000/api/classrooms") + const response = await fetch(`${process.env.APP_BASE_URL}/api/classrooms`) if (!response.ok) { return new Error("failed to load classrooms") } diff --git a/src/app/(pages)/courses/page.js b/src/app/(pages)/courses/page.js index 276b84a..83e1c47 100644 --- a/src/app/(pages)/courses/page.js +++ b/src/app/(pages)/courses/page.js @@ -2,7 +2,7 @@ import React from "react"; import CoursesList from "../../components/course-list"; async function getCourses() { - const response = await fetch("http://localhost:3000/api/courses") + const response = await fetch(`${process.env.APP_BASE_URL}/api/courses`) if (!response.ok) { return new Error("failed to load courses") } diff --git a/src/app/(pages)/home/page.js b/src/app/(pages)/home/page.js index cfed0b6..4c109ea 100644 --- a/src/app/(pages)/home/page.js +++ b/src/app/(pages)/home/page.js @@ -2,7 +2,7 @@ import React from "react"; import HomeList from "../../components/home-list"; async function getCourses() { - const response = await fetch("http://localhost:3000/api/courses") + const response = await fetch(`${process.env.APP_BASE_URL}/api/courses`) if (!response.ok) { return new Error("failed to load courses") } diff --git a/src/app/(pages)/page.js b/src/app/(pages)/page.js index 05c625d..34b78cd 100644 --- a/src/app/(pages)/page.js +++ b/src/app/(pages)/page.js @@ -1,4 +1,5 @@ "use client" +import React from "react"; import ChartPerformance from "../components/chart-performance"; export default function Home() { diff --git a/src/app/(pages)/questions/page.js b/src/app/(pages)/questions/page.js index c27d902..763e7e8 100644 --- a/src/app/(pages)/questions/page.js +++ b/src/app/(pages)/questions/page.js @@ -2,7 +2,7 @@ import React from "react"; import QuestionsList from "../../components/questions-list"; async function getQuestions() { - const response = await fetch("http://localhost:3000/api/questions") + const response = await fetch(`${process.env.APP_BASE_URL}/api/questions`) if (!response.ok) { return new Error("failed to load questions") } diff --git a/src/app/(pages)/students/page.js b/src/app/(pages)/students/page.js index 0c34891..0c8be1e 100644 --- a/src/app/(pages)/students/page.js +++ b/src/app/(pages)/students/page.js @@ -1,7 +1,8 @@ +import React from "react"; import StudentsList from "../../components/students-list" async function getStudents() { - const response = await fetch('http://localhost:3000/api/students') + const response = await fetch(`${process.env.APP_BASE_URL}/api/students`) if (!response.ok) { return new Error("failed to load students") } diff --git a/src/app/(pages)/teachers/page.js b/src/app/(pages)/teachers/page.js index 033b180..c34aff7 100644 --- a/src/app/(pages)/teachers/page.js +++ b/src/app/(pages)/teachers/page.js @@ -1,7 +1,8 @@ +import React from "react"; import TeachersList from "../../components/teachers-list" async function getTeachers() { - const response = await fetch("http://localhost:3000/api/teachers") + const response = await fetch(`${process.env.APP_BASE_URL}/api/teachers`) if (!response.ok) { return new Error("failed to load teachers") } diff --git a/src/app/actions/action-chart.js b/src/app/actions/action-chart.js index ee3c0ee..e428250 100644 --- a/src/app/actions/action-chart.js +++ b/src/app/actions/action-chart.js @@ -1,6 +1,6 @@ "use server" export async function ActionChart(source) { - const response = await fetch(`${process.env.NEXT_PUBLIC_VERCEL_URL}/api/${source}`, { + const response = await fetch(`${process.env.APP_BASE_URL}/api/${source}`, { method: "GET", headers: { "Content-type": "application/json", @@ -8,7 +8,6 @@ export async function ActionChart(source) { cache: "no-cache" }) const values = await response.json() - //revalidateTag("/") //revalidatePath("/") return values diff --git a/src/app/api/assessments/[id]/route.js b/src/app/api/assessments/[id]/route.js index d604e34..f5b7b4a 100644 --- a/src/app/api/assessments/[id]/route.js +++ b/src/app/api/assessments/[id]/route.js @@ -1,11 +1,9 @@ import { revalidatePath, revalidateTag } from "next/cache"; import { NextResponse } from "next/server"; -const API_URL_BASE = process.env.API_URL_BASE; - export async function GET(request, { params }) { const id = params.id - const response = await fetch(`${API_URL_BASE}/assessments?id=${id}`, { + const response = await fetch(`${process.env.API_BASE_URL}/assessments?id=${id}`, { method: "GET", headers: { "Content-type": "application/json" @@ -18,7 +16,7 @@ export async function GET(request, { params }) { export async function DELETE(request) { const id = request.params.id - await fetch(`${API_URL_BASE}/assessments/${id}`, { + await fetch(`${process.env.API_BASE_URL}/assessments/${id}`, { method: "DELETE", headers: { "Content-type": "application/json" diff --git a/src/app/api/assessments/route.js b/src/app/api/assessments/route.js index 1892c1d..d4b142c 100644 --- a/src/app/api/assessments/route.js +++ b/src/app/api/assessments/route.js @@ -1,10 +1,8 @@ import { revalidatePath, revalidateTag } from "next/cache"; import { NextResponse } from "next/server"; -const API_URL_BASE = process.env.API_URL_BASE; - export async function GET() { - const response = await fetch(`${API_URL_BASE}/assessments`, { + const response = await fetch(`${process.env.API_BASE_URL}/assessments`, { method: "GET", headers: { "Content-type": "application/json" @@ -17,7 +15,7 @@ export async function GET() { export async function POST(request) { const { avatar, firstname, lastname, email, phone, address } = await request.json() - const response = await fetch(`${API_URL_BASE}/assessments`, { + const response = await fetch(`${process.env.API_BASE_URL}/assessments`, { method: "POST", headers: { "Content-type": "application/json" diff --git a/src/app/api/chart_data/route.js b/src/app/api/chart_data/route.js index aa7bfe4..23a3c2d 100644 --- a/src/app/api/chart_data/route.js +++ b/src/app/api/chart_data/route.js @@ -1,10 +1,8 @@ import { revalidateTag } from "next/cache"; import { NextResponse } from "next/server"; -const API_URL_BASE = process.env.API_URL_BASE; - export async function GET() { - const response = await fetch(`${API_URL_BASE}/chart_data`, { + const response = await fetch(`${process.env.API_BASE_URL}/chart_data`, { method: "GET", headers: { "Content-type": "application/json" diff --git a/src/app/api/classrooms/[id]/route.js b/src/app/api/classrooms/[id]/route.js index dadd09a..0eb6ccb 100644 --- a/src/app/api/classrooms/[id]/route.js +++ b/src/app/api/classrooms/[id]/route.js @@ -1,11 +1,9 @@ import { revalidatePath, revalidateTag } from "next/cache"; import { NextResponse } from "next/server"; -const API_URL_BASE = process.env.API_URL_BASE; - export async function GET(request, { params }) { const id = params.id - const response = await fetch(`${API_URL_BASE}/classrooms/${id}`, { + const response = await fetch(`${process.env.API_BASE_URL}/classrooms/${id}`, { method: "GET", headers: { "Content-type": "application/json" @@ -18,7 +16,7 @@ export async function GET(request, { params }) { export async function DELETE(request) { const id = request.params.id - await fetch(`${API_URL_BASE}/classrooms/${id}`, { + await fetch(`${process.env.API_BASE_URL}/classrooms/${id}`, { method: "DELETE", headers: { "Content-type": "application/json" diff --git a/src/app/api/classrooms/route.js b/src/app/api/classrooms/route.js index 11c7b09..738025f 100644 --- a/src/app/api/classrooms/route.js +++ b/src/app/api/classrooms/route.js @@ -1,13 +1,11 @@ import { revalidatePath } from "next/cache"; import { NextResponse } from "next/server"; -const API_URL_BASE = process.env.API_URL_BASE; - export async function GET(request) { // const course = await request.nextUrl.searchParams.get('course') //const url = course !== null ? `http://localhost:8000/classrooms?course=${course}` : "http://localhost:8000/classrooms" - const response = await fetch(`${API_URL_BASE}/classrooms`, { + const response = await fetch(`${process.env.API_BASE_URL}/classrooms`, { method: "GET", headers: { "Content-type": "application/json" @@ -20,7 +18,7 @@ export async function GET(request) { export async function POST(request) { const { name, description } = await request.json() - const response = await fetch(`${API_URL_BASE}/classrooms`, { + const response = await fetch(`${process.env.API_BASE_URL}/classrooms`, { method: "POST", headers: { "Content-type": "application/json" diff --git a/src/app/api/courses/[id]/route.js b/src/app/api/courses/[id]/route.js index ae03cbf..e952de9 100644 --- a/src/app/api/courses/[id]/route.js +++ b/src/app/api/courses/[id]/route.js @@ -1,11 +1,9 @@ import { revalidatePath, revalidateTag } from "next/cache"; import { NextResponse } from "next/server"; -const API_URL_BASE = process.env.API_URL_BASE; - export async function GET(request, { params }) { const id = params.id - const response = await fetch(`${API_URL_BASE}/courses/${id}`, { + const response = await fetch(`${process.env.API_BASE_URL}/courses/${id}`, { method: "GET", headers: { "Content-type": "application/json" @@ -18,7 +16,7 @@ export async function GET(request, { params }) { export async function DELETE(request, { params }) { const id = params.id - await fetch(`${API_URL_BASE}/courses/${id}`, { + await fetch(`${process.env.API_BASE_URL}/courses/${id}`, { method: "DELETE", headers: { "Content-type": "application/json" diff --git a/src/app/api/courses/route.js b/src/app/api/courses/route.js index 40ff044..5a772ce 100644 --- a/src/app/api/courses/route.js +++ b/src/app/api/courses/route.js @@ -1,10 +1,8 @@ import { revalidatePath, revalidateTag } from "next/cache"; import { NextResponse } from "next/server"; -const API_URL_BASE = process.env.API_URL_BASE; - export async function GET() { - const response = await fetch(`${API_URL_BASE}/courses`, { + const response = await fetch(`${process.env.API_BASE_URL}/courses`, { method: "GET", headers: { "Content-type": "application/json" @@ -17,7 +15,7 @@ export async function GET() { export async function POST(request) { const { name, description } = await request.json() - const response = await fetch(`${API_URL_BASE}/courses`, { + const response = await fetch(`${process.env.API_BASE_URL}/courses`, { method: "POST", headers: { "Content-type": "application/json" diff --git a/src/app/api/home/[id]/route.js b/src/app/api/home/[id]/route.js index ae03cbf..e952de9 100644 --- a/src/app/api/home/[id]/route.js +++ b/src/app/api/home/[id]/route.js @@ -1,11 +1,9 @@ import { revalidatePath, revalidateTag } from "next/cache"; import { NextResponse } from "next/server"; -const API_URL_BASE = process.env.API_URL_BASE; - export async function GET(request, { params }) { const id = params.id - const response = await fetch(`${API_URL_BASE}/courses/${id}`, { + const response = await fetch(`${process.env.API_BASE_URL}/courses/${id}`, { method: "GET", headers: { "Content-type": "application/json" @@ -18,7 +16,7 @@ export async function GET(request, { params }) { export async function DELETE(request, { params }) { const id = params.id - await fetch(`${API_URL_BASE}/courses/${id}`, { + await fetch(`${process.env.API_BASE_URL}/courses/${id}`, { method: "DELETE", headers: { "Content-type": "application/json" diff --git a/src/app/api/home/route.js b/src/app/api/home/route.js index 40ff044..5a772ce 100644 --- a/src/app/api/home/route.js +++ b/src/app/api/home/route.js @@ -1,10 +1,8 @@ import { revalidatePath, revalidateTag } from "next/cache"; import { NextResponse } from "next/server"; -const API_URL_BASE = process.env.API_URL_BASE; - export async function GET() { - const response = await fetch(`${API_URL_BASE}/courses`, { + const response = await fetch(`${process.env.API_BASE_URL}/courses`, { method: "GET", headers: { "Content-type": "application/json" @@ -17,7 +15,7 @@ export async function GET() { export async function POST(request) { const { name, description } = await request.json() - const response = await fetch(`${API_URL_BASE}/courses`, { + const response = await fetch(`${process.env.API_BASE_URL}/courses`, { method: "POST", headers: { "Content-type": "application/json" diff --git a/src/app/api/questions/[id]/route.js b/src/app/api/questions/[id]/route.js index 75758bc..9f832c6 100644 --- a/src/app/api/questions/[id]/route.js +++ b/src/app/api/questions/[id]/route.js @@ -1,11 +1,9 @@ import { revalidatePath, revalidateTag } from "next/cache"; import { NextResponse } from "next/server"; -const API_URL_BASE = process.env.API_URL_BASE; - export async function GET(request, { params }) { const id = params.id - const response = await fetch(`${API_URL_BASE}/questions/${id}`, { + const response = await fetch(`${process.env.API_BASE_URL}/questions/${id}`, { method: "GET", headers: { "Content-type": "application/json" @@ -18,7 +16,7 @@ export async function GET(request, { params }) { export async function DELETE({ params }) { const id = params.id - await fetch(`${API_URL_BASE}/questions/${id}`, { + await fetch(`${process.env.API_BASE_URL}/questions/${id}`, { method: "DELETE", headers: { "Content-type": "application/json" diff --git a/src/app/api/questions/route.js b/src/app/api/questions/route.js index 5da79fc..fdeb6c6 100644 --- a/src/app/api/questions/route.js +++ b/src/app/api/questions/route.js @@ -1,10 +1,8 @@ import { revalidatePath, revalidateTag } from "next/cache"; import { NextResponse } from "next/server"; -const API_URL_BASE = process.env.API_URL_BASE; - export async function GET() { - const response = await fetch(`${API_URL_BASE}/questions`, { + const response = await fetch(`${process.env.API_BASE_URL}/questions`, { method: "GET", headers: { "Content-type": "application/json" @@ -17,7 +15,7 @@ export async function GET() { export async function POST(request) { const { questioning, type, alternatives, answer, discipline } = await request.json() - const response = await fetch(`${API_URL_BASE}/questions`, { + const response = await fetch(`${process.env.API_BASE_URL}/questions`, { method: "POST", headers: { "Content-type": "application/json" diff --git a/src/app/api/students/[id]/route.js b/src/app/api/students/[id]/route.js index a8f6f35..1424d31 100644 --- a/src/app/api/students/[id]/route.js +++ b/src/app/api/students/[id]/route.js @@ -1,11 +1,9 @@ import { revalidatePath, revalidateTag } from "next/cache"; import { NextResponse } from "next/server"; -const API_URL_BASE = process.env.API_URL_BASE; - export async function GET(request, { params }) { const id = params.id - const response = await fetch(`${API_URL_BASE}/students/${id}`, { + const response = await fetch(`${process.env.API_BASE_URL}/students/${id}`, { method: "GET", headers: { "Content-type": "application/json" @@ -19,7 +17,7 @@ export async function GET(request, { params }) { export async function DELETE(request) { const id = request.params.id //const response = - await fetch(`${API_URL_BASE}/students/${id}`, { + await fetch(`${process.env.API_BASE_URL}/students/${id}`, { method: "DELETE", headers: { "Content-type": "application/json" diff --git a/src/app/api/students/route.js b/src/app/api/students/route.js index ebc46a8..d22ffe2 100644 --- a/src/app/api/students/route.js +++ b/src/app/api/students/route.js @@ -1,11 +1,8 @@ import { revalidatePath, revalidateTag } from "next/cache"; import { NextResponse } from "next/server"; -const API_URL_BASE = process.env.API_URL_BASE; - export async function GET() { - //const response = await fetch("http://localhost:8000/students?categoryId_ne=0&_expand=category&_sort=id&_order=desc", { - const response = await fetch(`${API_URL_BASE}/students`, { + const response = await fetch(`${process.env.API_BASE_URL}/students`, { method: "GET", headers: { "Content-type": "application/json" @@ -19,7 +16,7 @@ export async function GET() { export async function POST(request) { const { avatar, firstname, lastname, email, phone, address } = await request.json() - const response = await fetch(`${API_URL_BASE}/students`, { + const response = await fetch(`${process.env.API_BASE_URL}/students`, { method: "POST", headers: { "Content-type": "application/json" diff --git a/src/app/api/teachers/[id]/route.js b/src/app/api/teachers/[id]/route.js index 25f758d..5736150 100644 --- a/src/app/api/teachers/[id]/route.js +++ b/src/app/api/teachers/[id]/route.js @@ -1,11 +1,9 @@ import { revalidatePath, revalidateTag } from "next/cache"; import { NextResponse } from "next/server"; -const API_URL_BASE = process.env.API_URL_BASE; - export async function GET(request, { params }) { const id = params.id - const response = await fetch(`${API_URL_BASE}/teachers/${id}`, { + const response = await fetch(`${process.env.API_BASE_URL}/teachers/${id}`, { method: "GET", headers: { "Content-type": "application/json" @@ -18,7 +16,7 @@ export async function GET(request, { params }) { export async function DELETE(request) { const id = request.params.id - await fetch(`${API_URL_BASE}/teachers/${id}`, { + await fetch(`${process.env.API_BASE_URL}/teachers/${id}`, { method: "DELETE", headers: { "Content-type": "application/json" diff --git a/src/app/api/teachers/route.js b/src/app/api/teachers/route.js index 3b1e755..644deac 100644 --- a/src/app/api/teachers/route.js +++ b/src/app/api/teachers/route.js @@ -1,10 +1,8 @@ import { revalidatePath, revalidateTag } from "next/cache"; import { NextResponse } from "next/server"; -const API_URL_BASE = process.env.API_URL_BASE; - export async function GET() { - const response = await fetch(`${API_URL_BASE}/teachers`, { + const response = await fetch(`${process.env.API_BASE_URL}/teachers`, { method: "GET", headers: { "Content-type": "application/json" @@ -17,7 +15,7 @@ export async function GET() { export async function POST(request) { const { avatar, firstname, lastname, email, phone, address } = await request.json() - const response = await fetch(`${API_URL_BASE}/teachers`, { + const response = await fetch(`${process.env.API_BASE_URL}/teachers`, { method: "POST", headers: { "Content-type": "application/json"