Skip to content

Commit f5ab05e

Browse files
authored
Merge pull request #1549 from basedosdados/feat/front-chatbot
Feat/front chatbot
2 parents bb71e1e + 3dc0cc6 commit f5ab05e

48 files changed

Lines changed: 5401 additions & 1187 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/release-prod.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ jobs:
2121
NEXT_PUBLIC_SITE_NAME: ${{ vars.NEXT_PUBLIC_SITE_NAME }}
2222
NEXT_PUBLIC_KEY_STRIPE: ${{ secrets.NEXT_PUBLIC_KEY_STRIPE }}
2323
NEXT_PUBLIC_BASE_URL_FRONTEND: ${{ vars.NEXT_PUBLIC_BASE_URL_FRONTEND }}
24+
CHATBOT_URL: ${{ secrets.CHATBOT_URL }}
2425
NODE_ENV: ${{ vars.NODE_ENV }}
2526
IMAGE_NAME: ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}:production
2627

@@ -61,3 +62,5 @@ jobs:
6162
NEXT_PUBLIC_BASE_URL_FRONTEND=${{ env.NEXT_PUBLIC_BASE_URL_FRONTEND }}
6263
URL_DOWNLOAD_CLOSED=${{ steps.import_secrets.outputs.URL_DOWNLOAD_CLOSED }}
6364
URL_DOWNLOAD_OPEN=${{ steps.import_secrets.outputs.URL_DOWNLOAD_OPEN }}
65+
CHATBOT_URL=${{ env.CHATBOT_URL }}
66+

.github/workflows/release-staging.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ jobs:
2121
NEXT_PUBLIC_SITE_NAME: ${{ vars.NEXT_PUBLIC_SITE_NAME }}
2222
NEXT_PUBLIC_KEY_STRIPE: ${{ secrets.NEXT_PUBLIC_KEY_STRIPE }}
2323
NEXT_PUBLIC_BASE_URL_FRONTEND: ${{ vars.NEXT_PUBLIC_BASE_URL_FRONTEND }}
24+
CHATBOT_URL: ${{ secrets.CHATBOT_URL }}
2425
NODE_ENV: ${{ vars.NODE_ENV }}
2526
IMAGE_NAME: ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}:staging
2627

@@ -61,3 +62,4 @@ jobs:
6162
NEXT_PUBLIC_BASE_URL_FRONTEND=${{ env.NEXT_PUBLIC_BASE_URL_FRONTEND }}
6263
URL_DOWNLOAD_CLOSED=${{ steps.import_secrets.outputs.URL_DOWNLOAD_CLOSED }}
6364
URL_DOWNLOAD_OPEN=${{ steps.import_secrets.outputs.URL_DOWNLOAD_OPEN }}
65+
CHATBOT_URL=${{ env.CHATBOT_URL }}

next/.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
20.18.1

next/Dockerfile

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Install dependencies only when needed
2-
FROM node:18.17.0-alpine AS deps
2+
FROM node:20.18.1-alpine AS deps
33
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
44
RUN apk add --no-cache libc6-compat
55
WORKDIR /app
@@ -16,7 +16,7 @@ ARG URL_DOWNLOAD_CLOSED
1616
ARG URL_DOWNLOAD_OPEN
1717

1818
# Rebuild the source code only when needed
19-
FROM node:18.17.0-alpine AS builder
19+
FROM node:20.18.1-alpine AS builder
2020

2121
ARG NEXT_PUBLIC_DOMAIN
2222
ARG NEXT_PUBLIC_SITE_NAME
@@ -25,12 +25,14 @@ ARG NEXT_PUBLIC_KEY_STRIPE
2525
ARG NEXT_PUBLIC_BASE_URL_FRONTEND
2626
ARG URL_DOWNLOAD_CLOSED
2727
ARG URL_DOWNLOAD_OPEN
28+
ARG CHATBOT_URL
2829

2930
ENV NEXT_PUBLIC_DOMAIN=$NEXT_PUBLIC_DOMAIN
3031
ENV NEXT_PUBLIC_SITE_NAME=$NEXT_PUBLIC_SITE_NAME
3132
ENV NEXT_PUBLIC_API_URL=$NEXT_PUBLIC_API_URL
3233
ENV NEXT_PUBLIC_KEY_STRIPE=$NEXT_PUBLIC_KEY_STRIPE
3334
ENV NEXT_PUBLIC_BASE_URL_FRONTEND=$NEXT_PUBLIC_BASE_URL_FRONTEND
35+
ENV CHATBOT_URL=$CHATBOT_URL
3436

