sample wip
This commit is contained in:
1 parent
ffc023f419
commit
c99b148e15
6 files changed
+22
-14
No files matched your search
+1
-2
@@ -134,8 +134,7 @@ export default function createOffers(log: Log, pg: Pg) {
|
|||||||
async function samples() {
|
async function samples() {
|
||||||
const user = await pg.userFindEmail('ntr@mnml.gg');
|
const user = await pg.userFindEmail('ntr@mnml.gg');
|
||||||
const offerGroups = await userOffers(user);
|
const offerGroups = await userOffers(user);
|
||||||
const i = Math.floor(Math.random() * offerGroups.length / 2);
|
return offerGroups.slice(0, 1);
|
||||||
return offerGroups[i];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
+8
-5
@@ -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)}`);
|
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() {
|
async function onConnection() {
|
||||||
|
if (!user) return anonConnection();
|
||||||
|
|
||||||
const userMsg: UserMessage = [RpcMessageType.User, user];
|
const userMsg: UserMessage = [RpcMessageType.User, user];
|
||||||
send(userMsg);
|
send(userMsg);
|
||||||
|
|
||||||
const wants = await pg.userWants(user);
|
const wants = await pg.userWants(user);
|
||||||
const wantsMsg: WantsMessage = [RpcMessageType.Wants, wants];
|
const wantsMsg: WantsMessage = [RpcMessageType.Wants, wants];
|
||||||
send(wantsMsg);
|
send(wantsMsg);
|
||||||
|
|
||||||
const samples = await offers.samples();
|
|
||||||
const sampleMsg: OfferSamplesMessage = [RpcMessageType.OfferSamples, samples];
|
|
||||||
// console.log(samples);
|
|
||||||
send(sampleMsg);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function send(msg: RpcMessage) {
|
function send(msg: RpcMessage) {
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import { useSelector, useDispatch } from 'react-redux'
|
|||||||
import http from './../http';
|
import http from './../http';
|
||||||
import { State, userState } from './../store';
|
import { State, userState } from './../store';
|
||||||
import Swirl from './../components/swirl';
|
import Swirl from './../components/swirl';
|
||||||
|
import OfferGroup from './../components/offer.group';
|
||||||
|
|
||||||
const Login = ({ mode }) => {
|
const Login = ({ mode }) => {
|
||||||
const dispatch = useDispatch()
|
const dispatch = useDispatch()
|
||||||
@@ -94,16 +95,22 @@ const Login = ({ mode }) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
function LoginPage({ mode }) {
|
function LoginPage({ mode }) {
|
||||||
|
const offers = useSelector((state: State) => state.offers);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div class="landing">
|
<div class="landing">
|
||||||
<Login mode={mode} />
|
<Login mode={mode} />
|
||||||
|
<div class='offers'>
|
||||||
|
{offers.map(OfferGroup)}
|
||||||
|
<div>
|
||||||
<Swirl />
|
<Swirl />
|
||||||
<div class='words'>
|
<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>We bundle orders together from thousands of online stores to reduce the cost of shipping vinyl.</p>
|
||||||
<p>Based in Preston.</p>
|
<p>Based in Preston.</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ export const userState = createSlice({
|
|||||||
|
|
||||||
export const offersState = createSlice({
|
export const offersState = createSlice({
|
||||||
name: 'offers',
|
name: 'offers',
|
||||||
initialState: null,
|
initialState: [],
|
||||||
reducers: {
|
reducers: {
|
||||||
set: (state, action) => action.payload
|
set: (state, action) => action.payload
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -217,6 +217,7 @@ button, [type=submit] {
|
|||||||
grid-gap: calc(var(--spacing-double) * 2);
|
grid-gap: calc(var(--spacing-double) * 2);
|
||||||
grid-template-areas:
|
grid-template-areas:
|
||||||
"login swirl"
|
"login swirl"
|
||||||
|
"login sample"
|
||||||
"login words";
|
"login words";
|
||||||
|
|
||||||
.login {
|
.login {
|
||||||
@@ -227,8 +228,8 @@ button, [type=submit] {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.swirl {
|
.swirl {
|
||||||
grid-area: swirl;
|
// grid-area: swirl;
|
||||||
height: 15rem;
|
height: 5rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.words {
|
.words {
|
||||||
@@ -344,8 +345,6 @@ article {
|
|||||||
}
|
}
|
||||||
|
|
||||||
form {
|
form {
|
||||||
margin-bottom: var(--spacing);
|
|
||||||
|
|
||||||
label, input {
|
label, input {
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
@@ -365,7 +364,6 @@ form {
|
|||||||
text-transform: uppercase;
|
text-transform: uppercase;
|
||||||
margin-bottom: var(--spacing-half);
|
margin-bottom: var(--spacing-half);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
a {
|
a {
|
||||||
|
|||||||
@@ -84,6 +84,7 @@ export default function createSocket(dispatch) {
|
|||||||
Offers: onOffers,
|
Offers: onOffers,
|
||||||
User: onUser,
|
User: onUser,
|
||||||
|
|
||||||
|
OfferSamples: onOffers,
|
||||||
AcpOffers: onAcpOffers,
|
AcpOffers: onAcpOffers,
|
||||||
|
|
||||||
Pong: onPong,
|
Pong: onPong,
|
||||||
|
|||||||
Reference in new issue
Block a user