Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { useState, useRef } from 'react';
import Image from 'next/image';
import Link from 'next/link';
import scriptRunner from '@/utils/scriptRunner';

function isValidEmail(email) {
return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email);
Expand Down Expand Up @@ -77,24 +78,18 @@ export function RequestPlugin({ appInfo, secondAppInfo = null, type, onClose })
window.signals.identify({
email: formData.userEmail,
});

console.log("In the form ");
const formDataToSend = formData;
const { plug, ...cleanedPayload } = formDataToSend;
cleanedPayload.userNeed = `New ${type || 'App'}`;
cleanedPayload.category = appInfo?.category?.join(', ');

try {
setIsLoading(true);
const pluginResponse = await fetch('https://flow.sokt.io/func/scriPIvL7pBP', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},

body: JSON.stringify(cleanedPayload),
});

const pluginData = await pluginResponse.json();
console.log("hello ji hello ");

const pluginData = await scriptRunner('REQUEST_PLUGIN', cleanedPayload, 'POST');
console.log(pluginData,"dafsdfasdf");

if (pluginData?.data?.success) {
handleClose();
Expand Down
17 changes: 5 additions & 12 deletions src/components/requestMeetingComp/RequestMeetingComp.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Image from 'next/image';
import React, { useState } from 'react';
import scriptRunner from '@/utils/scriptRunner';

const RequestMeeting = ({ agencyName }) => {
const [isLoading, setIsLoading] = useState(false);
Expand Down Expand Up @@ -57,22 +58,14 @@ const RequestMeeting = ({ agencyName }) => {
try {
setIsLoading(true);

const url = new URL('https://flow.sokt.io/func/scri22s212eP');
Object.entries(formData).forEach(([key, value]) => {
url.searchParams.append(key, value);
});
const payload = { ...formData };
if (agencyName) {
url.searchParams.append('agencyName', agencyName);
payload.agencyName = agencyName;
}

const response = await fetch(url.toString(), {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
});
const response = await scriptRunner('REQUEST_MEETING', payload, 'GET');

if (response.ok) {
if (response) {
alert('Meeting request submitted successfully!');
document.getElementById('meeting_request_form').close();
} else {
Expand Down
13 changes: 10 additions & 3 deletions src/pages/homeSection/searchInputHome.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { getVideoData } from '@/utils/getVideoData';
import { getBlogData } from '@/utils/getBlogData';
import { useTemplateFilters } from '@/hooks/useTemplateFilters';
import { validateTemplateData } from '@/utils/validateTemplateData';
import axios from 'axios';
import scriptRunner from '@/utils/scriptRunner';

const SearchInputHome = ({
onTemplatesChange,
Expand Down Expand Up @@ -605,8 +605,15 @@ const SearchInputHome = ({
params.append('categories', selectedIndustries.join(','));
}

const response = await axios.post(`https://flow.sokt.io/func/scrifJcjUubA?${params.toString()}`, {});
const responseData = await response?.data;
const payload = {};
if (selectedDepartments.length > 0) {
payload.departments = selectedDepartments.join(',');
}
if (selectedIndustries.length > 0) {
payload.categories = selectedIndustries.join(',');
}

const responseData = await scriptRunner('AI_SEARCH', payload, 'POST');
Comment on lines 605 to +616
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Include selected apps when invoking AI search

getAiResponse still collects the selected apps into params, but the subsequent scriptRunner('AI_SEARCH', payload) call never uses params and the payload object omits an apps field. As a result the request no longer contains the user's chosen apps, so the AI search backend cannot tailor results to the selection and always returns generic data. Forward the selected app names in the payload (or reuse params) to preserve the previous behaviour.

Useful? React with 👍 / 👎.


if (responseData) {
setAiResponse(responseData);
Expand Down
9 changes: 3 additions & 6 deletions src/pages/support.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import Footer from '@/components/footer/footer';
import { getFooterData } from '@/utils/getData';
import { FOOTER_FIELDS } from '@/const/fields';
import { getMetaData } from '@/utils/getMetaData';
import scriptRunner from '@/utils/scriptRunner';
import { FaHeadset } from 'react-icons/fa';
import { IoIosPeople } from 'react-icons/io';
import { FaAnchor } from 'react-icons/fa';
Expand Down Expand Up @@ -75,12 +76,8 @@ export default function Support({ footerData, metaData, testimonials }) {
setIsSend(true);

try {
const response = await fetch(`https://flow.sokt.io/func/scrir501xRzP`, {
method: 'POST',
headers: {},
body: JSON.stringify(formData),
});
if (response.ok) {
const response = await scriptRunner('SUPPORT_REQUEST', formData, 'POST');
if (response) {
setIsSubmit(true);
setIsSend(false);
} else {
Expand Down
16 changes: 13 additions & 3 deletions src/utils/SendErrorMessage.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import scriptRunner from './scriptRunner';

export async function sendErrorMessage({ error, pageUrl, source }) {
const extractedError = error?.response?.data ?? error?.message ?? 'Unknown error';
const statusCode = error?.response?.status ?? error?.status ?? 'unknown';
Expand All @@ -19,9 +21,17 @@ export async function sendErrorMessage({ error, pageUrl, source }) {
});

if (process.env.NEXT_PUBLIC_PRODUCTION_ENVIRONMENT === 'prod') {
const response = await fetch(`https://flow.sokt.io/func/scrixVwRkMy0?${queryParams.toString()}`);
if (!response.ok) {
console.error('Failed to send error message:', response.statusText);
const payload = {
error: JSON.stringify(extractedError),
url: pageUrl,
source: source || 'unknown',
statusCode: String(statusCode),
};

try {
await scriptRunner('SEND_ERROR_MESSAGE', payload, 'GET');
} catch (err) {
console.error('Failed to send error message:', err);
}
}
console.error(extractedError);
Expand Down
9 changes: 4 additions & 5 deletions src/utils/currencyConverter.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import scriptRunner from './scriptRunner';

export async function convertCurrency(countryCode) {
try {
const response = await fetch(`https://flow.sokt.io/func/scriSlHY6j9j?country_code=${countryCode}`);
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
const data = await response.json();
const data = await scriptRunner('CONVERT_CURRENCY', { country_code: countryCode }, 'GET');

if (data && data[0] && data[0].pricing && data[0].one_time_price) {
const basePricing = data[0].pricing;
const oneTimePrice = data[0].one_time_price;
Expand Down
5 changes: 2 additions & 3 deletions src/utils/getPricingData.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import axios from 'axios';
import scriptRunner from './scriptRunner';

export default async function getPricingData(countryCode) {
try {
const response = await axios.post(`https://flow.sokt.io/func/scri9yYiEIJq?country_code=${countryCode}`);
const responseData = await response?.data;
const responseData = await scriptRunner('GET_PRICING_DATA', { country_code: countryCode }, 'POST');
return responseData;
} catch (error) {
console.error('Error fetching combos:', error);
Expand Down
8 changes: 3 additions & 5 deletions src/utils/getPricingPlan.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import scriptRunner from './scriptRunner';

export async function getPricingPlan(country_code) {
try {
const response = await fetch(`https://flow.sokt.io/func/scriSlHY6j9j?country_code=${country_code}`);
if (!response.ok) {
throw new Error(`Network response was not ok: ${response.statusText}`);
}
const data = await response.json();
const data = await scriptRunner('GET_PRICING_PLAN', { country_code }, 'GET');
return data;
} catch (error) {
console.error('Error fetching pricing plan:', error);
Expand Down
24 changes: 24 additions & 0 deletions src/utils/scriptRunner.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import axios from 'axios';

const URL = process.env.NEXT_PUBLIC_PLUG_SERVICE_URL;

const scriptRunner = async (scriptEnum, payload = {}, method = 'POST') => {
try {

let result
const url = `${URL}/utility/script-runner/${scriptEnum}`

if (method.toUpperCase() === 'GET') {
result = await axios.get(url, { params: payload })
return result.data
}else{
result = await axios.post(url, payload)
}
return result?.data;
} catch (error) {
console.error(error,"error");
throw error
}
}

export default scriptRunner;