3537
WORKDIR /app
3638
COPY --from=deps /app/node_modules ./node_modules
@@ -44,16 +46,18 @@ COPY . .
4446
RUN npm run build
4547

4648
# Production image, copy all the files and run next
47-
FROM node:18.17.0-alpine AS runner
49+
FROM node:20.18.1-alpine AS runner
4850
WORKDIR /app
4951

5052
ARG URL_DOWNLOAD_CLOSED
5153
ARG URL_DOWNLOAD_OPEN
54+
ARG CHATBOT_URL
5255

53-
ENV NODE_ENV production
54-
ENV NODE_OPTIONS '-r next-logger'
56+
ENV NODE_ENV=production
57+
ENV NODE_OPTIONS='-r next-logger'
5558
ENV URL_DOWNLOAD_CLOSED=$URL_DOWNLOAD_CLOSED
5659
ENV URL_DOWNLOAD_OPEN=$URL_DOWNLOAD_OPEN
60+
ENV CHATBOT_URL=$CHATBOT_URL
5761
# Uncomment the following line in case you want to disable telemetry during runtime.
5862
# ENV NEXT_TELEMETRY_DISABLED 1
5963

@@ -74,6 +78,6 @@ USER nextjs
7478

7579
EXPOSE 3000
7680

77-
ENV PORT 3000
81+
ENV PORT=3000
7882

7983
CMD ["server.js"]

next/components/molecules/Menu.js

