diff --git a/backend/go-app/go.mod b/backend/go-app/go.mod index c425a292..adfd9643 100644 --- a/backend/go-app/go.mod +++ b/backend/go-app/go.mod @@ -18,7 +18,7 @@ require ( github.com/gorilla/mux v1.8.0 github.com/h2non/filetype v1.1.3 github.com/satori/go.uuid v1.2.0 - github.com/shuffle/shuffle-shared v0.6.2 + github.com/shuffle/shuffle-shared v0.6.14 golang.org/x/crypto v0.16.0 google.golang.org/api v0.125.0 google.golang.org/grpc v1.55.0 diff --git a/frontend/src/components/DiscordChat.jsx b/frontend/src/components/DiscordChat.jsx new file mode 100644 index 00000000..e1d226b8 --- /dev/null +++ b/frontend/src/components/DiscordChat.jsx @@ -0,0 +1,222 @@ +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)} + 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;