This commit is contained in:
ntr committed 2022-10-24 19:23:06 +11:00
1 parent 623d0f3938
commit f0e366a73d
4 files changed
+16 -12

No files matched your search

+7 -1
View File
@@ -1,6 +1,8 @@
import { h } from 'preact'; import { h } from 'preact';
import { useSelector } from 'react-redux' import { useSelector } from 'react-redux'
import { route } from 'preact-router';
import { State } from './../store' import { State } from './../store'
import Want from './../components/want'; import Want from './../components/want';
@@ -14,10 +16,14 @@ interface Props {
const List = ({ user }: Props) => { const List = ({ user }: Props) => {
const wants = useSelector((state: State) => state.wants); const wants = useSelector((state: State) => state.wants);
if (!wants.length) { if (!wants) {
return <div> loading... </div>; return <div> loading... </div>;
} }
if (!wants.length) {
route('/search');
}
return ( return (
<div class="list"> <div class="list">
{wants.map(Want)} {wants.map(Want)}
+6 -8
View File
@@ -12,17 +12,15 @@ function Home() {
const dispatch = useDispatch() const dispatch = useDispatch()
const offers = useSelector((state: State) => state.offers); const offers = useSelector((state: State) => state.offers);
// if (!offers.length) { const groups = Object.values(offers);
// return (
// <div class={'offers'}> if (!groups.length) {
// loading... route('/search');
// </div> }
// );
// }
return ( return (
<div class={'offers'}> <div class={'offers'}>
{Object.values(offers).map(WantOffers)} {groups.map(WantOffers)}
</div> </div>
); );
} }
+2 -2
View File
@@ -11,7 +11,7 @@ export const userState = createSlice({
export const offersState = createSlice({ export const offersState = createSlice({
name: 'offers', name: 'offers',
initialState: [], initialState: {},
reducers: { reducers: {
set: (state, action) => action.payload set: (state, action) => action.payload
}, },
@@ -27,7 +27,7 @@ export const acpOffersState = createSlice({
export const wantsState = createSlice({ export const wantsState = createSlice({
name: 'wants', name: 'wants',
initialState: [], initialState: null,
reducers: { reducers: {
set: (state, action) => action.payload set: (state, action) => action.payload
}, },
+1 -1
View File
@@ -394,7 +394,7 @@ header {
.offer { .offer {
display: grid; display: grid;
grid-template-columns: 1fr min-content; grid-template-columns: 1fr min-content;
grid-template-rows: 1fr min-content; grid-template-rows: min-content min-content;
grid-template-areas: grid-template-areas:
"details img" "details img"
"lines lines"; "lines lines";