import React, { useState, useEffect } from 'react'; import algoliasearch from 'algoliasearch'; import theme from '../theme.jsx'; import { InstantSearch, connectSearchBox, connectHits } from 'react-instantsearch-dom'; import { Grid, Paper, TextField, Typography, Button, InputAdornment, Avatar, List, ListItem, ListItemAvatar, ListItemText, } from '@mui/material'; import { Search as SearchIcon } from '@mui/icons-material'; const searchClient = algoliasearch("JNSS5CFDZZ", "1e5f29b1550939855de5915eac3bf5f7"); const DiscordChat = props => { const { isMobile, globalUrl } = props const [value, setValue] = useState(""); const [formMail, setFormMail] = React.useState(""); const [message, setMessage] = React.useState(""); const [formMessage, setFormMessage] = React.useState(""); const buttonStyle = {borderRadius: 30, height: 50, width: 220, margin: isMobile ? "15px auto 15px auto" : 20, fontSize: 18,} const borderRadius = 3 const submitContact = (email, message) => { const data = { "firstname": "", "lastname": "", "title": "", "companyname": "", "email": email, "phone": "", "message": message, } const errorMessage = "Something went wrong. Please contact frikky@shuffler.io directly." fetch(globalUrl+"/api/v1/contact", { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify(data), }) .then(response => response.json()) .then(response => { if (response.success === true) { setFormMessage(response.reason) //toast("Thanks for submitting!") } else { setFormMessage(errorMessage) } setFormMail("") setMessage("") }) .catch(error => { setFormMessage(errorMessage) console.log(error) }); } const SearchBox = ({ currentRefinement, refine }) => { return (
refine(event.currentTarget.value)} onKeyDown={(event) => { if(event.key === "Enter") { event.preventDefault(); } }} placeholder="Search Discord Chats..." style={{ backgroundColor: theme.palette.inputColor, borderRadius: borderRadius, margin: 10, width: "100%", }} InputProps={{ style: { color: "white", fontSize: "1em", height: 50, }, startAdornment: ( ), }} /> ); }; const highlightText = (text) => { if (!Array.isArray(text.matchedWords) || text.matchedWords.length === 0) { return text.value; } let highlightedText = ''; let currentIndex = 0; text.matchedWords.forEach((word, index) => { const startIndex = text.value.toLowerCase().indexOf(word.toLowerCase(), currentIndex); const endIndex = startIndex + word.length; highlightedText += text.value.substring(currentIndex, startIndex); highlightedText += `${text.value.substring(startIndex, endIndex)}`; currentIndex = endIndex; }); highlightedText += text.value.substring(currentIndex); return ; }; const Hits = ({ hits }) => { const handleHitClick = (url) => { const modifiedUrl = url.replace('https://ptb.discord.com/', 'https://discord.com/'); window.open(modifiedUrl, '_blank'); }; if (hits.length === 0) { return No results found. Try refining your search.; } return ( {hits.map((chat, index) => ( handleHitClick(chat.url)} style={{ cursor: "pointer", borderBottom: "1px solid rgba(255,255,255,0.4)" }}> ))} ); }; const CustomSearchBox = connectSearchBox(SearchBox); const CustomHits = connectHits(Hits); return (
Can't find what you're looking for?
setFormMail(e.target.value)} /> setMessage(e.target.value)} />
{formMessage}
Search by Algolia logo
); }; export default DiscordChat;