diff --git a/next/components/molecules/ColumnsTable.js b/next/components/molecules/ColumnsTable.js
index a5e93a4d..73f82c86 100644
--- a/next/components/molecules/ColumnsTable.js
+++ b/next/components/molecules/ColumnsTable.js
@@ -260,6 +260,7 @@ export default function ColumnsTable({
if(result?.error) return
let cloudTables = result?.cloudTables?.edges[0]?.node
+ const downloadInfo = HasDownloadPermitted(result?.uncompressedFileSize)
triggerGAEvent("download_da_tabela",`{
gcp: ${cloudTables?.gcpProjectId+"."+cloudTables?.gcpDatasetId+"."+cloudTables?.gcpTableId},
@@ -268,7 +269,8 @@ export default function ColumnsTable({
table: ${resource?._id},
columnDownload: true
}`)
- window.open(`https://storage.googleapis.com/basedosdados-public/one-click-download/${cloudTables?.gcpDatasetId}/${cloudTables?.gcpTableId}/${cloudTables?.gcpTableId}.csv.gz`)
+
+ window.open(`/api/tables/downloadTable?p=${btoa(cloudTables?.gcpDatasetId)}&q=${btoa(cloudTables?.gcpTableId)}&d=${btoa(downloadInfo.downloadPermitted)}&s=${btoa(downloadInfo.downloadWarning)}`)
}
return (
@@ -305,15 +307,13 @@ export default function ColumnsTable({
const datasetName = value?.table?.dataset?.name || ""
const tableName = value?.table?.name || ""
-
+
if(gcpDatasetID === "br_bd_diretorios_data_tempo") return "Não precisa de tradução"
if(gcpDatasetID === "br_bd_diretorios_brasil") {
if(gcpTableId === "empresa" || gcpTableId === "cep") return "Não precisa de tradução"
}
if(value?.name === "ddd") return "Não precisa de tradução"
- const downloadUrl = `https://storage.googleapis.com/basedosdados-public/one-click-download/${gcpDatasetID}/${gcpTableId}/${gcpTableId}.csv.gz`
-
return (
{value === null ?
@@ -325,7 +325,10 @@ export default function ColumnsTable({
{
if(!downloadInfo.downloadPermitted) return
diff --git a/next/components/molecules/DataInformationQuery.js b/next/components/molecules/DataInformationQuery.js
index 058a9e80..80a1b2fa 100644
--- a/next/components/molecules/DataInformationQuery.js
+++ b/next/components/molecules/DataInformationQuery.js
@@ -171,7 +171,8 @@ export function CodeHighlight({ language, children }) {
export default function DataInformationQuery({ resource }) {
const [tabAccessIndex, setTabAccessIndex] = useState(0)
const [tabIndex, setTabIndex] = useState(0)
- const [downloadNotAllowed, setDownloadNotAllowed] = useState(false)
+ const [downloadPermitted, setDownloadPermitted] = useState(false)
+ const [downloadWarning, setDownloadWarning] = useState("")
const [checkedColumns, setCheckedColumns] = useState([])
const [numberColumns, setNumberColumns] = useState(0)
const [columnsTranslationPro, setColumnsTranslationPro] = useState([])
@@ -185,7 +186,6 @@ export default function DataInformationQuery({ resource }) {
const [gcpProjectID, setGcpProjectID] = useState("")
const [gcpDatasetID, setGcpDatasetID] = useState("")
const [gcpTableId, setGcpTableId] = useState("")
- const [downloadUrl, setDownloadUrl] = useState("")
const isUserPro = () => {
let user
@@ -200,21 +200,27 @@ export default function DataInformationQuery({ resource }) {
}, [resource.dataset])
useEffect(() => {
- if (resource?.numberRows === 0) setDownloadNotAllowed(false)
- if (resource?.numberRows) resource?.numberRows > 200000 ? setDownloadNotAllowed(false) : setDownloadNotAllowed(true)
-
+ if (resource?.uncompressedFileSize) {
+ const limit100MB = 100 * 1024 * 1024;
+ const limit1GB = 1 * 1024 * 1024 * 1024;
+
+ if (resource?.uncompressedFileSize < limit100MB) {
+ setDownloadPermitted(true)
+ setDownloadWarning("free")
+ } else if (resource?.uncompressedFileSize < limit1GB) {
+ setDownloadPermitted(isUserPro())
+ setDownloadWarning("100mbBetween1gb")
+ } else {
+ setDownloadWarning("biggest1gb")
+ }
+ }
+
if (resource?.cloudTables?.[0]) {
setGcpProjectID(resource.cloudTables[0]?.gcpProjectId || "")
setGcpDatasetID(resource.cloudTables[0]?.gcpDatasetId || "")
setGcpTableId(resource.cloudTables[0]?.gcpTableId || "")
}
-
- if (gcpDatasetID) {
- if (gcpTableId) {
- setDownloadUrl(`https://storage.googleapis.com/basedosdados-public/one-click-download/${gcpDatasetID}/${gcpTableId}/${gcpTableId}.csv.gz`)
- }
- }
- }, [resource.numberRows, resource.cloudTables])
+ }, [resource.uncompressedFileSize, resource.cloudTables])
useEffect(() => {
if(resource._id === undefined) return
@@ -516,8 +522,7 @@ export default function DataInformationQuery({ resource }) {
marginTop="16px"
padding={0}
>
- {downloadNotAllowed ?
- isUserPro() ? "" :
+ {isUserPro() === false && downloadWarning === "free" &&
Estes dados estão disponíveis porque diversas pessoas colaboram para a sua manutenção.
Antes de baixar os dados, apoie você também com uma doação financeira ou
@@ -532,33 +537,50 @@ export default function DataInformationQuery({ resource }) {
saiba como contribuir com seu tempo.
- :
+ }
+ {isUserPro() === false && downloadWarning === "100mbBetween1gb" &&
+
+ O download de tabelas com tamanho entre 100 MB e 1 GB está disponível apenas para
+ assinantes dos nossos planos pagos
+ . No entanto, você pode acessar a tabela gratuitamente utilizando SQL, Python, R ou Stata. Considere atualizar para um plano pago para fazer o download.
+
+ }
+ {downloadWarning === "biggest1gb" &&
}
{ triggerGAEvent("download_da_tabela",`
- {
+ href={`/api/tables/downloadTable?p=${btoa(gcpDatasetID)}&q=${btoa(gcpTableId)}&d=${btoa(downloadPermitted)}&s=${btoa(downloadWarning)}`}
+ target="_blank"
+ onClick={() => {
+ triggerGAEvent("download_da_tabela",`{
gcp: ${gcpProjectID+"."+gcpDatasetID+"."+gcpTableId},
tamanho: ${formatBytes(resource.uncompressedFileSize) || ""},
dataset: ${resource?.dataset?._id},
table: ${resource?._id},
- }`
- ) }}
- target="_blank"
+ }`)
+ }}
display="flex"
alignItems="center"
height="40px"
width="fit-content"
borderRadius="8px"
- backgroundColor={downloadNotAllowed ? "#2B8C4D" : "#ACAEB1"}
+ backgroundColor={downloadPermitted ? "#2B8C4D" : "#ACAEB1"}
padding="8px 16px"
- cursor={downloadNotAllowed ? "pointer" : "default"}
+ cursor={downloadPermitted ? "pointer" : "default"}
color="#FFF"
fill="#FFF"
fontFamily="Roboto"
@@ -566,7 +588,7 @@ export default function DataInformationQuery({ resource }) {
fontSize="14px"
gap="8px"
lineHeight="20px"
- pointerEvents={downloadNotAllowed ? "default" : "none"}
+ pointerEvents={downloadPermitted ? "default" : "none"}
_hover={{
backgroundColor: "#22703E"
}}
@@ -575,7 +597,7 @@ export default function DataInformationQuery({ resource }) {
width="24px"
height="24px"
/>
- Download da tabela {downloadNotAllowed && `(${formatBytes(resource.uncompressedFileSize)})`}
+ Download da tabela {downloadPermitted && `(${formatBytes(resource.uncompressedFileSize)})`}
@@ -852,8 +874,8 @@ bd.read_sql(query = query, billing_project_id = billing_id)`}
isLoaded={!isLoadingCode}
>
{`
-# Defina o seu projeto no Google Cloud
-set_billing_id("")
+ # Defina o seu projeto no Google Cloud
+ set_billing_id("")
# Para carregar o dado direto no R
query <- "
diff --git a/next/components/organisms/BdmTablePage.js b/next/components/organisms/BdmTablePage.js
index 78b428aa..03512e10 100644
--- a/next/components/organisms/BdmTablePage.js
+++ b/next/components/organisms/BdmTablePage.js
@@ -196,16 +196,16 @@ export default function BdmTablePage({ id }) {
let formats
{yearFrequency ?
formats = {
- "second":`Atualização a cada ${frequency} por segundo`,
- "minute":`Atualização a cada ${frequency} por minuto`,
- "hour":`Atualização a cada ${frequency} por hora`,
- "day":`Atualização a cada ${frequency} diária`,
- "week":`Atualização a cada ${frequency} semanal`,
- "month":`Atualização a cada ${frequency} mensal`,
- "bimester":`Atualização a cada ${frequency} bimestral`,
- "quarter":`Atualização a cada ${frequency} trimestral`,
- "semester":`Atualização a cada ${frequency} semestral`,
- "year":`Atualização a cada ${frequency} anual`,
+ "second":`Atualização a cada ${frequency} segundos`,
+ "minute":`Atualização a cada ${frequency} minutos`,
+ "hour":`Atualização a cada ${frequency} horas`,
+ "day":`Atualização a cada ${frequency} dias`,
+ "week":`Atualização a cada ${frequency} semanas`,
+ "month":`Atualização a cada ${frequency} meses`,
+ "bimester":`Atualização a cada ${frequency} bimestres`,
+ "quarter":`Atualização a cada ${frequency} trimestres`,
+ "semester":`Atualização a cada ${frequency} semestres`,
+ "year":`Atualização a cada ${frequency} anos`,
}
:
formats = {
diff --git a/next/components/organisms/PaymentSystem.js b/next/components/organisms/PaymentSystem.js
index 28633997..beb8ac3c 100644
--- a/next/components/organisms/PaymentSystem.js
+++ b/next/components/organisms/PaymentSystem.js
@@ -15,10 +15,6 @@ import {
import Button from "../atoms/RoundedButton";
import styles from "../../styles/paymentSystem.module.css";
-import {
- getPrices,
-} from "../../pages/api/stripe";
-
const stripePromise = loadStripe(process.env.NEXT_PUBLIC_KEY_STRIPE)
const PaymentForm = ({ onSucess, onErro, clientSecret}) => {
@@ -112,24 +108,8 @@ export default function PaymentSystem({ userData, plan, onSucess, onErro }) {
}
}
- async function customerCreat(plan) {
- const prices = await getPrices()
-
- const findPlan = (slug, slots) => {
- const foundPlan = prices.find(p => {
- return p.node.productSlug === slug && p.node.productSlots === slots
- })
-
- return foundPlan ? foundPlan.node : null
- }
-
- const idPlan = findPlan(plan.slug, plan.slots)?._id
-
- customerCreatPost(idPlan)
- }
-
useEffect(() => {
- customerCreat(plan)
+ customerCreatPost(plan.id)
}, [])
const SkeletonBox = ({ type, ...props }) => {
diff --git a/next/pages/api/stripe/getPrices.js b/next/pages/api/stripe/getPlans.js
similarity index 50%
rename from next/pages/api/stripe/getPrices.js
rename to next/pages/api/stripe/getPlans.js
index 7122265c..735e2d8d 100644
--- a/next/pages/api/stripe/getPrices.js
+++ b/next/pages/api/stripe/getPlans.js
@@ -2,7 +2,7 @@ import axios from "axios";
const API_URL= `${process.env.NEXT_PUBLIC_API_URL}/api/v1/graphql`
-export default async function getPrices() {
+async function getPlans() {
try {
const res = await axios({
url: API_URL,
@@ -10,14 +10,15 @@ export default async function getPrices() {
data: {
query: `
query {
- allStripePrice {
+ allStripePrice (active: true) {
edges {
node {
_id
amount
productName
productSlug
- productSlots
+ interval
+ isActive
}
}
}
@@ -25,9 +26,19 @@ export default async function getPrices() {
`
}
})
- const data = res?.data?.data?.allStripePrice?.edges
+ const data = res.data
return data
} catch (error) {
console.error(error)
+ return "err"
}
}
+
+export default async function handler(req, res) {
+ const result = await getPlans()
+
+ if(result.errors) return res.status(500).json({error: result.errors, success: false})
+ if(result === "err") return res.status(500).json({error: "err", success: false})
+
+ res.status(200).json({data: result?.data?.allStripePrice?.edges, success: true})
+}
diff --git a/next/pages/api/stripe/index.js b/next/pages/api/stripe/index.js
deleted file mode 100644
index 2b92c5b1..00000000
--- a/next/pages/api/stripe/index.js
+++ /dev/null
@@ -1,5 +0,0 @@
-import getPrices from "./getPrices";
-
-export {
- getPrices,
-}
diff --git a/next/pages/api/tables/downloadTable.js b/next/pages/api/tables/downloadTable.js
index d2997eb9..dcd8d112 100644
--- a/next/pages/api/tables/downloadTable.js
+++ b/next/pages/api/tables/downloadTable.js
@@ -1,8 +1,32 @@
import axios from "axios";
-async function downloadTable(datasetID, tableId, res) {
+const API_URL= `${process.env.NEXT_PUBLIC_API_URL}/api/v1/graphql`
+
+async function validateToken(token) {
+ try {
+ const res = await axios({
+ url: API_URL,
+ method: "POST",
+ data: { query: ` mutation { verifyToken ( token: "${token}" ) { payload } }`
+ }
+ })
+ const data = res.data?.data?.verifyToken?.payload
+ return data
+ } catch (error) {
+ console.error(error)
+ return "err"
+ }
+}
+
+async function downloadTable(url, datasetID, tableId, token, res) {
+ let payloadToken
+ if(url !== "free" && token !== null) payloadToken = await validateToken(token)
+
try {
- const fileUrl = `https://storage.googleapis.com/basedosdados-public/one-click-download/${datasetID}/${tableId}/${tableId}.csv.gz`
+ const fileUrl = url === "free"
+ ? `${process.env.URL_DOWNLOAD_TABLE}/${datasetID}/${tableId}/${tableId}.csv.gz`
+ : payloadToken?.pro_subscription_status === "active" ? `${process.env.URL_DOWNLOAD_PRIVATE_TABLE}/${datasetID}/${tableId}/${tableId}.csv.gz` : ""
+
const response = await axios({
url: fileUrl,
method: 'GET',
@@ -20,5 +44,9 @@ async function downloadTable(datasetID, tableId, res) {
}
export default async function handler(req, res) {
- return downloadTable(atob(req.query.p), atob(req.query.q), res)
+ const token = req.cookies.token || null
+
+ if(atob(req.query.d) === "false") return res.status(500).json({error: "Você não tem permissão para fazer esse download"})
+
+ return downloadTable(atob(req.query.s), atob(req.query.p), atob(req.query.q), token, res)
}
\ No newline at end of file
diff --git a/next/pages/api/user/validateToken.js b/next/pages/api/user/validateToken.js
index c62ce024..d831f890 100644
--- a/next/pages/api/user/validateToken.js
+++ b/next/pages/api/user/validateToken.js
@@ -3,19 +3,19 @@ import axios from "axios";
const API_URL= `${process.env.NEXT_PUBLIC_API_URL}/api/v1/graphql`
async function validateToken(token) {
- const res = await axios({
- url: API_URL,
- method: "POST",
- data: {
- query: `
- mutation {
- verifyToken ( token: "${token}" ) {
- payload,
- }
- }`
- }
- })
try {
+ const res = await axios({
+ url: API_URL,
+ method: "POST",
+ data: {
+ query: `
+ mutation {
+ verifyToken ( token: "${token}" ) {
+ payload,
+ }
+ }`
+ }
+ })
const data = res.data
return data
} catch (error) {
diff --git a/next/pages/dataset/[dataset].js b/next/pages/dataset/[dataset].js
index 2e6255f8..a07b97fb 100644
--- a/next/pages/dataset/[dataset].js
+++ b/next/pages/dataset/[dataset].js
@@ -182,7 +182,10 @@ export default function DatasetPage ({ dataset }) {
>
Organização
-
+
{dataset?.organization?.name || "Nenhuma organização fornecida."}
-
+
diff --git a/next/pages/precos.js b/next/pages/precos.js
index afce0a7c..6a20884b 100644
--- a/next/pages/precos.js
+++ b/next/pages/precos.js
@@ -297,18 +297,41 @@ export const CardPrice = ({
export default function Price({ username ,isBDPro, isBDEmp }) {
const [toggleAnual, setToggleAnual] = useState(false)
- const [priceBDPro, setPriceBDPro] = useState("47")
- const [priceBDEmp, setPriceBDEmp] = useState("350")
+ const [plans, setPlans] = useState(null)
useEffect(() => {
- if(toggleAnual === true) {
- setPriceBDPro("37")
- setPriceBDEmp("280")
- } else {
- setPriceBDPro("47")
- setPriceBDEmp("350")
+ async function fecthPlans() {
+ try {
+ const result = await fetch(`/api/stripe/getPlans`, { method: "GET" })
+ .then(res => res.json())
+
+ if(result.success === true) {
+ function filterData(productName, interval, isActive) {
+ let array = result.data
+
+ return array.filter(item =>
+ (productName ? item.node.productName === productName : true) &&
+ (interval ? item.node.interval === interval : true) &&
+ (isActive !== undefined ? item.node.isActive === isActive : true)
+ )
+ }
+
+ const filteredPlans = {
+ bd_pro_month : filterData("BD Pro", "month", true)[0].node,
+ bd_pro_year : filterData("BD Pro", "year", true)[0].node,
+ bd_empresas_month : filterData("BD Empresas", "month", true)[0].node,
+ bd_empresas_year : filterData("BD Empresas", "year", true)[0].node
+ }
+
+ setPlans(filteredPlans)
+ }
+ } catch (error) {
+ console.error(error)
+ }
}
- }, [toggleAnual])
+
+ fecthPlans()
+ }, [])
return (
@@ -371,7 +394,7 @@ export default function Price({ username ,isBDPro, isBDEmp }) {
letterSpacing="0.1px"
color="#252A32"
>
- Desconto anual Economize 20%
+ Desconto anual Economize 20%
@@ -407,7 +430,7 @@ export default function Price({ username ,isBDPro, isBDEmp }) {
Para você ter acesso aos
dados mais atualizados>}
- price={priceBDPro}
+ price={plans?.["bd_pro_month"].amount || 47}
anualPlan={toggleAnual}
textResource="Todos os recursos da BD Grátis, mais:"
resources={[
@@ -416,7 +439,7 @@ export default function Price({ username ,isBDPro, isBDEmp }) {
]}
button={{
text: isBDPro ? "Plano atual" : `Iniciar teste grátis`,
- href: username === null ? "/user/login?p=plans&q=pro" :`/user/${username}?plans_and_payment&q=pro`,
+ href: username === null ? `/user/login?q=pro&i=${plans?.["bd_pro_month"]._id}` :`/user/${username}?plans_and_payment&q=pro&i=${plans?.["bd_pro_month"]._id}`,
isCurrentPlan: isBDPro,
}}
/>
@@ -424,7 +447,7 @@ export default function Price({ username ,isBDPro, isBDEmp }) {
Para sua empresa ganhar tempo
e qualidade em decisões>}
- price={priceBDEmp}
+ price={plans?.["bd_empresas_month"].amount || 350}
anualPlan={toggleAnual}
textResource="Todos os recursos da BD Pro, mais:"
resources={[
@@ -433,7 +456,7 @@ export default function Price({ username ,isBDPro, isBDEmp }) {
]}
button={{
text: isBDEmp ? "Plano atual" : "Iniciar teste grátis",
- href: username === null ? "/user/login?p=plans&q=empresas" :`/user/${username}?plans_and_payment&q=empresas`,
+ href: username === null ? `/user/login?q=empresas&i=${plans?.["bd_empresas_month"]._id}` :`/user/${username}?plans_and_payment&q=empresas&i=${plans?.["bd_empresas_month"]._id}`,
isCurrentPlan: isBDEmp,
}}
/>
diff --git a/next/pages/transparencia.js b/next/pages/transparencia.js
index 76a62101..636af6bb 100644
--- a/next/pages/transparencia.js
+++ b/next/pages/transparencia.js
@@ -231,12 +231,12 @@ export default function Transparencia({ pages }) {
gridGap={{ base: "64px", lg: "80px" }}
>
diff --git a/next/pages/user/[username].js b/next/pages/user/[username].js
index 882f009a..43fe3521 100644
--- a/next/pages/user/[username].js
+++ b/next/pages/user/[username].js
@@ -88,9 +88,9 @@ export async function getServerSideProps(context) {
const validateTokenResponse = await fetch(`${process.env.NEXT_PUBLIC_BASE_URL_FRONTEND}/api/user/validateToken?p=${btoa(req.cookies.token)}`, {method: "GET"})
const validateToken = await validateTokenResponse.json()
- if(validateToken.error) {
- const refreshTokenResponse = await fetch(`${process.env.NEXT_PUBLIC_BASE_URL_FRONTEND}/api/user/refreshToken?p=${btoa(req.cookies.token)}`, {method: "GET"})
- const refreshToken = await refreshTokenResponse.json()
+ if(validateToken.error) {
+ const refreshTokenResponse = await fetch(`${process.env.NEXT_PUBLIC_BASE_URL_FRONTEND}/api/user/refreshToken?p=${btoa(req.cookies.token)}`, {method: "GET"})
+ const refreshToken = await refreshTokenResponse.json()
if(refreshToken.error) {
res.setHeader('Set-Cookie', serialize('token', '', {maxAge: -1, path: '/', }))
@@ -128,7 +128,7 @@ export async function getServerSideProps(context) {
return {
props: {
- getUser
+ getUser,
}
}
}
@@ -1450,33 +1450,54 @@ const PlansAndPayment = ({ userData }) => {
const [isLoading, setIsLoading] = useState(false)
const [isLoadingH, setIsLoadingH] = useState(false)
const [isLoadingCanSub, setIsLoadingCanSub] = useState(false)
+
+ const [plans, setPlans] = useState(null)
const [toggleAnual, setToggleAnual] = useState(false)
- const [priceBDPro, setPriceBDPro] = useState("47")
- const [priceBDEmp, setPriceBDEmp] = useState("350")
useEffect(() => {
- if(query.q === "pro") {
- if(userData.proSubscriptionStatus === "active") return AlertChangePlanModal.onOpen()
- setPlan({title: "BD Pro", slug:"bd_pro", slots: "0"})
- PaymentModal.onOpen()
+ if(PlansModal.isOpen === false) return
+
+ async function fecthPlans() {
+ try {
+ const result = await fetch(`/api/stripe/getPlans`, { method: "GET" })
+ .then(res => res.json())
+
+ if(result.success === true) {
+ function filterData(productName, interval, isActive) {
+ let array = result.data
+
+ return array.filter(item =>
+ (productName ? item.node.productName === productName : true) &&
+ (interval ? item.node.interval === interval : true) &&
+ (isActive !== undefined ? item.node.isActive === isActive : true)
+ )
+ }
+
+ const filteredPlans = {
+ bd_pro_month : filterData("BD Pro", "month", true)[0].node,
+ bd_pro_year : filterData("BD Pro", "year", true)[0].node,
+ bd_empresas_month : filterData("BD Empresas", "month", true)[0].node,
+ bd_empresas_year : filterData("BD Empresas", "year", true)[0].node
+ }
+
+ setPlans(filteredPlans)
+ }
+ } catch (error) {
+ console.error(error)
+ }
}
- if(query.q === "empresas") {
+
+ fecthPlans()
+ }, [PlansModal.isOpen])
+
+ useEffect(() => {
+ if(query.i) {
if(userData.proSubscriptionStatus === "active") return AlertChangePlanModal.onOpen()
- setPlan({title: "BD Empresas", slug:"bd_pro_empresas", slots: "10"})
+ setPlan({id: query.i})
PaymentModal.onOpen()
}
}, [query])
- useEffect(() => {
- if(toggleAnual === true) {
- setPriceBDPro("37")
- setPriceBDEmp("280")
- } else {
- setPriceBDPro("47")
- setPriceBDEmp("350")
- }
- }, [toggleAnual])
-
const resources={
"BD Gratis" : {
title: "BD Grátis",
@@ -1597,14 +1618,14 @@ const PlansAndPayment = ({ userData }) => {
setIsLoadingCanSub(false)
}
- do {
- const statusSub = await fetch(`/api/stripe/userGetSubscription?p=${btoa(id)}`, {method: "GET"})
- .then(res => res.json())
- if(statusSub?.proSubscriptionStatus !== "active") {
- break
- }
- await new Promise (resolve => setTimeout(resolve ,1000))
- } while (true)
+ // do {
+ // const statusSub = await fetch(`/api/stripe/userGetSubscription?p=${btoa(id)}`, {method: "GET"})
+ // .then(res => res.json())
+ // if(statusSub?.proSubscriptionStatus !== "active") {
+ // break
+ // }
+ // await new Promise (resolve => setTimeout(resolve ,1000))
+ // } while (true)
const user = await fetch(`/api/user/getUser?p=${btoa(id)}`, {method: "GET"})
.then(res => res.json())
@@ -1943,7 +1964,7 @@ const PlansAndPayment = ({ userData }) => {
Para você ter acesso aos
dados mais atualizados>}
- price={priceBDPro}
+ price={plans?.["bd_pro_month"].amount || 47}
anualPlan={toggleAnual}
textResource="Todos os recursos da BD Grátis, mais:"
resources={[
@@ -1953,7 +1974,7 @@ const PlansAndPayment = ({ userData }) => {
button={{
text: `${userData?.proSubscription === "bd_pro" ? "Plano atual" : "Assinar"}`,
onClick: userData?.proSubscription === "bd_pro" ? () => {} : () => {
- setPlan({title: "BD Pro", slug:"bd_pro", slots: "0"})
+ setPlan({id: plans?.["bd_pro_month"]._id})
PlansModal.onClose()
PaymentModal.onOpen()
},
@@ -1964,7 +1985,7 @@ const PlansAndPayment = ({ userData }) => {
Para sua empresa ganhar tempo
e qualidade em decisões>}
- price={priceBDEmp}
+ price={plans?.["bd_empresas_month"].amount || 350}
anualPlan={toggleAnual}
textResource="Todos os recursos da BD Pro, mais:"
resources={[
@@ -1974,7 +1995,7 @@ const PlansAndPayment = ({ userData }) => {
button={{
text: `${userData?.proSubscription === "bd_pro_empresas" ? "Plano atual" : "Assinar"}`,
onClick: userData?.proSubscription === "bd_pro_empresas" ? () => {} : () => {
- setPlan({title: "BD Empresas", slug:"bd_pro_empresas", slots: "10"})
+ setPlan({id: plans?.["bd_empresas_month"]._id})
PlansModal.onClose()
PaymentModal.onOpen()
},
diff --git a/next/pages/user/login.js b/next/pages/user/login.js
index 032585b2..7040e4d7 100644
--- a/next/pages/user/login.js
+++ b/next/pages/user/login.js
@@ -81,13 +81,12 @@ export default function Login() {
cookies.set('userBD', JSON.stringify(userData))
- if(query.p === "plans") {
- if(query.q) return window.open(`/user/${userData.username}?plans_and_payment&q=${query.q}`, "_self")
- return window.open(`/user/${userData.username}?plans_and_payment&p=plans`, "_self")
- } else {
- if(userData.availableForResearch === null) return window.open("/user/survey", "_self")
- return window.open("/", "_self")
+ if(query.i) {
+ return window.open(`/user/${userData.username}?plans_and_payment&q=${query.q}&i=${query.i}`, "_self")
}
+
+ if(userData.availableForResearch === null) return window.open("/user/survey", "_self")
+ return window.open("/", "_self")
}
const LabelTextForm = ({ text, ...props }) => {