diff --git a/next/components/atoms/Toggle.js b/next/components/atoms/Toggle.js
new file mode 100644
index 00000000..4807ebff
--- /dev/null
+++ b/next/components/atoms/Toggle.js
@@ -0,0 +1,12 @@
+import { Switch } from "@chakra-ui/react";
+import styles from "../../styles/toggle.module.css";
+
+export default function Toggle({ value, onChange }) {
+ return (
+
+ )
+}
\ No newline at end of file
diff --git a/next/components/molecules/uiUserPage.js b/next/components/molecules/uiUserPage.js
index 3d094c04..782f758f 100644
--- a/next/components/molecules/uiUserPage.js
+++ b/next/components/molecules/uiUserPage.js
@@ -76,11 +76,18 @@ export function ModalGeneral ({
isOpen,
onClose,
isCentered = true,
+ propsModal,
propsModalContent,
classNameBody
}) {
return (
-
+
0) return res.status(500).json({error: result.data.deleteStripeSubscription.errors, success: false })
+ if(result?.data?.deleteStripeSubscription?.errors.length > 0) return res.status(500).json({error: result.data.deleteStripeSubscription.errors, success: false })
if(result === "err") return res.status(500).json({error: "err"})
- res.status(200).json(result?.data?.deleteStripeSubscription.subscription)
+ if(result?.data?.deleteStripeSubscription === null) return res.status(200).json({success: true})
}
diff --git a/next/pages/precos.js b/next/pages/precos.js
index fdbef727..9169c436 100644
--- a/next/pages/precos.js
+++ b/next/pages/precos.js
@@ -5,7 +5,6 @@ import {
Link,
Tooltip,
Badge,
- Button,
} from "@chakra-ui/react";
import { useEffect, useState } from "react";
import Head from "next/head";
@@ -13,11 +12,11 @@ import Display from "../components/atoms/Display";
import BigTitle from "../components/atoms/BigTitle"
import BodyText from "../components/atoms/BodyText";
import RoundedButton from "../components/atoms/RoundedButton";
+import Toggle from "../components/atoms/Toggle";
import { MainPageTemplate } from "../components/templates/main";
import { isMobileMod } from "../hooks/useCheckMobile.hook";
import CheckIcon from "../public/img/icons/checkIcon";
-import CrossIcon from "../public/img/icons/crossIcon";
import InfoIcon from '../public/img/icons/infoIcon';
export async function getServerSideProps(context) {
@@ -49,27 +48,12 @@ export const CardPrice = ({
title,
badge,
subTitle,
- personConfig,
+ price,
+ anualPlan = false,
textResource,
resources = [],
button,
}) => {
- const [nubmerOfPerson, setNubmerOfPerson] = useState(personConfig.person)
- const [priceValue, setPriceValue] = useState(personConfig.price)
-
- const addRemovePersonPrice = (action) => {
- if(action === "add") {
- const personAdd = nubmerOfPerson + 1
- setNubmerOfPerson(personAdd)
- setPriceValue(150 + 50 * personAdd)
- }
- if(action === "remove") {
- const personRemove = nubmerOfPerson - 1
- setNubmerOfPerson(personRemove)
- setPriceValue(150 + 50 * personRemove)
- }
- }
-
return (
- R$ {priceValue}
- /mês
-
-
-
- {personConfig.text &&
- <>
+
R$ {price}
+
- {personConfig.text}
-
+ fontFamily="Ubuntu"
+ >/mês
+
-
-
- {nubmerOfPerson - personConfig.person}
-
-
- >
+ {anualPlan &&
+ {(price*12).toLocaleString('pt-BR', { style: 'currency', currency: 'BRL', minimumFractionDigits: 0 })} cobrado uma vez no ano
}
@@ -342,6 +276,20 @@ 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")
+
+ useEffect(() => {
+ if(toggleAnual === true) {
+ setPriceBDPro("37")
+ setPriceBDEmp("280")
+ } else {
+ setPriceBDPro("47")
+ setPriceBDEmp("350")
+ }
+ }, [toggleAnual])
+
return (
@@ -359,7 +307,7 @@ export default function Price({ username ,isBDPro, isBDEmp }) {
+
+ setToggleAnual(!toggleAnual)}
+ />
+
+ Desconto anual Economize 20%
+
+
+
Para você descobrir o potencial da plataforma de dados}
- personConfig={{
- price: "0"
- }}
+ price={"0"}
textResource="Recursos:"
resources={[
{name: "Tabelas tratadas"},
@@ -413,9 +387,8 @@ export default function Price({ username ,isBDPro, isBDEmp }) {
Para você ter acesso aos
dados mais atualizados}
- personConfig={{
- price: "47"
- }}
+ price={priceBDPro}
+ anualPlan={toggleAnual}
textResource="Todos os recursos da BD Grátis, mais:"
resources={[
{name: "Dezenas de bases de alta frequência atualizadas"},
@@ -430,9 +403,8 @@ export default function Price({ username ,isBDPro, isBDEmp }) {
Para sua empresa ganhar tempo
e qualidade em decisões}
- personConfig={{
- price: "350"
- }}
+ price={priceBDEmp}
+ anualPlan={toggleAnual}
textResource="Todos os recursos da BD Pro, mais:"
resources={[
{name: "Acesso para 10 contas"},{name: "Suporte prioritário via email e Discord"}
diff --git a/next/pages/user/[username].js b/next/pages/user/[username].js
index 1edb18b7..63e51b4b 100644
--- a/next/pages/user/[username].js
+++ b/next/pages/user/[username].js
@@ -40,6 +40,7 @@ import ButtonSimple from "../../components/atoms/SimpleButton";
import InputForm from "../../components/atoms/SimpleInput";
import Link from "../../components/atoms/Link";
import BodyText from "../../components/atoms/BodyText";
+import Toggle from "../../components/atoms/Toggle";
import { CardPrice } from "../precos";
import PaymentSystem from "../../components/organisms/PaymentSystem";
import ImageCrop from "../../components/molecules/ImgCrop";
@@ -1441,6 +1442,9 @@ const PlansAndPayment = ({ userData }) => {
const [isLoading, setIsLoading] = useState(false)
const [isLoadingH, setIsLoadingH] = useState(false)
const [isLoadingCanSub, setIsLoadingCanSub] = useState(false)
+ const [toggleAnual, setToggleAnual] = useState(false)
+ const [priceBDPro, setPriceBDPro] = useState("47")
+ const [priceBDEmp, setPriceBDEmp] = useState("350")
useEffect(() => {
if(query.q === "pro") {
@@ -1455,6 +1459,16 @@ const PlansAndPayment = ({ userData }) => {
}
}, [query])
+ useEffect(() => {
+ if(toggleAnual === true) {
+ setPriceBDPro("37")
+ setPriceBDEmp("280")
+ } else {
+ setPriceBDPro("47")
+ setPriceBDEmp("350")
+ }
+ }, [toggleAnual])
+
const resources={
"BD Gratis" : {
title: "BD Grátis",
@@ -1567,6 +1581,7 @@ const PlansAndPayment = ({ userData }) => {
const subs = await fetch(`/api/stripe/getSubscriptionActive?p=${btoa(id)}`, {method: "GET"})
.then(res => res.json())
+
const result = await fetch(`/api/stripe/removeSubscription?p=${btoa(subs[0]?.node._id)}`, {method: "GET"})
.then(res => res.json())
@@ -1835,11 +1850,18 @@ const PlansAndPayment = ({ userData }) => {
-
+
Compare os planos
{
right="26px"
_hover={{backgroundColor: "transparent", color:"#42B0FF"}}
/>
+
+
+ setToggleAnual(!toggleAnual)}
+ />
+
+ Desconto anual Economize 20%
+
+
Para você descobrir o potencial da plataforma de dados}
- personConfig={{
- price: "0"
- }}
+ price={"0"}
textResource="Recursos:"
resources={[
{name: "Tabelas tratadas"},
@@ -1886,9 +1937,8 @@ const PlansAndPayment = ({ userData }) => {
Para você ter acesso aos
dados mais atualizados}
- personConfig={{
- price: "47"
- }}
+ price={priceBDPro}
+ anualPlan={toggleAnual}
textResource="Todos os recursos da BD Grátis, mais:"
resources={[
{name: "Dezenas de bases de alta frequência atualizadas"},
@@ -1907,9 +1957,8 @@ const PlansAndPayment = ({ userData }) => {
Para sua empresa ganhar tempo
e qualidade em decisões}
- personConfig={{
- price: "350"
- }}
+ price={priceBDEmp}
+ anualPlan={toggleAnual}
textResource="Todos os recursos da BD Pro, mais:"
resources={[
{name: "Acesso para 10 contas"},{name: "Suporte prioritário via email e Discord"}
@@ -2034,9 +2083,9 @@ const PlansAndPayment = ({ userData }) => {
@@ -2082,7 +2131,7 @@ const PlansAndPayment = ({ userData }) => {
{choices[sectionSelected].title}
diff --git a/next/styles/toggle.module.css b/next/styles/toggle.module.css
new file mode 100644
index 00000000..a032c938
--- /dev/null
+++ b/next/styles/toggle.module.css
@@ -0,0 +1,38 @@
+.toggle {
+ --switch-track-diff: 17px !important;
+ --switch-thumb-x: 17px !important;
+ --switch-track-width: 0 !important;
+ --switch-track-height: 0 !important;
+ border-color: transparent !important;
+}
+
+.toggle span{
+ background-color: #878A8E;
+ width: 42px;
+ height: 24px;
+}
+
+.toggle span[data-checked]{
+ background-color: #2B8C4D;
+ width: 42px;
+ height: 24px;
+}
+
+.toggle span[data-focus]{
+ box-shadow: none;
+}
+
+.toggle span span{
+ background-color: #FFF;
+ position: relative;
+ top: 1px;
+ left: 2px;
+ width: 21px;
+ height: 21px;
+}
+
+.toggle span span[data-checked]{
+ background-color: #FFF;
+ width: 21px;
+ height: 21px;
+}