Lines changed: 54 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -84,27 +84,27 @@ function MenuDrawer({ userData, isOpen, onClose, links, hasChatbotAccess, isUser
8484

8585
return (
8686
<Drawer isOpen={isOpen} placement="left" onClose={onClose}>
87-
<DrawerOverlay backdropFilter="blur(2px)"/>
87+
<DrawerOverlay backdropFilter="blur(2px)" />
8888
<DrawerContent padding="24px">
89-
{locale === 'en' ? (
89+
{locale === "en" ? (
9090
<DBLogoImage
9191
widthImage="65px"
9292
heightImage="30px"
9393
marginBottom="24px"
94-
onClick={() => router.push('/')}
94+
onClick={() => router.push("/")}
9595
/>
9696
) : (
9797
<BDLogoImage
9898
widthImage="65px"
9999
heightImage="30px"
100100
marginBottom="24px"
101-
onClick={() => router.push('/')}
101+
onClick={() => router.push("/")}
102102
/>
103103
)}
104104
<VStack alignItems="flex-start" width="100%" spacing="16px">
105105
{Object.entries(links).map(([key, elm]) => {
106-
if(key === "Button") {
107-
return elm.map(b =>
106+
if (key === "Button") {
107+
return elm.map((b) => (
108108
<Button
109109
key={b.name}
110110
backgroundColor={b.color}
@@ -116,15 +116,15 @@ function MenuDrawer({ userData, isOpen, onClose, links, hasChatbotAccess, isUser
116116
>
117117
{b.name}
118118
</Button>
119-
)
119+
));
120120
}
121121
if (typeof elm === "object") {
122122
return (
123123
<Accordion key={key} allowToggle width="100%">
124124
<AccordionItem borderWidth="0 !important">
125125
<AccordionButton
126126
padding={0}
127-
_hover={{background: "none"}}
127+
_hover={{ background: "none" }}
128128
justifyContent="space-between"
129129
>
130130
<Text
@@ -138,33 +138,35 @@ function MenuDrawer({ userData, isOpen, onClose, links, hasChatbotAccess, isUser
138138
</Text>
139139
<AccordionIcon />
140140
</AccordionButton>
141-
<AccordionPanel
142-
display="flex"
143-
flexDirection="column"
144-
gridGap="13px"
145-
padding="16px 0 2px"
146-
>
147-
{elm.map((c) => {
148-
if(c.name === undefined) return null
149-
150-
return (
151-
<Link
152-
key={c.name}
153-
display="flex"
154-
gap="16px"
155-
fontSize="16px"
156-
fontFamily="Roboto"
157-
letterSpacing="0.1px"
158-
fontWeight="400"
159-
href={c.href}
160-
onClick={() => handleMenuLinkClick(c.href)}
161-
>{c.icon && c.icon} {c.name}</Link>
162-
)
163-
})}
164-
</AccordionPanel>
141+
<AccordionPanel
142+
display="flex"
143+
flexDirection="column"
144+
gridGap="13px"
145+
padding="16px 0 2px"
146+
>
147+
{elm.map((c) => {
148+
if (c.name === undefined) return null;
149+
150+
return (
151+
<Link
152+
key={c.name}
153+
display="flex"
154+
gap="16px"
155+
fontSize="16px"
156+
fontFamily="Roboto"
157+
letterSpacing="0.1px"
158+
fontWeight="400"
159+
href={c.href}
160+
onClick={() => handleMenuLinkClick(c.href)}
161+
>
162+
{c.icon && c.icon} {c.name}
163+
</Link>
164+
);
165+
})}
166+
</AccordionPanel>
165167
</AccordionItem>
166168
</Accordion>
167-
)
169+
);
168170
} else {
169171
return (
170172
<Link
@@ -175,9 +177,10 @@ function MenuDrawer({ userData, isOpen, onClose, links, hasChatbotAccess, isUser
175177
fontWeight="400"
176178
href={elm}
177179
onClick={() => handleMenuLinkClick(elm)}
178-
>{key}
180+
>
181+
{key}
179182
</Link>
180-
)
183+
);
181184
}
182185
})}
183186
</VStack>
@@ -200,16 +203,12 @@ function MenuDrawer({ userData, isOpen, onClose, links, hasChatbotAccess, isUser
200203
fontSize="20px"
201204
fontFamily="Roboto"
202205
fontWeight="400"
203-
href={hasChatbotAccess ? getChatbotStreamlitAppUrl() : "/prices"}
206+
href={hasChatbotAccess ? "/chatbot" : "/prices"}
204207
onClick={(e) => {
205208
onClose();
206209
if (hasChatbotAccess) {
207210
e.preventDefault();
208-
window.open(
209-
getChatbotStreamlitAppUrl(),
210-
"_blank",
211-
"noopener,noreferrer"
212-
);
211+
router.push("/chatbot");
213212
trackMenuOpenChatbot({
214213
menuPlacement: "mobile_drawer",
215214
hasChatbotSubscription: hasChatbotAccess,
@@ -242,24 +241,29 @@ function MenuDrawer({ userData, isOpen, onClose, links, hasChatbotAccess, isUser
242241
{userData ? (
243242
<></>
244243
) : (
245-
<Stack spacing={0} display={{base: "flex", lg: "none"}} marginTop="auto" gap="16px">
244+
<Stack
245+
spacing={0}
246+
display={{ base: "flex", lg: "none" }}
247+
marginTop="auto"
248+
gap="16px"
249+
>
246250
<Link
247251
href="/user/login"
248252
width="100%"
249253
onClick={() => {
250-
if (typeof window !== 'undefined') {
251-
localStorage.setItem('previousPath', window.location.href)
254+
if (typeof window !== "undefined") {
255+
localStorage.setItem("previousPath", window.location.href);
252256
}
253257
}}
254258
>
255259
<Button width="100%" justifyContent="center">
256-
{t('enter', { ns: 'menu' })}
260+
{t("enter", { ns: "menu" })}
257261
</Button>
258262
</Link>
259263

260264
<Link href="/user/register" width="100%">
261-
<Button isVariant width="100%" justifyContent="center">
262-
{t('register', { ns: 'menu' })}
265+
<Button isVariant width="100%" justifyContent="center">
266+
{t("register", { ns: "menu" })}
263267
</Button>
264268
</Link>
265269
</Stack>
@@ -389,16 +393,12 @@ function MenuDrawerUser({ userData, isOpen, onClose, isUserPro, haveInterprisePl
389393
gap="6px"
390394
color="#71757A"
391395
fontWeight="400"
392-
href={hasChatbotAccess ? getChatbotStreamlitAppUrl() : "/prices"}
396+
href={hasChatbotAccess ? "/chatbot" : "/prices"}
393397
onClick={(e) => {
394398
onClose()
395399
if (hasChatbotAccess) {
396400
e.preventDefault()
397-
window.open(
398-
getChatbotStreamlitAppUrl(),
399-
"_blank",
400-
"noopener,noreferrer"
401-
)
401+
router.push("/chatbot")
402402
trackMenuOpenChatbot({
403403
menuPlacement: "mobile_drawer_user",
404404
hasChatbotSubscription: hasChatbotAccess,
@@ -981,9 +981,8 @@ function DesktopLinks({
981981
{...(hasChatbotAccess
982982
? {
983983
as: "a",
984-
href: getChatbotStreamlitAppUrl(),
984+
href: "/chatbot",
985985
target: "_blank",
986-
rel: "noopener noreferrer",
987986
onClick: () =>
988987
trackMenuOpenChatbot({
989988
menuPlacement: "desktop_header_right",

0 commit comments

Comments
 (0)