Sliders for accepting
This commit is contained in:
1 parent
445821aa10
commit
5e86a52d43
5 files changed
+111
-17
No files matched your search
+14
@@ -22,6 +22,7 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/plugin-transform-react-jsx-source": "^7.18.6",
|
"@babel/plugin-transform-react-jsx-source": "^7.18.6",
|
||||||
|
"@types/lodash": "^4.17.10",
|
||||||
"@typescript-eslint/eslint-plugin": "^5.30.6",
|
"@typescript-eslint/eslint-plugin": "^5.30.6",
|
||||||
"@typescript-eslint/parser": "^5.30.6",
|
"@typescript-eslint/parser": "^5.30.6",
|
||||||
"eslint": "^8.20.0",
|
"eslint": "^8.20.0",
|
||||||
@@ -3009,6 +3010,13 @@
|
|||||||
"integrity": "sha512-wOuvG1SN4Us4rez+tylwwwCV1psiNVOkJeM3AUWUNWg/jDQY2+HE/444y5gc+jBmRqASOm2Oeh5c1axHobwRKQ==",
|
"integrity": "sha512-wOuvG1SN4Us4rez+tylwwwCV1psiNVOkJeM3AUWUNWg/jDQY2+HE/444y5gc+jBmRqASOm2Oeh5c1axHobwRKQ==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"node_modules/@types/lodash": {
|
||||||
|
"version": "4.17.10",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.17.10.tgz",
|
||||||
|
"integrity": "sha512-YpS0zzoduEhuOWjAotS6A5AVCva7X4lVlYLF0FYHAY9sdraBfnatttHItlWeZdGhuEkf+OzMNg2ZYAx8t+52uQ==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
"node_modules/@types/mime": {
|
"node_modules/@types/mime": {
|
||||||
"version": "3.0.0",
|
"version": "3.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/@types/mime/-/mime-3.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/@types/mime/-/mime-3.0.0.tgz",
|
||||||
@@ -23437,6 +23445,12 @@
|
|||||||
"integrity": "sha512-wOuvG1SN4Us4rez+tylwwwCV1psiNVOkJeM3AUWUNWg/jDQY2+HE/444y5gc+jBmRqASOm2Oeh5c1axHobwRKQ==",
|
"integrity": "sha512-wOuvG1SN4Us4rez+tylwwwCV1psiNVOkJeM3AUWUNWg/jDQY2+HE/444y5gc+jBmRqASOm2Oeh5c1axHobwRKQ==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"@types/lodash": {
|
||||||
|
"version": "4.17.10",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.17.10.tgz",
|
||||||
|
"integrity": "sha512-YpS0zzoduEhuOWjAotS6A5AVCva7X4lVlYLF0FYHAY9sdraBfnatttHItlWeZdGhuEkf+OzMNg2ZYAx8t+52uQ==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
"@types/mime": {
|
"@types/mime": {
|
||||||
"version": "3.0.0",
|
"version": "3.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/@types/mime/-/mime-3.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/@types/mime/-/mime-3.0.0.tgz",
|
||||||
|
|||||||
Regular → Executable
+1
@@ -22,6 +22,7 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/plugin-transform-react-jsx-source": "^7.18.6",
|
"@babel/plugin-transform-react-jsx-source": "^7.18.6",
|
||||||
|
"@types/lodash": "^4.17.10",
|
||||||
"@typescript-eslint/eslint-plugin": "^5.30.6",
|
"@typescript-eslint/eslint-plugin": "^5.30.6",
|
||||||
"@typescript-eslint/parser": "^5.30.6",
|
"@typescript-eslint/parser": "^5.30.6",
|
||||||
"eslint": "^8.20.0",
|
"eslint": "^8.20.0",
|
||||||
|
|||||||
+8
-1
@@ -16,7 +16,14 @@ import Search from './routes/search';
|
|||||||
import List from './routes/list';
|
import List from './routes/list';
|
||||||
import Info from './routes/info';
|
import Info from './routes/info';
|
||||||
|
|
||||||
if (window.location.host === 'matescrates.au') LogRocket.init('yh0dy3/mcrates');
|
if (window.location.host === 'crates.strix.systems') LogRocket.init('yh0dy3/mcrates');
|
||||||
|
|
||||||
|
|
||||||
|
// ██ ██ ███████ █████ ██████ ███████ ███████ ██████ ██████ █████ ██████ ██ ██
|
||||||
|
// ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
|
||||||
|
// ██ █ ██ █████ ███████ ██████ █████ ███████ ██ ██ ██████ ███████ ██ █████
|
||||||
|
// ██ ███ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
|
||||||
|
// ███ ███ ███████ ██ ██ ██ ██ ███████ ███████ ██████ ██████ ██ ██ ██████ ██ ██
|
||||||
|
|
||||||
|
|
||||||
const Mcrates = () => {
|
const Mcrates = () => {
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { h } from 'preact';
|
import { h } from 'preact';
|
||||||
import { ExternalLink, Check } from 'react-feather';
|
import { ExternalLink, Check } from 'react-feather';
|
||||||
import { useState } from 'preact/hooks';
|
import { useState } from 'preact/hooks';
|
||||||
|
import _ from 'lodash'
|
||||||
|
|
||||||
import { useSelector, useDispatch } from 'react-redux'
|
import { useSelector, useDispatch } from 'react-redux'
|
||||||
import { State } from './../store';
|
import { State } from './../store';
|
||||||
@@ -58,6 +59,73 @@ function OfferPriceBtn(offer) {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function OfferConditionSlider([condition, offers], i, groupId, rangeMin, rangeMax) {
|
||||||
|
// const ws = useSelector((state: State) => state.ws);
|
||||||
|
// const accepted = offer.status === 'Accepted';
|
||||||
|
// const confirmed = offer.status === 'Confirmed';
|
||||||
|
|
||||||
|
// function setStatus() {
|
||||||
|
// if (accepted) return ws.sendOfferStatusSet(offer.id, 'Pending')
|
||||||
|
// ws.sendOfferStatusSet(offer.id, 'Accepted');
|
||||||
|
// }
|
||||||
|
|
||||||
|
// const classes = `${accepted ? 'accepted' : ''} ${confirmed ? 'confirmed' : ''}`;
|
||||||
|
// const btnText = accepted
|
||||||
|
// ? offer.status
|
||||||
|
// : 'Accept';
|
||||||
|
|
||||||
|
// const title = accepted
|
||||||
|
// ? 'Click to cancel'
|
||||||
|
// : 'Click to accept this offer';
|
||||||
|
|
||||||
|
// return (
|
||||||
|
// <button disabled={confirmed} title={title} onClick={() => setStatus()} class={classes}>${offer.total} {offer.condition}</button>
|
||||||
|
// )
|
||||||
|
|
||||||
|
const min = _.first(offers).total
|
||||||
|
const max = _.last(offers).total
|
||||||
|
// const step = min === max ? max : "any"
|
||||||
|
const step = 'any'
|
||||||
|
const id = `${groupId}-${i}`
|
||||||
|
const markersId = `${id}-markers`
|
||||||
|
const steps = offers.map(o => o.total)
|
||||||
|
|
||||||
|
const [acceptedPrice, setAcceptedPrice] = useState(0)
|
||||||
|
|
||||||
|
function onChange(target) {
|
||||||
|
const highest = () => {
|
||||||
|
return _.findLast(steps, s => target.value >= Number(s)) || 0
|
||||||
|
}
|
||||||
|
|
||||||
|
const v = highest()
|
||||||
|
setAcceptedPrice(v)
|
||||||
|
target.value = v
|
||||||
|
}
|
||||||
|
|
||||||
|
const acceptedPriceLabel = acceptedPrice ? `$${acceptedPrice}` : '-'
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div key={id}>
|
||||||
|
<label for={id}>{condition}</label><br />
|
||||||
|
<label for={id}>{acceptedPriceLabel}</label><br />
|
||||||
|
<input
|
||||||
|
type="range"
|
||||||
|
id={id}
|
||||||
|
name={id}
|
||||||
|
list={markersId}
|
||||||
|
step={step}
|
||||||
|
min={rangeMin}
|
||||||
|
max={rangeMax}
|
||||||
|
value={acceptedPrice}
|
||||||
|
onChange={e => onChange((e.target as HTMLInputElement)) } />
|
||||||
|
|
||||||
|
<datalist id={markersId}>
|
||||||
|
{offers.map(o => <option value={o.total}></option>)}
|
||||||
|
</datalist>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
export default function OfferGroup(group, i) {
|
export default function OfferGroup(group, i) {
|
||||||
const ws = useSelector((state: State) => state.ws);
|
const ws = useSelector((state: State) => state.ws);
|
||||||
@@ -66,6 +134,10 @@ export default function OfferGroup(group, i) {
|
|||||||
const descriptions = group.details.formats.map(f => f.descriptions.join(' ')).join(' ')
|
const descriptions = group.details.formats.map(f => f.descriptions.join(' ')).join(' ')
|
||||||
const detailText = `${format} ${descriptions}`;
|
const detailText = `${format} ${descriptions}`;
|
||||||
|
|
||||||
|
const conditions = Object.entries(_.groupBy(group.offers, 'condition'))
|
||||||
|
const rangeMin = 0
|
||||||
|
const rangeMax = _.maxBy(group.offers, 'total').total
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div class="offer" key={i} id={group.details.id}>
|
<div class="offer" key={i} id={group.details.id}>
|
||||||
<section>
|
<section>
|
||||||
@@ -76,8 +148,8 @@ export default function OfferGroup(group, i) {
|
|||||||
<div class='alt-text details'>Status: {group.status}</div>
|
<div class='alt-text details'>Status: {group.status}</div>
|
||||||
</section>
|
</section>
|
||||||
<img src={group.details.thumb} />
|
<img src={group.details.thumb} />
|
||||||
<div class="lines">
|
<div>
|
||||||
{group.offers.map(o => OfferPriceBtn(o))}
|
{conditions.map((c, i) => OfferConditionSlider(c, i, group.details.id, rangeMin, rangeMax))}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|||||||
+14
-14
@@ -1,16 +1,18 @@
|
|||||||
version: "3.3"
|
version: "3.3"
|
||||||
|
|
||||||
services:
|
services:
|
||||||
# pg:
|
pg:
|
||||||
# image: postgres:latest
|
image: postgres:latest
|
||||||
# environment:
|
environment:
|
||||||
# POSTGRES_USER: '${POSTGRES_USER}'
|
POSTGRES_USER: '${POSTGRES_USER}'
|
||||||
# POSTGRES_DB: '${POSTGRES_DB}'
|
POSTGRES_DB: '${POSTGRES_DB}'
|
||||||
# POSTGRES_PASSWORD: '${POSTGRES_PASSWORD}'
|
POSTGRES_PASSWORD: '${POSTGRES_PASSWORD}'
|
||||||
# ports:
|
volumes:
|
||||||
# - '45432:5432'
|
# so ez
|
||||||
# volumes:
|
# insane
|
||||||
# - "./db:/var/lib/postgresql/data"
|
- "./pg:/docker-entrypoint-initdb.d"
|
||||||
|
ports:
|
||||||
|
- '45432:5432'
|
||||||
|
|
||||||
api:
|
api:
|
||||||
image: crates/api
|
image: crates/api
|
||||||
@@ -18,8 +20,8 @@ services:
|
|||||||
context: ./api
|
context: ./api
|
||||||
dockerfile: ./api.Dockerfile
|
dockerfile: ./api.Dockerfile
|
||||||
working_dir: /opt/crates/api
|
working_dir: /opt/crates/api
|
||||||
# depends_on:
|
depends_on:
|
||||||
# - 'pg'
|
- 'pg'
|
||||||
command: npm start
|
command: npm start
|
||||||
environment:
|
environment:
|
||||||
DATABASE_URL: 'postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}:5432/${POSTGRES_DB}?schema=public'
|
DATABASE_URL: 'postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}:5432/${POSTGRES_DB}?schema=public'
|
||||||
@@ -29,8 +31,6 @@ services:
|
|||||||
volumes:
|
volumes:
|
||||||
- "./api:/opt/crates/api"
|
- "./api:/opt/crates/api"
|
||||||
- "/opt/crates/api/node_modules"
|
- "/opt/crates/api/node_modules"
|
||||||
extra_hosts:
|
|
||||||
- "pg:host-gateway"
|
|
||||||
|
|
||||||
migrate:
|
migrate:
|
||||||
restart: on-failure:3
|
restart: on-failure:3
|
||||||
|
|||||||
Reference in new issue
Block a user