Merge pull request #59 from TurTaskProject/frontend-production

Deploy on vercel
This commit is contained in:
Sirin Puenggun 2023-11-22 23:22:00 +07:00 committed by GitHub
commit 71f0a9f654
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 34 additions and 25 deletions

View File

@ -1,20 +1,17 @@
module.exports = { module.exports = {
root: true, root: true,
env: { browser: true, es2020: true }, env: { browser: true, es2020: true, node: true },
extends: [ extends: [
'eslint:recommended', "eslint:recommended",
'plugin:react/recommended', "plugin:react/recommended",
'plugin:react/jsx-runtime', "plugin:react/jsx-runtime",
'plugin:react-hooks/recommended', "plugin:react-hooks/recommended",
], ],
ignorePatterns: ['dist', '.eslintrc.cjs'], ignorePatterns: ["dist", ".eslintrc.cjs"],
parserOptions: { ecmaVersion: 'latest', sourceType: 'module' }, parserOptions: { ecmaVersion: "latest", sourceType: "module" },
settings: { react: { version: '18.2' } }, settings: { react: { version: "18.2" } },
plugins: ['react-refresh'], plugins: ["react-refresh"],
rules: { rules: {
'react-refresh/only-export-components': [ "react-refresh/only-export-components": ["warn", { allowConstantExport: true }],
'warn',
{ allowConstantExport: true },
],
}, },
} };

View File

