-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(app-create-game): add create game form
- Loading branch information
Showing
38 changed files
with
491 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,3 +23,5 @@ export interface Card { | |
number: number, | ||
deckId: string | ||
} | ||
|
||
export type CardEntity = Card & {id:string}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
packages/game-app/src/_shared/components/TextArea/TextArea.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import React from 'react'; | ||
import styled from 'styled-components'; | ||
|
||
type Props = { | ||
name: string; | ||
label?: string; | ||
value: string; | ||
onChange: React.ChangeEventHandler<HTMLInputElement>; | ||
errorMessage?: string | null; | ||
disabled?: boolean; | ||
}; | ||
|
||
const StyledTextArea = styled.textarea` | ||
border: 0; | ||
border-radius: 10px; | ||
`; | ||
|
||
const TextArea: React.FC<Props> = ({ name, value, errorMessage, label, onChange, disabled }) => { | ||
return ( | ||
<div className="column"> | ||
{label ? <label htmlFor={name}>{label}</label> : null} | ||
<StyledTextArea rows={4} disabled={disabled} value={value} name={name} id={name} onChange={onChange as any} /> | ||
{errorMessage ? <span className="error-message">{errorMessage}</span> : null} | ||
</div> | ||
); | ||
}; | ||
|
||
TextArea.displayName = 'TextArea'; | ||
|
||
export default TextArea; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import TextArea from './TextArea'; | ||
|
||
export default TextArea; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
import SelectInput from './SelectInput'; | ||
import TextInput from './TextInput'; | ||
import PasswordInput from './PasswordInput'; | ||
import TextArea from './TextArea'; | ||
|
||
export { TextInput, SelectInput, PasswordInput }; | ||
export { TextInput, SelectInput, PasswordInput, TextArea }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import { createAction } from '@reduxjs/toolkit'; | ||
import { GameCreationData } from '../types/gameCreationData'; | ||
|
||
export const createGame = createAction<GameCreationData>('createGame/start'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { GameCreationData } from '../types/gameCreationData'; | ||
import firebase from 'firebase/app'; | ||
import 'firebase/firestore'; | ||
import { FirebaseCollections, Game } from '@pipeline/common'; | ||
|
||
const DEFAULT_DECK_ID = '7p5qqvE8kCV9WWysVc2n'; | ||
|
||
export default function callCreateGame(data: GameCreationData, userId: string) { | ||
return firebase | ||
.firestore() | ||
.collection(FirebaseCollections.Games) | ||
.add({ | ||
scenarioContent: data.scenarioContent, | ||
scenarioTitle: data.scenarioTitle, | ||
scenarioCardId: data.scenarioCardId || null, | ||
facilitator: { | ||
id: userId, | ||
}, | ||
deckId: DEFAULT_DECK_ID, | ||
createdAt: firebase.firestore.FieldValue.serverTimestamp(), | ||
} as Game); | ||
} |
Oops, something went wrong.