feat: first commit
parent
b828d8b9bd
commit
ee85841911
|
@ -1,8 +1,13 @@
|
|||
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
|
||||
JWT_SECRET_KEY=sua_chave_supersecreta
|
||||
MYSQL_HOST=1172.31.187.150
|
||||
MYSQL_PORT=3306
|
||||
MYSQL_USER=root
|
||||
MYSQL_PASS=AOSJFOSIDUJ
|
||||
|
||||
SECRET_KEY=ay93nO1KqLgPp6FXfB5W8vZtQeRmTs2uXn0dA7cVjYgHkLz1
|
||||
JWT_SECRET_KEY=Ue4qXs9YdCvApMfTzK3gLb2WoJhNxVa6QrEiStBpHgZoKu7j
|
||||
JWT_ACCESS_TOKEN_EXPIRES_DAYS=15
|
|
@ -6,12 +6,21 @@ load_dotenv()
|
|||
|
||||
class Config:
|
||||
PORT = os.getenv("PORT", 8001)
|
||||
|
||||
DEBUG = True
|
||||
TESTING = False
|
||||
SECRET_KEY = os.getenv("SECRET_KEY", "default-secret-key")
|
||||
|
||||
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_ACCESS_TOKEN_EXPIRES = timedelta(days=int(os.getenv("JWT_ACCESS_TOKEN_EXPIRES_DAYS", 1)))
|
||||
|
||||
FRONTEND_URL = os.getenv("FRONTEND_URL", 3000)
|
||||
|
||||
|
||||
|
|
|
@ -1,19 +1,8 @@
|
|||
from app.config import Config
|
||||
from sqlalchemy import create_engine
|
||||
from sqlalchemy.orm import sessionmaker, scoped_session
|
||||
from urllib.parse import quote_plus
|
||||
|
||||
def get_engine_for_company(company_id: str):
|
||||
schema = f"hitpbx_{company_id}"
|
||||
user = "appuser"
|
||||
password = quote_plus("nmvP$x23Vzb@T%Su")
|
||||
|
||||
# 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
|
||||
def get_engine_for_company(company_id: str):
|
||||
schema = f"hitpbx_{company_id}"
|
||||
db_url = f"mysql+pymysql://{Config.MYSQL_USER}:{quote_plus(Config.MYSQL_PASS)}@{Config.MYSQL_HOST}:{Config.MYSQL_PORT}/{schema}?charset=utf8mb4"
|
||||
return create_engine(db_url, pool_pre_ping=True)
|
|
@ -4,15 +4,13 @@ import { useEffect, useState } from "react"
|
|||
import { useRouter } from "next/navigation"
|
||||
import LoginForm from "@/components/login-form"
|
||||
|
||||
export default function HomePage() {
|
||||
const [isAuthenticated, setIsAuthenticated] = useState(false)
|
||||
export default function HomePage() {
|
||||
const [isLoading, setIsLoading] = useState(true)
|
||||
const router = useRouter()
|
||||
|
||||
useEffect(() => {
|
||||
const token = localStorage.getItem("access_token")
|
||||
if (token) {
|
||||
setIsAuthenticated(true)
|
||||
if (token) {
|
||||
router.push("/dashboard")
|
||||
} else {
|
||||
setIsLoading(false)
|
||||
|
|
|
@ -38,6 +38,16 @@ interface CostUpdateResponse {
|
|||
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() {
|
||||
const [isLoading, setIsLoading] = useState(false)
|
||||
const [isLoadingData, setIsLoadingData] = useState(false)
|
||||
|
@ -106,6 +116,7 @@ export default function CostUpdateForm() {
|
|||
setError(errorData.message || "Erro ao buscar dados dos modelos")
|
||||
}
|
||||
} catch (err) {
|
||||
console.log("Erro de conexão com o servidor: ",err)
|
||||
setError("Erro de conexão com o servidor")
|
||||
} finally {
|
||||
setIsLoadingData(false)
|
||||
|
@ -133,7 +144,7 @@ export default function CostUpdateForm() {
|
|||
.filter((id) => id.length > 0)
|
||||
}
|
||||
|
||||
const payload: any = {
|
||||
const payload: CostUpdatePayload = {
|
||||
product: formData.product,
|
||||
start_date: formData.start_date,
|
||||
end_date: formData.end_date,
|
||||
|
@ -172,6 +183,7 @@ export default function CostUpdateForm() {
|
|||
setError(errorData.message || "Erro ao atualizar custos")
|
||||
}
|
||||
} catch (err) {
|
||||
console.log("====> Erro de conexão com o servidor: ", err)
|
||||
setError("Erro de conexão com o servidor")
|
||||
} finally {
|
||||
setIsLoading(false)
|
||||
|
|
|
@ -49,6 +49,7 @@ export default function LoginForm() {
|
|||
setError(data.message || "Erro ao fazer login")
|
||||
}
|
||||
} catch (err) {
|
||||
console.log("====> Erro de conexão com o servidor: ",err)
|
||||
setError("Erro de conexão com o servidor")
|
||||
} finally {
|
||||
setIsLoading(false)
|
||||
|
@ -82,6 +83,7 @@ export default function LoginForm() {
|
|||
setError(data.message || "Erro ao criar usuário")
|
||||
}
|
||||
} catch (err) {
|
||||
console.log("====> Erro de conexão com o servidor: ", err)
|
||||
setError("Erro de conexão com o servidor")
|
||||
} finally {
|
||||
setIsLoading(false)
|
||||
|
|
|
@ -106,6 +106,7 @@ export default function ModelPricesTable() {
|
|||
setError(errorData.message || "Erro ao buscar dados")
|
||||
}
|
||||
} catch (err) {
|
||||
console.log("====> Erro de conexão com o servidor: ", err)
|
||||
setError("Erro de conexão com o servidor")
|
||||
} finally {
|
||||
setIsLoading(false)
|
||||
|
@ -181,6 +182,7 @@ export default function ModelPricesTable() {
|
|||
setError(errorData.message || "Erro ao salvar alterações")
|
||||
}
|
||||
} catch (err) {
|
||||
console.log("====> Erro de conexão com o servidor: ", err)
|
||||
setError("Erro de conexão com o servidor")
|
||||
} finally {
|
||||
setIsSaving(false)
|
||||
|
|
|
@ -127,6 +127,7 @@ export default function TranscriptionTable() {
|
|||
setError(errorData.message || "Erro ao buscar dados")
|
||||
}
|
||||
} catch (err) {
|
||||
console.log("====> Erro de conexão com o servidor: ", err)
|
||||
setError("Erro de conexão com o servidor")
|
||||
} finally {
|
||||
setIsLoading(false)
|
||||
|
@ -169,6 +170,7 @@ export default function TranscriptionTable() {
|
|||
setError(errorData.message || "Erro ao exportar dados")
|
||||
}
|
||||
} catch (err) {
|
||||
console.log("====> Erro de conexão com o servidor: ", err)
|
||||
setError("Erro de conexão com o servidor")
|
||||
} finally {
|
||||
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