@ -16,6 +16,8 @@ import Dashboard from "./components/dashboard/dashboard";
import { useAuth } from "./hooks/AuthHooks"; import { useAuth } from "./hooks/AuthHooks";
const baseURL = import.meta.env.VITE_BASE_URL;
const App = () => { const App = () => {
const { isAuthenticated, setIsAuthenticated } = useAuth(); const { isAuthenticated, setIsAuthenticated } = useAuth();
@ -27,7 +29,7 @@ const App = () => {
}; };
await axios await axios
.post("http://127.0.0.1:8000/api/auth/status/", data, { .post(`${baseURL}auth/status/`, data, {
headers: { headers: {
Authorization: "Bearer " + localStorage.getItem("access_token"), Authorization: "Bearer " + localStorage.getItem("access_token"),
}, },

View File

@ -1,6 +1,8 @@
import axios from "axios"; import axios from "axios";
import axiosInstance from "./AxiosConfig"; import axiosInstance from "./AxiosConfig";
const baseURL = import.meta.env.VITE_BASE_URL;
// Function for user login // Function for user login
const apiUserLogin = (data) => { const apiUserLogin = (data) => {
return axiosInstance return axiosInstance
@ -26,7 +28,7 @@ const apiUserLogout = () => {
// Function for Google login // Function for Google login
const googleLogin = async (token) => { const googleLogin = async (token) => {
axios.defaults.withCredentials = true; axios.defaults.withCredentials = true;
let res = await axios.post("http://localhost:8000/api/auth/google/", { let res = await axios.post(`${baseURL}auth/google/`, {
code: token, code: token,
}); });
// console.log('service google login res: ', res); // console.log('service google login res: ', res);
@ -49,7 +51,7 @@ const getGreeting = () => {
const createUser = async (formData) => { const createUser = async (formData) => {
try { try {
axios.defaults.withCredentials = true; axios.defaults.withCredentials = true;
const response = axios.post("http://localhost:8000/api/user/create/", formData); const response = axios.post(`${baseURL}user/create/`, formData);
// const response = await axiosInstance.post('/user/create/', formData); // const response = await axiosInstance.post('/user/create/', formData);
return response.data; return response.data;
} catch (e) { } catch (e) {

View File

@ -1,8 +1,10 @@
import axios from "axios"; import axios from "axios";
import { redirect } from "react-router-dom"; import { redirect } from "react-router-dom";
const baseURL = import.meta.env.VITE_BASE_URL;
const axiosInstance = axios.create({ const axiosInstance = axios.create({
baseURL: "http://127.0.0.1:8000/api/", baseURL: baseURL,
timeout: 5000, timeout: 5000,
headers: { headers: {
Authorization: "Bearer " + localStorage.getItem("access_token"), Authorization: "Bearer " + localStorage.getItem("access_token"),

View File

@ -1,6 +1,6 @@
import axiosInstance from "src/api/AxiosConfig"; import axiosInstance from "src/api/AxiosConfig";
const baseURL = ""; const baseURL = import.meta.env.VITE_BASE_URL;
export const createTask = (endpoint, data) => { export const createTask = (endpoint, data) => {
return axiosInstance return axiosInstance

View File

@ -1,8 +1,10 @@
import axios from "axios"; import axios from "axios";
const ApiUpdateUserProfile = async formData => { const baseURL = import.meta.env.VITE_BASE_URL;
const ApiUpdateUserProfile = async (formData) => {
try { try {
const response = await axios.post("http://127.0.1:8000/api/user/update/", formData, { const response = await axios.post(`${baseURL}user/update/`, formData, {
headers: { headers: {
Authorization: "Bearer " + localStorage.getItem("access_token"), Authorization: "Bearer " + localStorage.getItem("access_token"),
"Content-Type": "multipart/form-data", "Content-Type": "multipart/form-data",

View File

@ -4,7 +4,7 @@ import { useGoogleLogin } from "@react-oauth/google";
import { useCallback } from "react"; import { useCallback } from "react";
import Particles from "react-tsparticles"; import Particles from "react-tsparticles";
import { loadFull } from "tsparticles"; import { loadFull } from "tsparticles";
import refreshAccessToken from "./refreshAcesstoken"; import refreshAccessToken from "./refreshAcessToken";
import axiosapi from "../../api/AuthenticationApi"; import axiosapi from "../../api/AuthenticationApi";
import { FcGoogle } from "react-icons/fc"; import { FcGoogle } from "react-icons/fc";
import { useAuth } from "src/hooks/AuthHooks"; import { useAuth } from "src/hooks/AuthHooks";

View File

@ -1,5 +1,7 @@
import axios from "axios"; import axios from "axios";
const baseURL = import.meta.env.VITE_BASE_URL;
async function refreshAccessToken() { async function refreshAccessToken() {
const refresh_token = localStorage.getItem("refresh_token"); const refresh_token = localStorage.getItem("refresh_token");
const access_token = localStorage.getItem("access_token"); const access_token = localStorage.getItem("access_token");
@ -12,7 +14,7 @@ async function refreshAccessToken() {
return false; return false;
} }
const refreshUrl = "http://127.0.0.1:8000/api/token/refresh/"; const refreshUrl = `${baseURL}token/refresh/`;
try { try {
const response = await axios.post(refreshUrl, { refresh: refresh_token }); const response = await axios.post(refreshUrl, { refresh: refresh_token });

View File

@ -10,7 +10,7 @@ import {
Title, Title,
Legend, Legend,
} from "@tremor/react"; } from "@tremor/react";
import KpiCard from "./kpiCard"; import KpiCard from "./KpiCard";
import { BarChartGraph } from "./Barchart"; import { BarChartGraph } from "./Barchart";
import DonutChartGraph from "./DonutChart"; import DonutChartGraph from "./DonutChart";
import { AreaChartGraph } from "./Areachart"; import { AreaChartGraph } from "./Areachart";

View File

@ -1,7 +1,6 @@
import { defineConfig } from "vite"; import { defineConfig } from "vite";
import react from "@vitejs/plugin-react"; import react from "@vitejs/plugin-react";
// https://vitejs.dev/config/
export default defineConfig({ export default defineConfig({
plugins: [react()], plugins: [react()],
resolve: { resolve: {
@ -9,4 +8,7 @@ export default defineConfig({
src: "/src", src: "/src",
}, },
}, },
define: {
__APP_ENV__: process.env.VITE_VERCEL_ENV,
},
}); });