Spaces:
Build error
Build error
Add 13 files
Browse files- Dockerfile +57 -0
- README.md +8 -7
- package.json +31 -0
- public/index.html +11 -0
- public/style.css +37 -0
- src/components/DiceGame.tsx +18 -0
- src/components/Game.tsx +5 -0
- src/components/PlinkoGame.tsx +18 -0
- src/components/RouletteGame.tsx +18 -0
- src/components/SlotMachine.tsx +18 -0
- src/features/auth/authSlice.ts +21 -0
- src/pages/index.tsx +56 -0
- tsconfig.json +28 -0
Dockerfile
ADDED
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
FROM node:18-alpine AS base
|
3 |
+
|
4 |
+
# Install dependencies only when needed
|
5 |
+
FROM base AS deps
|
6 |
+
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
|
7 |
+
RUN apk add --no-cache libc6-compat
|
8 |
+
WORKDIR /app
|
9 |
+
|
10 |
+
# Install dependencies based on the preferred package manager
|
11 |
+
COPY package.json package-lock.json* ./
|
12 |
+
RUN npm install
|
13 |
+
|
14 |
+
# Uncomment the following lines if you want to use a secret at buildtime,
|
15 |
+
# for example to access your private npm packages
|
16 |
+
# RUN --mount=type=secret,id=HF_EXAMPLE_SECRET,mode=0444,required=true # $(cat /run/secrets/HF_EXAMPLE_SECRET)
|
17 |
+
|
18 |
+
# Rebuild the source code only when needed
|
19 |
+
FROM base AS builder
|
20 |
+
WORKDIR /app
|
21 |
+
COPY --from=deps /app/node_modules ./node_modules
|
22 |
+
COPY . .
|
23 |
+
|
24 |
+
# Next.js collects completely anonymous telemetry data about general usage.
|
25 |
+
# Learn more here: https://nextjs.org/telemetry
|
26 |
+
# Uncomment the following line in case you want to disable telemetry during the build.
|
27 |
+
# ENV NEXT_TELEMETRY_DISABLED 1
|
28 |
+
|
29 |
+
RUN npm run build
|
30 |
+
|
31 |
+
# Production image, copy all the files and run next
|
32 |
+
FROM base AS runner
|
33 |
+
WORKDIR /app
|
34 |
+
|
35 |
+
ENV NODE_ENV production
|
36 |
+
# Uncomment the following line in case you want to disable telemetry during runtime.
|
37 |
+
# ENV NEXT_TELEMETRY_DISABLED 1
|
38 |
+
|
39 |
+
RUN addgroup --system --gid 1001 nodejs
|
40 |
+
RUN adduser --system --uid 1001 nextjs
|
41 |
+
|
42 |
+
COPY --from=builder /app/public ./public
|
43 |
+
|
44 |
+
# Automatically leverage output traces to reduce image size
|
45 |
+
# https://nextjs.org/docs/advanced-features/output-file-tracing
|
46 |
+
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
|
47 |
+
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
|
48 |
+
COPY --from=builder --chown=nextjs:nodejs /app/.next/cache ./.next/cache
|
49 |
+
# COPY --from=builder --chown=nextjs:nodejs /app/.next/cache/fetch-cache ./.next/cache/fetch-cache
|
50 |
+
|
51 |
+
USER nextjs
|
52 |
+
|
53 |
+
EXPOSE 3000
|
54 |
+
|
55 |
+
ENV PORT 3000
|
56 |
+
|
57 |
+
CMD ["node", "server.js"]
|
README.md
CHANGED
@@ -1,11 +1,12 @@
|
|
1 |
---
|
|
|
2 |
title: Next Test App
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
pinned: false
|
8 |
-
license: mit
|
9 |
---
|
10 |
|
11 |
-
|
|
|
|
|
|
1 |
---
|
2 |
+
license: apache-2.0
|
3 |
title: Next Test App
|
4 |
+
sdk: docker
|
5 |
+
emoji: 👨💻
|
6 |
+
colorFrom: yellow
|
7 |
+
colorTo: green
|
|
|
|
|
8 |
---
|
9 |
|
10 |
+
# Next Test App
|
11 |
+
|
12 |
+
This is a Next.js 12 example project created by a reality check.
|
package.json
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"name": "next-project",
|
3 |
+
"version": "1.0.0",
|
4 |
+
"description": "Next.js 12 example project",
|
5 |
+
"scripts": {
|
6 |
+
"dev": "next dev",
|
7 |
+
"build": "next build",
|
8 |
+
"start": "next start",
|
9 |
+
"lint": "next lint"
|
10 |
+
},
|
11 |
+
"dependencies": {
|
12 |
+
"next": "12.0.7",
|
13 |
+
"react": "18.2.0",
|
14 |
+
"react-dom": "18.2.0",
|
15 |
+
"react-redux": "7.1.0",
|
16 |
+
"redux": "4.0.4",
|
17 |
+
"redux-logger": "3.0.6",
|
18 |
+
"tailwindcss": "0.7.4",
|
19 |
+
"typescript": "4.5.4"
|
20 |
+
},
|
21 |
+
"devDependencies": {
|
22 |
+
"@types/node": "17.0.9",
|
23 |
+
"@types/react": "17.0.36",
|
24 |
+
"@types/react-dom": "17.0.11",
|
25 |
+
"@types/react-redux": "0.7.7",
|
26 |
+
"@types/redux-logger": "3.0.31",
|
27 |
+
"@types/tailwindcss": "0.7.4",
|
28 |
+
"@types/typescript": "4.5.4"
|
29 |
+
},
|
30 |
+
"license": "ISC"
|
31 |
+
}
|
public/index.html
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!DOCTYPE html>
|
2 |
+
<html lang="en">
|
3 |
+
<head>
|
4 |
+
<meta charset="UTF-8">
|
5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6 |
+
<title>Document</title>
|
7 |
+
</head>
|
8 |
+
<body>
|
9 |
+
<div id="app"></div>
|
10 |
+
</body>
|
11 |
+
</html>
|
public/style.css
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
html, body {
|
2 |
+
margin: 0;
|
3 |
+
padding: 0;
|
4 |
+
font-family: sans-serif;
|
5 |
+
}
|
6 |
+
|
7 |
+
.min-h-screen {
|
8 |
+
min-height: 100vh;
|
9 |
+
}
|
10 |
+
|
11 |
+
.flex {
|
12 |
+
display: flex;
|
13 |
+
}
|
14 |
+
|
15 |
+
.flex-col {
|
16 |
+
flex-direction: column;
|
17 |
+
}
|
18 |
+
|
19 |
+
.bg[#121212] {
|
20 |
+
background-color: #121212;
|
21 |
+
}
|
22 |
+
|
23 |
+
.text[#f0f0f0] {
|
24 |
+
color: #f0f0f0;
|
25 |
+
}
|
26 |
+
|
27 |
+
.text-z-0 {
|
28 |
+
z-index: 0;
|
29 |
+
}
|
30 |
+
|
31 |
+
.text-z-../..: {
|
32 |
+
z-index: -1;
|
33 |
+
}
|
34 |
+
|
35 |
+
.text-z-../.. {
|
36 |
+
z-index: -2;;
|
37 |
+
}
|
src/components/DiceGame.tsx
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
function DiceGame({ balance, onGameEnd }) {
|
2 |
+
// Existing code...
|
3 |
+
|
4 |
+
return (
|
5 |
+
<div>
|
6 |
+
<button
|
7 |
+
onClick={rollDice}
|
8 |
+
className="my-2 px-4 py-2 bg-[#facc15] rounded"
|
9 |
+
>
|
10 |
+
Roll
|
11 |
+
</button>
|
12 |
+
<BalanceDisplay balance={balance} />
|
13 |
+
<p>Last Roll Result: {roll}</p>
|
14 |
+
</div>
|
15 |
+
)
|
16 |
+
}
|
17 |
+
|
18 |
+
export default DiceGame
|
src/components/Game.tsx
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
function Game({ onGameEnd }) {
|
2 |
+
return <div>This is the game</div>
|
3 |
+
}
|
4 |
+
|
5 |
+
export default Game
|
src/components/PlinkoGame.tsx
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
function PlinkoGame({ balance, onGameEnd }) {
|
2 |
+
// Existing code...
|
3 |
+
|
4 |
+
return (
|
5 |
+
<div>
|
6 |
+
<button
|
7 |
+
onClick={dropPlinko}
|
8 |
+
className="my-2 px-4 py-2 bg-[#facc15] rounded"
|
9 |
+
>
|
10 |
+
Drop
|
11 |
+
</button>
|
12 |
+
<BalanceDisplay balance={balance} />
|
13 |
+
<p>Last Drop Result: {dropResult}</p>
|
14 |
+
</div>
|
15 |
+
)
|
16 |
+
}
|
17 |
+
|
18 |
+
export default PlinkoGame
|
src/components/RouletteGame.tsx
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
function RouletteGame({ balance, onGameEnd }) {
|
2 |
+
// Existing code...
|
3 |
+
|
4 |
+
return (
|
5 |
+
<div>
|
6 |
+
<button
|
7 |
+
onClick={spinRoulette}
|
8 |
+
className="my-2 px-4 py-2 bg-[#facc15] rounded"
|
9 |
+
>
|
10 |
+
Spin
|
11 |
+
</button>
|
12 |
+
<BalanceDisplay balance={balance} />
|
13 |
+
<p>Last Spin Result: {spinResult}</p>
|
14 |
+
</div>
|
15 |
+
)
|
16 |
+
}
|
17 |
+
|
18 |
+
export default RouletteGame
|
src/components/SlotMachine.tsx
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
function SlotMachine({ balance, onGameEnd }) {
|
2 |
+
// Existing code...
|
3 |
+
|
4 |
+
return (
|
5 |
+
<div>
|
6 |
+
<button
|
7 |
+
onClick={spinReels}
|
8 |
+
className="my-2 px-4 py-2 bg-[#facc15] rounded"
|
9 |
+
>
|
10 |
+
Spin
|
11 |
+
</button>
|
12 |
+
<BalanceDisplay balance={balance} />
|
13 |
+
<ul>{reelsDisplay}</ul>
|
14 |
+
</div>
|
15 |
+
)
|
16 |
+
}
|
17 |
+
|
18 |
+
export default SlotMachine
|
src/features/auth/authSlice.ts
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { createSlice } from '@reduxjs/toolkit'
|
2 |
+
import { useAuth0 } from '@auth0/auth0-react'
|
3 |
+
|
4 |
+
const authSlice = createSlice({
|
5 |
+
name: 'auth',
|
6 |
+
initialState: {
|
7 |
+
isAuthenticated: false
|
8 |
+
},
|
9 |
+
reducers: {
|
10 |
+
login(state) {
|
11 |
+
state.isAuthenticated = true
|
12 |
+
},
|
13 |
+
logout(state) {
|
14 |
+
state.isAuthenticated = false
|
15 |
+
}
|
16 |
+
}
|
17 |
+
})
|
18 |
+
|
19 |
+
export const { login, logout } = authSlice.actions
|
20 |
+
|
21 |
+
export default authSlice.reducer
|
src/pages/index.tsx
ADDED
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import React, { useState } from 'react'
|
2 |
+
import { useSelector, useDispatch } from 'react-redux'
|
3 |
+
import { authSlice } from '../features/auth/authSlice'
|
4 |
+
|
5 |
+
function IndexPage() {
|
6 |
+
const { isAuthenticated } = useSelector(state => state.auth)
|
7 |
+
const dispatch = useDispatch()
|
8 |
+
|
9 |
+
const [selectedGame, setSelectedGame] = useState(null)
|
10 |
+
|
11 |
+
const onGameSelected = (e) => {
|
12 |
+
setSelectedGame(e.target.value)
|
13 |
+
}
|
14 |
+
|
15 |
+
const onLogin = (e) => {
|
16 |
+
e.preventDefault()
|
17 |
+
dispatch(authSlice.actions.login())
|
18 |
+
}
|
19 |
+
|
20 |
+
const onLogout = (e) => {
|
21 |
+
e.preventDefault()
|
22 |
+
dispatch(authSlice.actions.logout())
|
23 |
+
}
|
24 |
+
|
25 |
+
return (
|
26 |
+
<div className="min-h-screen flex flex-col bg-[#121212] text-[#f0f0f0] font-roboto">
|
27 |
+
<ul className="flex justify-end">
|
28 |
+
<li>
|
29 |
+
{
|
30 |
+
isAuthenticated ? (
|
31 |
+
<button className="bg-[#121212] text-[#f0f0f0] font- roboto border-[#f0f0f0] py-2 px-4 rounded-l" onClick={onLogout}>Logout</button>
|
32 |
+
) : (
|
33 |
+
<button className="bg-[#121212] text-[#f0f0f0] font- roboto border-[#f0f0f0] py-2 px-4 rounded-l" onClick={onLogin}>Login</button>
|
34 |
+
)
|
35 |
+
}
|
36 |
+
</li>
|
37 |
+
</ul>
|
38 |
+
{
|
39 |
+
selectedGame ? (
|
40 |
+
<>
|
41 |
+
{/* The rest of the code will go here */}
|
42 |
+
</>
|
43 |
+
) : (
|
44 |
+
<select className="bg-[#121212] text-[#f0f0f0] font- roboto border-[#f0f0f0] py-2 px-4 rounded-l" onChange={onGameSelected} value={selectedGame}>
|
45 |
+
<option value="">Select a game</option>
|
46 |
+
{games.map(game => (
|
47 |
+
<option key={game.key} value={game.key}>{game.label}</option>
|
48 |
+
))}
|
49 |
+
</select>
|
50 |
+
)
|
51 |
+
}
|
52 |
+
</div>
|
53 |
+
)
|
54 |
+
}
|
55 |
+
|
56 |
+
export default IndexPage
|
tsconfig.json
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"compilerOptions": {
|
3 |
+
"target": "ES2022",
|
4 |
+
"lib": ["dom", "dom.iterable", "esnext"],
|
5 |
+
"allowJs": true,
|
6 |
+
"skipLibCheck": true,
|
7 |
+
"strict": true,
|
8 |
+
"forceConsistentCasingInFileNames": true,
|
9 |
+
"noEmit": true,
|
10 |
+
"esModuleInterop": true,
|
11 |
+
"module": "esnext",
|
12 |
+
"moduleResolution": "node",
|
13 |
+
"resolveJsonModule": true,
|
14 |
+
"isolatedModules": true,
|
15 |
+
"jsx": "preserve",
|
16 |
+
"incremental": true,
|
17 |
+
"plugins": [
|
18 |
+
{
|
19 |
+
"name": "next"
|
20 |
+
}
|
21 |
+
],
|
22 |
+
"paths": {
|
23 |
+
"@/*": ["./src/*"]
|
24 |
+
}
|
25 |
+
},
|
26 |
+
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
|
27 |
+
"exclude": ["node_modules"]
|
28 |
+
}
|