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";