-
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.
Add basic frontend representation of secrets
- Loading branch information
Showing
6 changed files
with
152 additions
and
6 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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
interface SecretData { | ||
id: number | ||
name: string | null | ||
type: string | null | ||
faction: number | ||
} | ||
|
||
class Secret { | ||
public id: number | ||
public name: string | null | ||
public type: string | null | ||
public faction: number | ||
|
||
constructor(data: SecretData) { | ||
this.id = data.id | ||
this.name = data.name | ||
this.type = data.type | ||
this.faction = data.faction | ||
} | ||
} | ||
|
||
export default Secret |
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,24 @@ | ||
import Faction from "@/classes/Faction" | ||
import Secret from "@/classes/Secret" | ||
import { useGameContext } from "@/contexts/GameContext" | ||
import { capitalize } from "@mui/material/utils" | ||
|
||
const SecretList = ({ faction }: { faction: Faction }) => { | ||
const { allSecrets } = useGameContext() | ||
|
||
const secrets = allSecrets.asArray.filter( | ||
(secret: Secret) => secret.faction === faction.id | ||
) | ||
|
||
return ( | ||
<div className="flex flex-col gap-2"> | ||
{secrets.map((secret: Secret) => ( | ||
<p> | ||
<b>{capitalize(secret.type as string)}</b>: {secret.name} | ||
</p> | ||
))} | ||
</div> | ||
) | ||
} | ||
|
||
export default SecretList |
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