58 lines
1.5 KiB
TypeScript
58 lines
1.5 KiB
TypeScript
import React from 'react';
|
|
|
|
import LoginForm from './LoginForm';
|
|
import ScoreCounter from './ScoreCounter';
|
|
import Row from './Row';
|
|
import Icon from './Icon';
|
|
|
|
import { useJSONLocalStorage, useLocalStorage } from './hooks/useLocalStorage';
|
|
import {toot, starman, flush, getCheer} from './sound';
|
|
|
|
import './App.css';
|
|
|
|
|
|
|
|
interface Stats {
|
|
attempts: number;
|
|
scheduledPoops: number;
|
|
selfPoops: number;
|
|
cleanUndies: number;
|
|
};
|
|
|
|
const initialStats:Stats = {
|
|
attempts: 1,
|
|
scheduledPoops: 1,
|
|
selfPoops: 1,
|
|
cleanUndies: 1,
|
|
};
|
|
|
|
const initialStreakTracker:StreakTracker = {
|
|
streaks: [0,0,0,0],
|
|
currentStreakSince: Date.now()
|
|
}
|
|
|
|
function App() {
|
|
|
|
const [stats, setStats] = useJSONLocalStorage<Stats>("stats", initialStats);
|
|
const [name] = useLocalStorage<string>("name", {});
|
|
const [password] = useLocalStorage<string>("password", {});
|
|
|
|
return !name || !password ? <LoginForm /> :(
|
|
<div className="App">
|
|
<div className="header">
|
|
<div className="name-plate">Hello Pax!</div>
|
|
<div className="score-board">
|
|
Points: <ScoreCounter stats={stats}/>
|
|
</div>
|
|
</div>
|
|
<Row stats={stats} setStats={setStats} name="attempts" emoji="🚽" sound={flush} />
|
|
<Row stats={stats} setStats={setStats} name="scheduledPoops" emoji="💩" sound={toot} />
|
|
<Row stats={stats} setStats={setStats} name="selfPoops" emoji="💩" sound={toot} />
|
|
<Row stats={stats} setStats={setStats} name="cleanUndies" emoji="🩲" sound={starman} />
|
|
<div className="streak-counter"></div>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
export default App;
|