Skip to content

Commit 7ee4e47

Browse files
Feat: Learn More Button in FAQ (#146)
* Feat: Learn More Button in FAQ * Fix formatting
1 parent 35dd013 commit 7ee4e47

File tree

6 files changed

+142
-54
lines changed

6 files changed

+142
-54
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
"use client";
2+
3+
import { Button } from "@/components/ui/button";
4+
import { ArrowRightIcon } from "lucide-react";
5+
6+
export default function FaqLearnMore({
7+
index,
8+
learnMoreChatbotMessage,
9+
children
10+
}: {
11+
index: number;
12+
children: React.ReactNode;
13+
learnMoreChatbotMessage: string;
14+
}) {
15+
return (
16+
<Button
17+
variant="link"
18+
className="flex w-max cursor-pointer flex-row items-center justify-center gap-1 rounded-none border-b border-black px-0 text-black hover:no-underline lg:text-lg"
19+
onClick={() => {
20+
// Open Chatbot with question regarding the index of the FAQ
21+
let topic = "";
22+
switch (index) {
23+
case 0:
24+
topic = "CTO as a Service";
25+
break;
26+
case 1:
27+
topic = "ERP Implementation";
28+
break;
29+
case 2:
30+
topic = "Tech Due Diligence";
31+
break;
32+
case 3:
33+
topic = "Software as a Service";
34+
break;
35+
default:
36+
break;
37+
}
38+
39+
window.dispatchEvent(
40+
new CustomEvent("prefillAIAgent", {
41+
detail: {
42+
message: `${learnMoreChatbotMessage} ${topic}`
43+
}
44+
})
45+
);
46+
}}>
47+
{children}
48+
<span>
49+
<ArrowRightIcon className="h-4 w-4" />
50+
</span>
51+
</Button>
52+
);
53+
}

app/[lang]/(hyperjump)/components/landing-ai-agent.tsx

Lines changed: 61 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@
33
import { Button } from "@/components/ui/button";
44
import { MessageCircle, X } from "lucide-react";
55
import Image from "next/image";
6-
import { useEffect, useRef, useState } from "react";
6+
import { useCallback, useEffect, useRef, useState } from "react";
77
import { toast } from "sonner";
88
import { motion, AnimatePresence } from "framer-motion";
99

1010
// Types
11+
type PrefillAIAgentEvent = CustomEvent<{ message: string }>;
12+
1113
type TMessageResponse = {
1214
messages: TMessage[];
1315
messageCount: number;
@@ -173,37 +175,64 @@ export default function LandingAIAgent() {
173175
}, [messages]);
174176

175177
// Function to handle form submission
176-
const handleSubmit = async (text: string) => {
177-
if (!text.length || !inputRef.current) return;
178-
179-
// Set chat input and clear input field
180-
const chatInput = text.trim();
181-
setText("");
182-
inputRef.current.value = "";
183-
184-
setIsSubmitting(true);
185-
try {
186-
const prevMessages = messages;
187-
const newMessages = [...prevMessages, { human: chatInput, ai: "" }];
188-
setMessages(newMessages);
189-
const { output } = await fetchAsk({
190-
chatInput,
191-
sessionId: sessionId as string
192-
});
193-
194-
const newMessagesFromAI = [
195-
...prevMessages,
196-
{ human: chatInput, ai: output }
197-
];
198-
setMessages(newMessagesFromAI);
199-
200-
scrollToBottom();
201-
} catch (error) {
202-
toast("Failed to ask question. Please try again later.");
203-
} finally {
204-
setIsSubmitting(false);
205-
}
206-
};
178+
const handleSubmit = useCallback(
179+
async (text: string) => {
180+
if (!text.length) return;
181+
if (!text.length || !inputRef.current) return;
182+
183+
// Set chat input and clear input field
184+
const chatInput = text.trim();
185+
setText("");
186+
if (inputRef.current) {
187+
inputRef.current.value = "";
188+
}
189+
190+
setIsSubmitting(true);
191+
try {
192+
const prevMessages = messages;
193+
const newMessages = [...prevMessages, { human: chatInput, ai: "" }];
194+
setMessages(newMessages);
195+
const { output } = await fetchAsk({
196+
chatInput,
197+
sessionId: sessionId as string
198+
});
199+
200+
const newMessagesFromAI = [
201+
...prevMessages,
202+
{ human: chatInput, ai: output }
203+
];
204+
setMessages(newMessagesFromAI);
205+
206+
scrollToBottom();
207+
} catch (error) {
208+
toast("Failed to ask question. Please try again later.");
209+
} finally {
210+
setIsSubmitting(false);
211+
}
212+
},
213+
[messages, sessionId]
214+
);
215+
216+
// Listen for custom event to prefill and submit
217+
useEffect(() => {
218+
const handlePrefillAndSubmit = (event: Event) => {
219+
const customEvent = event as PrefillAIAgentEvent;
220+
const { message } = customEvent.detail;
221+
setClosed(false);
222+
setText(message);
223+
224+
// Wait for the chat to open and then submit
225+
setTimeout(() => {
226+
handleSubmit(message);
227+
}, 300);
228+
};
229+
230+
window.addEventListener("prefillAIAgent", handlePrefillAndSubmit);
231+
232+
return () => {
233+
window.removeEventListener("prefillAIAgent", handlePrefillAndSubmit);
234+
};
235+
}, [handleSubmit]);
207236

208237
return (
209238
<div className="fixed right-6 bottom-16 z-50 flex flex-col items-end gap-3">

app/[lang]/(hyperjump)/page.tsx

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,12 @@ import {
1010
AccordionTrigger
1111
} from "@/components/ui/accordion";
1212
import { Button } from "@/components/ui/button";
13-
import { Card, CardContent, CardHeader } from "@/components/ui/card";
13+
import {
14+
Card,
15+
CardContent,
16+
CardFooter,
17+
CardHeader
18+
} from "@/components/ui/card";
1419
import GridItemsContainer, {
1520
GridItems,
1621
GridItemsMoreButton,
@@ -35,7 +40,9 @@ import {
3540
mainCaseStudiesCtaHeading,
3641
mainCaseStudiesCtaDesc,
3742
mainCaseStudiesCtaExploreOurCaseStudies,
38-
mainHeroHeading
43+
mainHeroHeading,
44+
mainFaqLearnMore,
45+
mainFaqLearnMoreChatbotMessage
3946
} from "@/locales/.generated/server";
4047

4148
import { Clients } from "./components/clients";
@@ -48,6 +55,8 @@ import {
4855
services
4956
} from "./data";
5057
import { dynamicOpengraph } from "@/lib/default-metadata";
58+
import { ArrowRightIcon } from "lucide-react";
59+
import FaqLearnMore from "./components/faq-learn-more";
5160

5261
const { github, socials, title, url } = data;
5362

@@ -260,9 +269,18 @@ function Faqs({ lang }: HomeParams) {
260269
</AccordionTrigger>
261270
</CardHeader>
262271
<AccordionContent asChild>
263-
<CardContent className="px-4 pt-0 pb-4 text-base text-[#61656E] lg:text-lg">
272+
<CardContent className="flex flex-col gap-4 px-4 pt-0 pb-4 text-base text-[#61656E] lg:text-lg">
264273
{item.answer}
265274
</CardContent>
275+
<CardFooter className="p-0 px-4">
276+
<FaqLearnMore
277+
index={i}
278+
learnMoreChatbotMessage={mainFaqLearnMoreChatbotMessage(
279+
lang
280+
)}>
281+
{mainFaqLearnMore(lang)}
282+
</FaqLearnMore>
283+
</CardFooter>
266284
</AccordionContent>
267285
</Card>
268286
</AccordionItem>

locales/en/main.json

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,38 +31,32 @@
3131
"0_title": "Transforming a fisheries tech team into a scalable product engine",
3232
"0_text": "A junior but passionate tech team. Zero products in production. High impact at stake. We embedded deeply with their team to introduce structure, build confidence, and ship a functional MVP within 3 months. Through rigorous agile practices and full-system rollouts, we helped evolve a fragile tech org into a reliable product engine.",
3333
"0_category": "CTO as a Service",
34-
3534
"1_title": "Elevating a media-tech engineering team from feature factory to innovation powerhouse",
3635
"1_text": "When rapid growth outpaced engineering maturity, this team needed more than features, they needed transformation. We restructured their agile practices, automated DevOps, established measurable KPIs, and helped them move from task execution to true product ownership and experimentation.",
3736
"1_category": "CTO as a Service"
3837
},
3938
"project": {
4039
"heading": "Open source product",
4140
"desc": "Explore our open-source projects and see how we innovate, collaborate, and build solutions that drive real impact. Join our community and contribute to cutting-edge technology.",
42-
4341
"0_title": "Grule",
4442
"0_text": "Grule is a powerful open-source rule engine for Go that lets you define business rules in a human-readable format—making your app more flexible and maintainable.",
45-
4643
"1_title": "Monika",
4744
"1_text": "Monika is a command line application to monitor every part of your web app using a simple JSON configuration file. Get alert not only when your site is down but also when it's slow.",
48-
4945
"2_title": "WhatsApp Chatbot Connector",
5046
"2_text": "WhatsApp Chatbot Connector backend built using Express.js. It is designed to integrate with the WhatsApp Business API and supports various AI platforms such as Dify and Rasa."
5147
},
5248
"faq": {
5349
"heading": "Frequently asked questions",
5450
"desc": "Find answers to commonly asked questions. If you need further assistance, feel free to reach out to us.",
55-
5651
"0_question": "What is CTO as a Service (CTOaaS), and how can it benefit my company?",
5752
"0_answer": "CTOaaS provides on-demand access to experienced technology leadership without the cost of a full-time executive. It helps enterprises with strategic IT planning, digital transformation, and technical decision-making to scale efficiently.",
58-
5953
"1_question": "How do you approach ERP implementation for enterprises?",
6054
"1_answer": "We follow a structured process that includes business analysis, system selection, customization, integration, training, and post-implementation support to ensure seamless adoption and long-term success.",
61-
6255
"2_question": "What does your tech due diligence service cover?",
6356
"2_answer": "Our tech due diligence includes codebase reviews, security assessments, scalability analysis, infrastructure evaluation, and compliance checks to ensure that your technology investments are low-risk and high-value.",
64-
6557
"3_question": "Why should we choose your consulting services over hiring an in-house team?",
66-
"3_answer": "We offer specialized expertise, flexibility, and cost-effective solutions without the overhead of full-time employees. Our team brings years of experience in enterprise IT, ensuring faster implementation and better ROI."
58+
"3_answer": "We offer specialized expertise, flexibility, and cost-effective solutions without the overhead of full-time employees. Our team brings years of experience in enterprise IT, ensuring faster implementation and better ROI.",
59+
"learn_more": "Learn more",
60+
"learn_more_chatbot_message": "I want to learn more about"
6761
}
6862
}

locales/id/main.json

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,38 +31,32 @@
3131
"0_title": "Mengubah tim teknologi perikanan menjadi mesin produk yang skalabel",
3232
"0_text": "Sebuah tim teknologi junior namun penuh semangat. Tidak ada produk yang sudah berjalan. Taruhannya besar. Kami terlibat secara mendalam dengan tim mereka untuk memperkenalkan struktur, membangun kepercayaan diri, dan merilis MVP yang berfungsi dalam 3 bulan. Melalui praktik agile yang ketat dan peluncuran sistem menyeluruh, kami membantu mengubah organisasi teknologi yang rapuh menjadi mesin produk yang andal.",
3333
"0_category": "CTO as a Service",
34-
3534
"1_title": "Meningkatkan tim rekayasa media dari pabrik fitur menjadi pusat inovasi",
3635
"1_text": "Ketika pertumbuhan pesat melampaui kematangan tim, tim ini membutuhkan lebih dari sekadar fitur, mereka membutuhkan transformasi. Kami merestrukturisasi praktik agile mereka, mengotomatisasi DevOps, menetapkan KPI yang terukur, dan membantu mereka beralih dari sekadar mengeksekusi tugas menjadi pemilik produk sejati yang mampu berinovasi.",
3736
"1_category": "CTO as a Service"
3837
},
3938
"project": {
4039
"heading": "Produk sumber terbuka",
4140
"desc": "Jelajahi proyek open-source kami dan lihat bagaimana kami berinovasi, berkolaborasi, dan membangun solusi berdampak nyata. Bergabunglah dengan komunitas kami dan berkontribusi dalam pengembangan teknologi mutakhir.",
42-
4341
"0_title": "Grule",
4442
"0_text": "Grule adalah mesin aturan (rule engine) open-source yang kuat untuk Go, yang memungkinkan Anda mendefinisikan aturan bisnis dalam format yang mudah dibaca manusia—membuat aplikasi Anda lebih fleksibel dan mudah dipelihara.",
45-
4643
"1_title": "Monika",
4744
"1_text": "Monika adalah aplikasi baris perintah untuk memantau berbagai komponen aplikasi web Anda menggunakan konfigurasi sederhana berbasis JSON. Dapatkan notifikasi tidak hanya saat situs Anda down, tetapi juga ketika performanya melambat.",
48-
4945
"2_title": "Konektor Chatbot WhatsApp",
5046
"2_text": "Backend Konektor Chatbot WhatsApp dibangun menggunakan Express.js. Dirancang untuk terintegrasi dengan WhatsApp Business API dan mendukung berbagai platform AI seperti Dify dan Rasa."
5147
},
5248
"faq": {
5349
"heading": "Pertanyaan yang sering diajukan",
5450
"desc": "Temukan jawaban atas pertanyaan yang sering diajukan. Jika membutuhkan bantuan lebih lanjut, jangan ragu untuk menghubungi kami.",
55-
5651
"0_question": "Apa itu CTO sebagai Layanan (CTOaaS), dan bagaimana manfaatnya bagi perusahaan saya?",
5752
"0_answer": "CTOaaS memberikan akses fleksibel ke kepemimpinan teknologi berpengalaman tanpa biaya eksekutif penuh waktu. Layanan ini membantu perusahaan dalam perencanaan strategis TI, transformasi digital, dan pengambilan keputusan teknis untuk mendukung pertumbuhan secara efisien.",
58-
5953
"1_question": "Bagaimana pendekatan Anda dalam implementasi ERP untuk perusahaan?",
6054
"1_answer": "Kami mengikuti proses terstruktur yang mencakup analisis bisnis, pemilihan sistem, kustomisasi, integrasi, pelatihan, dan dukungan pasca implementasi untuk memastikan adopsi yang lancar dan keberhasilan jangka panjang.",
61-
6255
"2_question": "Apa saja yang dicakup dalam layanan uji tuntas teknologi Anda?",
6356
"2_answer": "Uji tuntas teknologi kami mencakup review kode, evaluasi keamanan, analisis skalabilitas, penilaian infrastruktur, dan pemeriksaan kepatuhan untuk memastikan investasi teknologi Anda aman dan bernilai tinggi.",
64-
6557
"3_question": "Mengapa kami harus memilih layanan konsultasi Anda dibandingkan membangun tim internal?",
66-
"3_answer": "Kami menawarkan keahlian khusus, fleksibilitas, dan solusi yang hemat biaya tanpa beban karyawan tetap. Tim kami memiliki pengalaman bertahun-tahun dalam TI enterprise, memastikan implementasi lebih cepat dan ROI yang lebih tinggi."
58+
"3_answer": "Kami menawarkan keahlian khusus, fleksibilitas, dan solusi yang hemat biaya tanpa beban karyawan tetap. Tim kami memiliki pengalaman bertahun-tahun dalam TI enterprise, memastikan implementasi lebih cepat dan ROI yang lebih tinggi.",
59+
"learn_more": "Pelajari lebih lanjut",
60+
"learn_more_chatbot_message": "Saya ingin mempelajari lebih lanjut tentang"
6761
}
6862
}

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"moduleResolution": "bundler",
1111
"resolveJsonModule": true,
1212
"isolatedModules": true,
13-
"jsx": "react-jsx",
13+
"jsx": "preserve",
1414
"incremental": true,
1515
"plugins": [
1616
{

0 commit comments

Comments
 (0)