mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 22:16:40 +00:00
working typescript version
This commit is contained in:
1 parent
581d6011e0
commit
cff746aa38
119 files changed
+247
-189
No files matched your search
@@ -0,0 +1,59 @@
|
||||
import React, { useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { makeStyles } from "@material-ui/core/styles";
|
||||
import { TextField } from "@material-ui/core";
|
||||
import TweetList from "./tweet/TweetList";
|
||||
|
||||
import Nui from "../../../os/nui-events/utils/Nui";
|
||||
import SearchButton from "./buttons/SearchButton";
|
||||
import { useFilteredTweets } from "../hooks/useFilteredTweets";
|
||||
|
||||
const useStyles = makeStyles({
|
||||
root: {
|
||||
width: "100%",
|
||||
},
|
||||
searchContainer: {
|
||||
padding: "15px",
|
||||
},
|
||||
search: {
|
||||
width: "100%",
|
||||
},
|
||||
});
|
||||
|
||||
function TwitterSearch() {
|
||||
const classes = useStyles();
|
||||
const { t } = useTranslation();
|
||||
const [searchValue, setSearchValue] = useState("");
|
||||
const { tweets, setTweets } = useFilteredTweets();
|
||||
|
||||
const handleChange = (e) => setSearchValue(e.target.value);
|
||||
|
||||
const handleSubmit = () => {
|
||||
const cleanedSearchValue = searchValue.trim();
|
||||
if (!cleanedSearchValue) return;
|
||||
|
||||
Nui.send("phone:fetchTweetsFiltered", cleanedSearchValue);
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className={classes.root}>
|
||||
<div className={classes.searchContainer}>
|
||||
<TextField
|
||||
className={classes.search}
|
||||
placeholder={t("APPS_TWITTER_SEARCH_TWEETS_PLACEHOLDER")}
|
||||
label={t("APPS_TWITTER_SEARCH_TWEETS")}
|
||||
value={searchValue}
|
||||
onChange={handleChange}
|
||||
size="medium"
|
||||
inputRef={(input) => input && input.focus()}
|
||||
/>
|
||||
</div>
|
||||
{tweets && tweets.length > 0 && <TweetList tweets={tweets} />}
|
||||
</div>
|
||||
<SearchButton handleClick={handleSubmit} />
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
export default TwitterSearch;
|
||||
Reference in new issue
Block a user