offers changes and select status

This commit is contained in:
ntr committed 2022-09-10 17:47:18 +10:00
1 parent bbc3fe6b48
commit 5f853696ab
10 files changed
+89 -18

No files matched your search

+4
View File
@@ -2,6 +2,10 @@ import { route } from 'preact-router';
import http from './http';
const actions = store => ({
setWs: function setWs(state, ws) {
return { ws };
},
setUser: function setUser(state, user) {
return { user };
},
+2 -1
View File
@@ -26,11 +26,12 @@ async function init() {
if (error) return route('/login');
route('/bundles');
store.setState({ user });
store.setState({ ws });
}
init();
const App = () =>{
const App = () => {
return (
<Provider store={store}>
<main id="app">
+7
View File
@@ -96,6 +96,13 @@ const actions = {
id,
});
},
postOfferStatus: async function postOfferStatus(id, status) {
return api.post('/acp/offer/status', {
id,
status,
});
},
};
export default actions;
+17 -2
View File
@@ -1,12 +1,22 @@
import { h } from 'preact';
import { useState, useEffect } from 'preact/hooks';
import { connect } from 'unistore/preact'
import http from './../http';
import AcpOffer from './../components/acp.offer';
function Item(item) {
import { Status } from './../../../api/src/offers';
function ItemEl({ item, ws }) {
console.log(item);
console.log(ws);
const statuses = Object.entries(Status).map(([label, value]) => (
<option value={value}>{label}</option>
));
function onChange(e) {
console.log(item.id, e.target.value);
}
return (
<div key={item.id}>
@@ -15,10 +25,15 @@ function Item(item) {
</a>
<h5 class='alt-text'>{item.total}</h5>
<h5>{item.status}</h5>
<select onChange={onChange}>
{statuses}
</select>
</div>
);
}
const Item = connect(['ws'], {}, ItemEl);
function SellerGroup(group) {
return (
<div class="bundle">
@@ -29,7 +44,7 @@ function SellerGroup(group) {
</section>
<div class='items'>
{group.offers.map(Item)}
{group.offers.map(i => <Item item={i} />)}
</div>
</div>
)
+1
View File
@@ -5,5 +5,6 @@ export default function createStore() {
bundles: [],
offers: [],
user: null,
ws: null,
});
};