clearing unused files
This commit is contained in:
@@ -1,19 +0,0 @@
|
|||||||
import React from 'react';
|
|
||||||
import { render } from '@testing-library/react';
|
|
||||||
import { Provider } from 'react-redux';
|
|
||||||
import { store } from './app/store';
|
|
||||||
import App from './App';
|
|
||||||
|
|
||||||
test('renders a title', () => {
|
|
||||||
const { getByText } = render(
|
|
||||||
<Provider store={store}>
|
|
||||||
<App />
|
|
||||||
</Provider>
|
|
||||||
);
|
|
||||||
|
|
||||||
expect(getAllByText(/cat/)).toBeInTheDocument();
|
|
||||||
});
|
|
||||||
|
|
||||||
test('store is not empty or falsy', () => {
|
|
||||||
expect(store).not.toBeNull();
|
|
||||||
})
|
|
||||||
@@ -28,6 +28,7 @@
|
|||||||
|
|
||||||
img, video {
|
img, video {
|
||||||
max-height: 45rem;
|
max-height: 45rem;
|
||||||
|
max-width: 75%;
|
||||||
object-fit: contain;
|
object-fit: contain;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,53 +0,0 @@
|
|||||||
import React, { useState, useEffect } from "react";
|
|
||||||
import { useDispatch, useSelector } from "react-redux";
|
|
||||||
import { searchByActive, /* selectSearchResults */ } from '../posts/postsSlice';
|
|
||||||
import { selectActive, /* selectAllSubs */ } from "../reddit/redditSlice";
|
|
||||||
|
|
||||||
export default function SearchBar() {
|
|
||||||
const dispatch = useDispatch();
|
|
||||||
|
|
||||||
// const selectedSubs = useSelector(selectAllSubs);
|
|
||||||
const activeSubs = useSelector(selectActive);
|
|
||||||
|
|
||||||
const [term, setTerm] = useState('');
|
|
||||||
const [results, setResults] = useState(null);
|
|
||||||
// const searchData = useSelector(selectSearchResults);
|
|
||||||
|
|
||||||
const handleChange = (e) => {
|
|
||||||
e.preventDefault();
|
|
||||||
setTerm(e.target.value);
|
|
||||||
}
|
|
||||||
|
|
||||||
const handleSubmit = () => {
|
|
||||||
if (term && activeSubs) {
|
|
||||||
let extracted = [];
|
|
||||||
for (let sub in activeSubs) {
|
|
||||||
extracted.push(sub);
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log(extracted);
|
|
||||||
let mapped = extracted.map((sub) => dispatch(searchByActive({sub, term})));
|
|
||||||
Promise.all([...mapped]).then((data) => setResults(data));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
let active = true;
|
|
||||||
|
|
||||||
if (results && active) {
|
|
||||||
console.log(results);
|
|
||||||
}
|
|
||||||
|
|
||||||
return () => {
|
|
||||||
active = false;
|
|
||||||
}
|
|
||||||
}, [results, activeSubs]);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<input type="text" className="nav-searchbar" placeholder="Search posts" value={term ? term : ''} onChange={handleChange} />
|
|
||||||
<input type="submit" onClick={handleSubmit}></input>
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user