import { Button, Divider, Page, Panel, TextField, UserCard } from "../../ui"; import { ChangeEvent, useCallback, useEffect, useState } from "react"; import { RegisterVariantType, VariantLabel } from "."; import { IUser } from "../../../schemas"; import { getAllUsers } from "../../../util/apiUtils"; import { v4 } from 'uuid'; const AddFriends: RegisterVariantType = ({ transitionDisplay }) => { const [searchTerm, setSearchTerm] = useState(); const [userPool, setUserPool] = useState([]); const [friendResults, setFriendResults] = useState([]); const handleClick = async () => { transitionDisplay(VariantLabel.FinishUp); } // this isn't really working right now i don't think const handleRequestSent = useCallback((targetid: string | number) => { setUserPool((prev: IUser[]) => { const newResults = prev.filter((user: IUser) => { return user.id !== targetid; }) return newResults; }) }, []) // load available user pool on mount useEffect(() => { (async function() { const result = await getAllUsers(); if (result) setUserPool(result); })(); }, []) useEffect(() => { if (!searchTerm) { setFriendResults(new Array()); } else { const narrowedPool = userPool?.filter((person: IUser) => { if (person.firstname.toLowerCase().includes(searchTerm) || person.lastname.toLowerCase().includes(searchTerm) || person.handle.toLowerCase().includes(searchTerm)) return person; }) setFriendResults(narrowedPool); } }, [userPool, searchTerm]) return (

Cool, we'll keep all the recipes you post in that collection.

You can access that any time by clicking on "Collections" in your menu bar.

One last thing, and you'll be good to go!

If any of your friends already use Recipin, you can use the widget below to find them and add them!

This will allow you to share recipes and collections back and forth, and leave comments on each other's recipes.

If you know their email or unique handle, type it in below!

) => setSearchTerm(e.target.value.toLowerCase())} placeholder={'Search'} /> { friendResults && friendResults.map((friend: IUser) => { return handleRequestSent(friend.id!)} /> }) }
) } export default AddFriends;