Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore belindas nextjs update api evironment #525

Merged
merged 3 commits into from
Aug 3, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .env.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Copy and create new .env file
# Public API URL: https://belindascloset.com/api
# Local API URL: http://localhost:3001/api // localhost Port and Server's port need to match
API_URL=http://localhost:3001/api
5 changes: 2 additions & 3 deletions app/add-product-page/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@ import {
ProductSizePantsInseamList,
} from "./product-prop-list";
import UnauthorizedPageMessage from "@/components/UnauthorizedPageMessage";
// WARNING: You won't be able to connect to local backend unless you remove the env variable below.
const URL =
process.env.BELINDAS_CLOSET_PUBLIC_API_URL || "http://localhost:3000/api";

const URL = process.env.BELINDAS_CLOSET_PUBLIC_API_URL;

const AddProduct = () => {
const [productType, setProductType] = useState<string>("");
Expand Down
4 changes: 2 additions & 2 deletions app/archived-products-page/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import ProductCard from "@/components/ProductCard";
import logo from "@/public/belinda-images/logo.png";
import { Container, Grid, Typography } from "@mui/material";
import UnauthorizedPageMessage from "@/components/UnauthorizedPageMessage";
// WARNING: You won't be able to connect to local backend unless you remove the env variable below.
const URL = process.env.BELINDAS_CLOSET_PUBLIC_API_URL || "http://localhost:3000/api";

const URL = process.env.BELINDAS_CLOSET_PUBLIC_API_URL;
const placeholderImg = logo;
interface Product {
_id: string;
Expand Down
5 changes: 2 additions & 3 deletions app/auth/change-password-page/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@ import ErrorAlert from "@/components/ErrorAlert";
import SuccessAlert from "@/components/SuccessAlert";
import { useRouter } from "next/navigation";
import UnauthorizedPageMessage from "@/components/UnauthorizedPageMessage";
// WARNING: You won't be able to connect to local backend unless you remove the env variable below.
const URL =
process.env.BELINDAS_CLOSET_PUBLIC_API_URL || "http://localhost:3000/api";

const URL = process.env.BELINDAS_CLOSET_PUBLIC_API_URL;

const ChangePasswordPage = () => {
const [password, setPassword] = useState({
Expand Down
5 changes: 2 additions & 3 deletions app/auth/reset-password-page/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@ import {
TextField,
Typography,
} from "@mui/material";
// WARNING: You won't be able to connect to local backend unless you remove the env variable below.
const URL =
process.env.BELINDAS_CLOSET_PUBLIC_API_URL || "http://localhost:3000/api";

const URL = process.env.BELINDAS_CLOSET_PUBLIC_API_URL;

const ResetPasswordPage = () => {
const [password, setPassword] = useState({
Expand Down
7 changes: 5 additions & 2 deletions app/auth/sign-in/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,11 @@ import {
useMediaQuery,
} from "@mui/material";
import useAuth from "@/hooks/useAuth";
// WARNING: You won't be able to connect to local backend unless you remove the env variable below.
const URL = process.env.BELINDAS_CLOSET_PUBLIC_API_URL || "http://localhost:3000/api";
// Check env.local file to update API address
const URL = process.env.BELINDAS_CLOSET_PUBLIC_API_URL;
if (URL?.includes('localhost')) {
console.log('Dev API Address: ',URL)
}

const Signin = () => {
const [error, setError] = useState("");
Expand Down
8 changes: 5 additions & 3 deletions app/auth/sign-up/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ import { Link as MuiLink } from "@mui/material";
import ErrorAlert from "@/components/ErrorAlert";
import SuccessAlert from "@/components/SuccessAlert";
import { useRouter } from "next/navigation";
// WARNING: You won't be able to connect to local backend unless you remove the env variable below.
const URL =
process.env.BELINDAS_CLOSET_PUBLIC_API_URL || "http://localhost:3000/api";
// Check env.local file to update API address
const URL = process.env.BELINDAS_CLOSET_PUBLIC_API_URL;
if (URL?.includes('localhost')) {
console.log('Dev API Address: ',URL)
}

const SignUp = () => {
// handling user's incoming info
Expand Down
4 changes: 2 additions & 2 deletions app/category-page/[categoryId]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import React, { useState, useEffect, Dispatch, SetStateAction } from "react";
import ProductCard from "@/components/ProductCard";
import logo from "@/public/belinda-images/logo.png";
import { Container, Grid, Typography } from "@mui/material";
// WARNING: You won't be able to connect to local backend unless you remove the env variable below.

const URL =
process.env.BELINDAS_CLOSET_PUBLIC_API_URL || "http://localhost:3000/api";
process.env.BELINDAS_CLOSET_PUBLIC_API_URL;
const placeholderImg = logo;
interface Product {
_id: string;
Expand Down
4 changes: 2 additions & 2 deletions app/category-page/[categoryId]/products/[productId]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
import React, { useState, useEffect } from "react";
import { CircularProgress } from "@mui/material";
import ProductDetailDisplay from "../[productId]/ProductDetailDisplay";
// WARNING: You won't be able to connect to local backend unless you remove the env variable below.

const URL =
process.env.BELINDAS_CLOSET_PUBLIC_API_URL || "http://localhost:3000/api";
process.env.BELINDAS_CLOSET_PUBLIC_API_URL;
interface Product {
_id: string;
productType: string[];
Expand Down
4 changes: 2 additions & 2 deletions app/category-page/all-products/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import React, { useState, useEffect, Dispatch, SetStateAction } from "react";
import ProductCard from "@/components/ProductCard";
import logo from "@/public/belinda-images/logo.png";
import { Container, Grid, Typography } from "@mui/material";
// WARNING: You won't be able to connect to local backend unless you remove the env variable below.
const URL = process.env.BELINDAS_CLOSET_PUBLIC_API_URL || "http://localhost:3000/api";

const URL = process.env.BELINDAS_CLOSET_PUBLIC_API_URL;
const placeholderImg = logo;
interface Product {
_id: string;
Expand Down
5 changes: 2 additions & 3 deletions app/edit-user-role-page/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ import React, { useState, useEffect } from "react";
import UserCard from "../../components/UserCard";
import { Stack, Typography } from "@mui/material";
import UnauthorizedPageMessage from "@/components/UnauthorizedPageMessage";
// WARNING: You won't be able to connect to local backend unless you remove the env variable below.
const URL =
process.env.BELINDAS_CLOSET_PUBLIC_API_URL || "http://localhost:3000/api";

const URL = process.env.BELINDAS_CLOSET_PUBLIC_API_URL;

/**
* Represents a user.
Expand Down
4 changes: 2 additions & 2 deletions app/profile/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import { Box, Button, Stack, Typography, useMediaQuery, useTheme } from "@mui/ma
import EditUserDetailsDialog from "@/components/EditUserDetailsDialog";
import { useRouter } from "next/navigation";
import UnauthorizedPageMessage from "@/components/UnauthorizedPageMessage";
// WARNING: You won't be able to connect to local backend unless you remove the env variable below.
const URL = process.env.BELINDAS_CLOSET_PUBLIC_API_URL || "http://localhost:3000/api";

const URL = process.env.BELINDAS_CLOSET_PUBLIC_API_URL;

/**
* Represents a user.
Expand Down
5 changes: 2 additions & 3 deletions components/ConfirmArchiveDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ import React, { useState } from "react";
import { Product } from "@/app/category-page/[categoryId]/products/[productId]/ProductDetailDisplay";
import Snackbar from "@mui/material/Snackbar";
import { useMediaQuery, useTheme } from "@mui/material";
// WARNING: You won't be able to connect to local backend unless you remove the env variable below.
const URL =
process.env.BELINDAS_CLOSET_PUBLIC_API_URL || "http://localhost:3000/api";

const URL = process.env.BELINDAS_CLOSET_PUBLIC_API_URL;
/**
* Props for the ConfirmArchiveDialog component.
*/
Expand Down
5 changes: 2 additions & 3 deletions components/ConfirmDeleteDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ import React, { useState } from "react";
import { Product } from "@/app/category-page/[categoryId]/products/[productId]/ProductDetailDisplay";
import Snackbar, { SnackbarOrigin } from "@mui/material/Snackbar";
import { useMediaQuery, useTheme } from "@mui/material";
// WARNING: You won't be able to connect to local backend unless you remove the env variable below.
const URL =
process.env.BELINDAS_CLOSET_PUBLIC_API_URL || "http://localhost:3000/api";

const URL = process.env.BELINDAS_CLOSET_PUBLIC_API_URL;
/**
* Props for the ConfirmDeleteDialog component.
*/
Expand Down
3 changes: 1 addition & 2 deletions components/EditProductDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ import {
import { TextField, useMediaQuery, useTheme } from "@mui/material";
import { Padding } from "@mui/icons-material";
// WARNING: You won't be able to connect to local backend unless you remove the env variable below.
const URL =
process.env.BELINDAS_CLOSET_PUBLIC_API_URL || "http://localhost:3000/api";
const URL = process.env.BELINDAS_CLOSET_PUBLIC_API_URL;

/**
* Props for the EditProductDialog component.
Expand Down
5 changes: 2 additions & 3 deletions components/EditUserRoleDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@ import { UserCardProps } from "./UserCard";
import Snackbar from "@mui/material/Snackbar";
import Alert, { AlertColor } from "@mui/material/Alert";
import { useMediaQuery, useTheme } from "@mui/material";
// WARNING: You won't be able to connect to local backend unless you remove the env variable below.
const URL =
process.env.BELINDAS_CLOSET_PUBLIC_API_URL || "http://localhost:3000/api";

const URL = process.env.BELINDAS_CLOSET_PUBLIC_API_URL;

const options = ["admin", "creator", "user"];

Expand Down
5 changes: 2 additions & 3 deletions components/ProductCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@ import { Stack, Button, Link, useTheme, useMediaQuery } from "@mui/material";
import Image from "next/image";
import DeleteIcon from "@mui/icons-material/Delete";
import ArchiveIcon from "@mui/icons-material/Archive";
// WARNING: You won't be able to connect to local backend unless you remove the env variable below.
const URL =
process.env.BELINDAS_CLOSET_PUBLIC_API_URL || "http://localhost:3000/api";

const URL = process.env.BELINDAS_CLOSET_PUBLIC_API_URL;

type ProductCardProps = {
image: StaticImageData;
Expand Down
4 changes: 2 additions & 2 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ const nextConfig = {
distDir: "build",
//reactStrictMode: false, // Uncomment to test API behavior using front-end
env: {
// variable call would be process.env.BELINDAS_CLOSET_PUBLIC_API_URL,
BELINDAS_CLOSET_PUBLIC_API_URL: "https://belindascloset.com/api",
// Check env.local file to update API address
BELINDAS_CLOSET_PUBLIC_API_URL: process.env.API_URL,
},
};

Expand Down
Loading