From f0e366a73d3f59c302f12f9aff4f91c76e8cd2c0 Mon Sep 17 00:00:00 2001 From: ntr Date: Mon, 24 Oct 2022 19:23:06 +1100 Subject: [PATCH] styles --- client/src/routes/list.tsx | 8 +++++++- client/src/routes/offers.tsx | 14 ++++++-------- client/src/store.tsx | 4 ++-- client/src/style/index.less | 2 +- 4 files changed, 16 insertions(+), 12 deletions(-) diff --git a/client/src/routes/list.tsx b/client/src/routes/list.tsx index 9d4ab3b..6cbf31c 100644 --- a/client/src/routes/list.tsx +++ b/client/src/routes/list.tsx @@ -1,6 +1,8 @@ import { h } from 'preact'; import { useSelector } from 'react-redux' +import { route } from 'preact-router'; + import { State } from './../store' import Want from './../components/want'; @@ -14,10 +16,14 @@ interface Props { const List = ({ user }: Props) => { const wants = useSelector((state: State) => state.wants); - if (!wants.length) { + if (!wants) { return
loading...
; } + if (!wants.length) { + route('/search'); + } + return (
{wants.map(Want)} diff --git a/client/src/routes/offers.tsx b/client/src/routes/offers.tsx index e5be866..d9396df 100644 --- a/client/src/routes/offers.tsx +++ b/client/src/routes/offers.tsx @@ -12,17 +12,15 @@ function Home() { const dispatch = useDispatch() const offers = useSelector((state: State) => state.offers); - // if (!offers.length) { - // return ( - //
- // loading... - //
- // ); - // } + const groups = Object.values(offers); + + if (!groups.length) { + route('/search'); + } return (
- {Object.values(offers).map(WantOffers)} + {groups.map(WantOffers)}
); } diff --git a/client/src/store.tsx b/client/src/store.tsx index 9277344..c846e73 100644 --- a/client/src/store.tsx +++ b/client/src/store.tsx @@ -11,7 +11,7 @@ export const userState = createSlice({ export const offersState = createSlice({ name: 'offers', - initialState: [], + initialState: {}, reducers: { set: (state, action) => action.payload }, @@ -27,7 +27,7 @@ export const acpOffersState = createSlice({ export const wantsState = createSlice({ name: 'wants', - initialState: [], + initialState: null, reducers: { set: (state, action) => action.payload }, diff --git a/client/src/style/index.less b/client/src/style/index.less index 5ece7cd..f62c3af 100644 --- a/client/src/style/index.less +++ b/client/src/style/index.less @@ -394,7 +394,7 @@ header { .offer { display: grid; grid-template-columns: 1fr min-content; - grid-template-rows: 1fr min-content; + grid-template-rows: min-content min-content; grid-template-areas: "details img" "lines lines";