feat: first commit
parent
b828d8b9bd
commit
ee85841911
|
@ -1,8 +1,13 @@
|
||||||
PORT=5000
|
PORT=5000
|
||||||
FRONTEND_URL=http://localhost:3000
|
FRONTEND_URL=http://localhost:9008
|
||||||
|
|
||||||
MONGO_URI=mongodb://admin:SODIOXX98*@172.31.187.24:27017
|
MONGO_URI=mongodb://admin:aisjdnsk*@172.31.187.24:27017
|
||||||
|
|
||||||
SECRET_KEY=TESTPSOJDFPSODIJFPDSJP
|
MYSQL_HOST=1172.31.187.150
|
||||||
JWT_SECRET_KEY=sua_chave_supersecreta
|
MYSQL_PORT=3306
|
||||||
|
MYSQL_USER=root
|
||||||
|
MYSQL_PASS=AOSJFOSIDUJ
|
||||||
|
|
||||||
|
SECRET_KEY=ay93nO1KqLgPp6FXfB5W8vZtQeRmTs2uXn0dA7cVjYgHkLz1
|
||||||
|
JWT_SECRET_KEY=Ue4qXs9YdCvApMfTzK3gLb2WoJhNxVa6QrEiStBpHgZoKu7j
|
||||||
JWT_ACCESS_TOKEN_EXPIRES_DAYS=15
|
JWT_ACCESS_TOKEN_EXPIRES_DAYS=15
|
|
@ -6,12 +6,21 @@ load_dotenv()
|
||||||
|
|
||||||
class Config:
|
class Config:
|
||||||
PORT = os.getenv("PORT", 8001)
|
PORT = os.getenv("PORT", 8001)
|
||||||
|
|
||||||
DEBUG = True
|
DEBUG = True
|
||||||
TESTING = False
|
TESTING = False
|
||||||
SECRET_KEY = os.getenv("SECRET_KEY", "default-secret-key")
|
|
||||||
MONGO_URI = os.getenv("MONGO_URI")
|
MONGO_URI = os.getenv("MONGO_URI")
|
||||||
|
|
||||||
|
MYSQL_HOST = os.getenv("MYSQL_HOST")
|
||||||
|
MYSQL_PORT = os.getenv("MYSQL_PORT","3306")
|
||||||
|
MYSQL_USER = os.getenv("MYSQL_USER")
|
||||||
|
MYSQL_PASS = os.getenv("MYSQL_PASS")
|
||||||
|
|
||||||
|
SECRET_KEY = os.getenv("SECRET_KEY", "default-secret-key")
|
||||||
JWT_SECRET_KEY = os.getenv("JWT_SECRET_KEY", "chave_secreta")
|
JWT_SECRET_KEY = os.getenv("JWT_SECRET_KEY", "chave_secreta")
|
||||||
JWT_ACCESS_TOKEN_EXPIRES = timedelta(days=int(os.getenv("JWT_ACCESS_TOKEN_EXPIRES_DAYS", 1)))
|
JWT_ACCESS_TOKEN_EXPIRES = timedelta(days=int(os.getenv("JWT_ACCESS_TOKEN_EXPIRES_DAYS", 1)))
|
||||||
|
|
||||||
FRONTEND_URL = os.getenv("FRONTEND_URL", 3000)
|
FRONTEND_URL = os.getenv("FRONTEND_URL", 3000)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,19 +1,8 @@
|
||||||
|
from app.config import Config
|
||||||
from sqlalchemy import create_engine
|
from sqlalchemy import create_engine
|
||||||
from sqlalchemy.orm import sessionmaker, scoped_session
|
|
||||||
from urllib.parse import quote_plus
|
from urllib.parse import quote_plus
|
||||||
|
|
||||||
def get_engine_for_company(company_id: str):
|
def get_engine_for_company(company_id: str):
|
||||||
schema = f"hitpbx_{company_id}"
|
schema = f"hitpbx_{company_id}"
|
||||||
user = "appuser"
|
db_url = f"mysql+pymysql://{Config.MYSQL_USER}:{quote_plus(Config.MYSQL_PASS)}@{Config.MYSQL_HOST}:{Config.MYSQL_PORT}/{schema}?charset=utf8mb4"
|
||||||
password = quote_plus("nmvP$x23Vzb@T%Su")
|
return create_engine(db_url, pool_pre_ping=True)
|
||||||
|
|
||||||
# Dev
|
|
||||||
# db_url = f"mysql+pymysql://root:mypass@127.0.0.1:3307/{schema}?charset=utf8mb4"
|
|
||||||
|
|
||||||
db_url = f"mysql+pymysql://{user}:{password}@172.31.187.150:6033/{schema}?charset=utf8mb4"
|
|
||||||
return create_engine(db_url, pool_pre_ping=True)
|
|
||||||
|
|
||||||
def get_session_for_company(company_id):
|
|
||||||
engine = get_engine_for_company(company_id)
|
|
||||||
Session = scoped_session(sessionmaker(bind=engine))
|
|
||||||
return Session
|
|
|
@ -4,15 +4,13 @@ import { useEffect, useState } from "react"
|
||||||
import { useRouter } from "next/navigation"
|
import { useRouter } from "next/navigation"
|
||||||
import LoginForm from "@/components/login-form"
|
import LoginForm from "@/components/login-form"
|
||||||
|
|
||||||
export default function HomePage() {
|
export default function HomePage() {
|
||||||
const [isAuthenticated, setIsAuthenticated] = useState(false)
|
|
||||||
const [isLoading, setIsLoading] = useState(true)
|
const [isLoading, setIsLoading] = useState(true)
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const token = localStorage.getItem("access_token")
|
const token = localStorage.getItem("access_token")
|
||||||
if (token) {
|
if (token) {
|
||||||
setIsAuthenticated(true)
|
|
||||||
router.push("/dashboard")
|
router.push("/dashboard")
|
||||||
} else {
|
} else {
|
||||||
setIsLoading(false)
|
setIsLoading(false)
|
||||||
|
|
|
@ -38,6 +38,16 @@ interface CostUpdateResponse {
|
||||||
docs_updated: number
|
docs_updated: number
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface CostUpdatePayload {
|
||||||
|
product: string
|
||||||
|
start_date: string
|
||||||
|
end_date: string
|
||||||
|
price: string
|
||||||
|
billing_unit: number
|
||||||
|
company_ids?: string[]
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
export default function CostUpdateForm() {
|
export default function CostUpdateForm() {
|
||||||
const [isLoading, setIsLoading] = useState(false)
|
const [isLoading, setIsLoading] = useState(false)
|
||||||
const [isLoadingData, setIsLoadingData] = useState(false)
|
const [isLoadingData, setIsLoadingData] = useState(false)
|
||||||
|
@ -106,6 +116,7 @@ export default function CostUpdateForm() {
|
||||||
setError(errorData.message || "Erro ao buscar dados dos modelos")
|
setError(errorData.message || "Erro ao buscar dados dos modelos")
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
console.log("Erro de conexão com o servidor: ",err)
|
||||||
setError("Erro de conexão com o servidor")
|
setError("Erro de conexão com o servidor")
|
||||||
} finally {
|
} finally {
|
||||||
setIsLoadingData(false)
|
setIsLoadingData(false)
|
||||||
|
@ -133,7 +144,7 @@ export default function CostUpdateForm() {
|
||||||
.filter((id) => id.length > 0)
|
.filter((id) => id.length > 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
const payload: any = {
|
const payload: CostUpdatePayload = {
|
||||||
product: formData.product,
|
product: formData.product,
|
||||||
start_date: formData.start_date,
|
start_date: formData.start_date,
|
||||||
end_date: formData.end_date,
|
end_date: formData.end_date,
|
||||||
|
@ -172,6 +183,7 @@ export default function CostUpdateForm() {
|
||||||
setError(errorData.message || "Erro ao atualizar custos")
|
setError(errorData.message || "Erro ao atualizar custos")
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
console.log("====> Erro de conexão com o servidor: ", err)
|
||||||
setError("Erro de conexão com o servidor")
|
setError("Erro de conexão com o servidor")
|
||||||
} finally {
|
} finally {
|
||||||
setIsLoading(false)
|
setIsLoading(false)
|
||||||
|
|
|
@ -49,6 +49,7 @@ export default function LoginForm() {
|
||||||
setError(data.message || "Erro ao fazer login")
|
setError(data.message || "Erro ao fazer login")
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
console.log("====> Erro de conexão com o servidor: ",err)
|
||||||
setError("Erro de conexão com o servidor")
|
setError("Erro de conexão com o servidor")
|
||||||
} finally {
|
} finally {
|
||||||
setIsLoading(false)
|
setIsLoading(false)
|
||||||
|
@ -82,6 +83,7 @@ export default function LoginForm() {
|
||||||
setError(data.message || "Erro ao criar usuário")
|
setError(data.message || "Erro ao criar usuário")
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
console.log("====> Erro de conexão com o servidor: ", err)
|
||||||
setError("Erro de conexão com o servidor")
|
setError("Erro de conexão com o servidor")
|
||||||
} finally {
|
} finally {
|
||||||
setIsLoading(false)
|
setIsLoading(false)
|
||||||
|
|
|
@ -106,6 +106,7 @@ export default function ModelPricesTable() {
|
||||||
setError(errorData.message || "Erro ao buscar dados")
|
setError(errorData.message || "Erro ao buscar dados")
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
console.log("====> Erro de conexão com o servidor: ", err)
|
||||||
setError("Erro de conexão com o servidor")
|
setError("Erro de conexão com o servidor")
|
||||||
} finally {
|
} finally {
|
||||||
setIsLoading(false)
|
setIsLoading(false)
|
||||||
|
@ -181,6 +182,7 @@ export default function ModelPricesTable() {
|
||||||
setError(errorData.message || "Erro ao salvar alterações")
|
setError(errorData.message || "Erro ao salvar alterações")
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
console.log("====> Erro de conexão com o servidor: ", err)
|
||||||
setError("Erro de conexão com o servidor")
|
setError("Erro de conexão com o servidor")
|
||||||
} finally {
|
} finally {
|
||||||
setIsSaving(false)
|
setIsSaving(false)
|
||||||
|
|
|
@ -127,6 +127,7 @@ export default function TranscriptionTable() {
|
||||||
setError(errorData.message || "Erro ao buscar dados")
|
setError(errorData.message || "Erro ao buscar dados")
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
console.log("====> Erro de conexão com o servidor: ", err)
|
||||||
setError("Erro de conexão com o servidor")
|
setError("Erro de conexão com o servidor")
|
||||||
} finally {
|
} finally {
|
||||||
setIsLoading(false)
|
setIsLoading(false)
|
||||||
|
@ -169,6 +170,7 @@ export default function TranscriptionTable() {
|
||||||
setError(errorData.message || "Erro ao exportar dados")
|
setError(errorData.message || "Erro ao exportar dados")
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
console.log("====> Erro de conexão com o servidor: ", err)
|
||||||
setError("Erro de conexão com o servidor")
|
setError("Erro de conexão com o servidor")
|
||||||
} finally {
|
} finally {
|
||||||
setIsExporting(false)
|
setIsExporting(false)
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
module.exports = {
|
||||||
|
apps: [
|
||||||
|
{
|
||||||
|
name: "frontend-transcription",
|
||||||
|
script: "npm",
|
||||||
|
args: "run start",
|
||||||
|
env: {
|
||||||
|
PORT: 9008,
|
||||||
|
NODE_ENV: "production"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
Loading…
Reference in New Issue