Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
digitaldesigndj committed Jul 29, 2023
1 parent a13ec24 commit 7577ba0
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
11 changes: 6 additions & 5 deletions routes/deal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ export const handler = {
GET: (req, ctx) => {
const { session } = ctx.state
const deck = getNewCards()
const deck_id = crypto.randomUUID()
// const deck_id = crypto.randomUUID()
const cards = [...deck].splice(0, 5)
session.set(`deck-${deck_id}`, JSON.stringify({ deck }))
// session.set(`deck-${deck_id}`, JSON.stringify({ deck }))
session.set("deck", JSON.stringify({ deck }))
// ctx.store.expire(`deck-${deck_id}`, 5 * 60)
return ctx.render({ ...ctx.state, cards, deck_id })
return ctx.render({ ...ctx.state, cards })
},
POST: async (req, ctx) => {
console.log(await req.formData())
Expand All @@ -26,7 +27,7 @@ export const handler = {

export default function Home(props) {
const { data } = props
const { cards, deck_id, streak } = data
const { cards, streak } = data
return (
<Layout data={data}>
<div class="p-4 mx-auto max-w-screen-md">
Expand All @@ -41,7 +42,7 @@ export default function Home(props) {
Now how many in a row can you do before you make a mistake?
</p>
)}
<PokerGame cards={cards} deck_id={deck_id} />
<PokerGame cards={cards} />
<Keyboard />
{/* <pre>{JSON.stringify( props, null, 2 )}</pre> */}
</div>
Expand Down
9 changes: 5 additions & 4 deletions routes/draw.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ export const handler = {
// const deck = getNewCards();
// const deck_id = crypto.randomUUID();
// const cards = deck.splice(0, 5);
const deck_id = data.get("deck_id")
const redis_data = session.get(`deck-${deck_id}`)
// const deck_id = data.get("deck_id")
// const redis_data = session.get(`deck-${deck_id}`)
const redis_data = session.get("deck")
// await ctx.store.get(`deck-${deck_id}`)
if (redis_data) {
const hold_1 = data.get("hold_1") ? true : false
Expand Down Expand Up @@ -59,11 +60,11 @@ export const handler = {
session.set("streak", 0)
ctx.state.streak = 0
}
session.set(`deck-${deck_id}`, null)
session.set("deck", null)
// session.set(`deck-${deck_id}`, null)
return ctx.render({
...ctx.state,
cards,
deck_id,
result,
})
}
Expand Down
4 changes: 2 additions & 2 deletions routes/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ export default function Home({ data }) {
)
}

export const PokerGame = ({ cards, result, deck_id }) => {
export const PokerGame = ({ cards, result }) => {
const cards_wrapper_classes = "flex gap-2 w-full grid grid-cols-5 hand"
if (!cards) {
return (
Expand All @@ -354,7 +354,7 @@ export const PokerGame = ({ cards, result, deck_id }) => {
return (
<form action="/draw" method="POST">
{/* <input type="hidden" name="next" value={JSON.stringify(cards)} /> */}
<input type="hidden" name="deck_id" value={deck_id} />
{/* <input type="hidden" name="deck_id" value={deck_id} /> */}
<div class={cards_wrapper_classes}>
{cards.map((card, idx) => (
<Card card={card} idx={idx} active={true} />
Expand Down

0 comments on commit 7577ba0

Please sign in to comment.