sample wip

This commit is contained in:
ntr committed 2022-11-26 18:22:13 +11:00
1 parent ffc023f419
commit c99b148e15
6 files changed
+22 -14

No files matched your search

+1 -2
View File
@@ -134,8 +134,7 @@ export default function createOffers(log: Log, pg: Pg) {
async function samples() {
const user = await pg.userFindEmail('ntr@mnml.gg');
const offerGroups = await userOffers(user);
const i = Math.floor(Math.random() * offerGroups.length / 2);
return offerGroups[i];
return offerGroups.slice(0, 1);
}
return {
+8 -5
View File
@@ -112,18 +112,21 @@ export default function createRpc(log: Log, pg: Pg, ws, discogs: Discogs, offers
throw new Error(`Invalid parameters for message type ${msgType}: ${JSON.stringify(message)}`);
}
async function anonConnection() {
const samples = await offers.samples();
const sampleMsg: OfferSamplesMessage = [RpcMessageType.OfferSamples, samples];
send(sampleMsg);
}
async function onConnection() {
if (!user) return anonConnection();
const userMsg: UserMessage = [RpcMessageType.User, user];
send(userMsg);
const wants = await pg.userWants(user);
const wantsMsg: WantsMessage = [RpcMessageType.Wants, wants];
send(wantsMsg);
const samples = await offers.samples();
const sampleMsg: OfferSamplesMessage = [RpcMessageType.OfferSamples, samples];
// console.log(samples);
send(sampleMsg);
}
function send(msg: RpcMessage) {
+8 -1
View File
@@ -6,6 +6,7 @@ import { useSelector, useDispatch } from 'react-redux'
import http from './../http';
import { State, userState } from './../store';
import Swirl from './../components/swirl';
import OfferGroup from './../components/offer.group';
const Login = ({ mode }) => {
const dispatch = useDispatch()
@@ -94,16 +95,22 @@ const Login = ({ mode }) => {
};
function LoginPage({ mode }) {
const offers = useSelector((state: State) => state.offers);
return (
<div class="landing">
<Login mode={mode} />
<div class='offers'>
{offers.map(OfferGroup)}
<div>
<Swirl />
<div class='words'>
<p>Mates Crates is a record importing service.</p>
<p>We bundle orders together from thousands of online stores to reduce the cost of shipping vinyl.</p>
<p>Based in Preston.</p>
</div>
</div>
</div>
</div>
)
}
+1 -1
View File
@@ -11,7 +11,7 @@ export const userState = createSlice({
export const offersState = createSlice({
name: 'offers',
initialState: null,
initialState: [],
reducers: {
set: (state, action) => action.payload
},
+3 -5
View File
@@ -217,6 +217,7 @@ button, [type=submit] {
grid-gap: calc(var(--spacing-double) * 2);
grid-template-areas:
"login swirl"
"login sample"
"login words";
.login {
@@ -227,8 +228,8 @@ button, [type=submit] {
}
.swirl {
grid-area: swirl;
height: 15rem;
// grid-area: swirl;
height: 5rem;
}
.words {
@@ -344,8 +345,6 @@ article {
}
form {
margin-bottom: var(--spacing);
label, input {
display: block;
}
@@ -365,7 +364,6 @@ form {
text-transform: uppercase;
margin-bottom: var(--spacing-half);
}
}
a {
+1
View File
@@ -84,6 +84,7 @@ export default function createSocket(dispatch) {
Offers: onOffers,
User: onUser,
OfferSamples: onOffers,
AcpOffers: onAcpOffers,
Pong: onPong,