import React, { useState, useEffect, useContext } from 'react'; import ReactGA from 'react-ga4'; import {getTheme} from '../theme.jsx'; import {Link} from 'react-router-dom'; import { Search as SearchIcon, CloudQueue as CloudQueueIcon, Code as CodeIcon } from '@mui/icons-material'; import { toast } from 'react-toastify'; import { Context } from '../context/ContextApi.jsx'; //import algoliasearch from 'algoliasearch/lite'; import algoliasearch from 'algoliasearch'; import { InstantSearch, connectSearchBox, connectHits } from 'react-instantsearch-dom'; import { Grid, Paper, TextField, ButtonBase, InputAdornment, Typography, Button, Tooltip } from '@mui/material'; import aa from 'search-insights' const searchClient = algoliasearch("JNSS5CFDZZ", "33e4e3564f4f060e96e0531957bed552") const Appsearch = props => { const { maxRows, showName, showSuggestion, isMobile, globalUrl, parsedXs, newSelectedApp, setNewSelectedApp, defaultSearch, showSearch, ConfiguredHits, userdata, cy, isCreatorPage, actionImageList, setActionImageList, setUserSpecialzedApp, inputHeight, apps, } = props const { themeMode } = useContext(Context) const theme = getTheme(themeMode) const isCloud = window.location.host === "localhost:3002" || window.location.host === "shuffler.io"; const rowHandler = maxRows === undefined || maxRows === null ? 50 : maxRows const xs = parsedXs === undefined || parsedXs === null ? 12 : parsedXs const [formMail, setFormMail] = React.useState(""); const [message, setMessage] = React.useState(""); const [formMessage, setFormMessage] = React.useState(""); const [selectedApp, setSelectedApp] = React.useState({}); const buttonStyle = {borderRadius: 30, height: 50, width: 220, margin: isMobile ? "15px auto 15px auto" : 20, fontSize: 18,} const innerColor = "rgba(255,255,255,0.65)" const borderRadius = 3 window.title = "Shuffle | Apps | Find and integration any app" const parsedInputHeight = inputHeight === undefined || inputHeight === null ? 295 : inputHeight // value={currentRefinement} const SearchBox = ({currentRefinement, refine, isSearchStalled} ) => { useEffect(() => { //console.log("FIRST LOAD ONLY? RUN REFINEMENT: !", currentRefinement) if (defaultSearch !== undefined && defaultSearch !== null) { refine(defaultSearch) } }, []) return (
) //value={currentRefinement} } const Hits = ({ hits }) => { const [mouseHoverIndex, setMouseHoverIndex] = useState(-1) var counted = 0 if (hits?.length < 20 && apps !== undefined && apps !== null && apps?.length > 0) { // Find the textbox html const findId = "shuffle_workflow_search_field" const searchField = document.getElementById(findId) const searchValue = searchField === null || searchField === undefined ? "" : searchField?.value if (searchValue?.length > 0) { const parsedsearch = searchValue.toLowerCase().replaceAll(" ", "") for (var appkey in apps) { const app = apps[appkey] const parsedAppname = app?.name?.toLowerCase().replaceAll(" ", "") if (parsedAppname.includes(parsedsearch)) { hits.push({ objectID: app.id, id: app.id, name: app.name, image_url: app.large_image, }) } } } else { console.log("No value in textfield: ", searchValue) } } return (