Skip to content

Commit

Permalink
build: adjust environment variables
Browse files Browse the repository at this point in the history
  • Loading branch information
jobson-almeida committed Feb 29, 2024
1 parent 04532b6 commit 26e19bd
Show file tree
Hide file tree
Showing 25 changed files with 45 additions and 74 deletions.
9 changes: 5 additions & 4 deletions src/app/(pages)/assessments/[id]/page.js
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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"
Expand All @@ -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"
Expand All @@ -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"
Expand Down
3 changes: 1 addition & 2 deletions src/app/(pages)/assessments/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/(pages)/classrooms/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/(pages)/courses/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/(pages)/home/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down
1 change: 1 addition & 0 deletions src/app/(pages)/page.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"use client"
import React from "react";
import ChartPerformance from "../components/chart-performance";

export default function Home() {
Expand Down
2 changes: 1 addition & 1 deletion src/app/(pages)/questions/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down
3 changes: 2 additions & 1 deletion src/app/(pages)/students/page.js
Original file line number Diff line number Diff line change
@@ -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")
}
Expand Down
3 changes: 2 additions & 1 deletion src/app/(pages)/teachers/page.js
Original file line number Diff line number Diff line change
@@ -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")
}
Expand Down
3 changes: 1 addition & 2 deletions src/app/actions/action-chart.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
"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",
},
cache: "no-cache"
})
const values = await response.json()

//revalidateTag("/")
//revalidatePath("/")
return values
Expand Down
6 changes: 2 additions & 4 deletions src/app/api/assessments/[id]/route.js
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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"
Expand Down
6 changes: 2 additions & 4 deletions src/app/api/assessments/route.js
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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"
Expand Down
4 changes: 1 addition & 3 deletions src/app/api/chart_data/route.js
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
6 changes: 2 additions & 4 deletions src/app/api/classrooms/[id]/route.js
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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"
Expand Down
6 changes: 2 additions & 4 deletions src/app/api/classrooms/route.js
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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"
Expand Down
6 changes: 2 additions & 4 deletions src/app/api/courses/[id]/route.js
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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"
Expand Down
6 changes: 2 additions & 4 deletions src/app/api/courses/route.js
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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"
Expand Down
6 changes: 2 additions & 4 deletions src/app/api/home/[id]/route.js
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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"
Expand Down
6 changes: 2 additions & 4 deletions src/app/api/home/route.js
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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"
Expand Down
6 changes: 2 additions & 4 deletions src/app/api/questions/[id]/route.js
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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"
Expand Down
6 changes: 2 additions & 4 deletions src/app/api/questions/route.js
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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"
Expand Down
6 changes: 2 additions & 4 deletions src/app/api/students/[id]/route.js
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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"
Expand Down
Loading

0 comments on commit 26e19bd

Please sign in to comment.