potty-chart/src/App.tsx

58 lines
1.5 KiB
TypeScript
Raw Normal View History

import React from 'react';
2023-01-17 23:37:29 +00:00
import LoginForm from './LoginForm';
import ScoreCounter from './ScoreCounter';
2023-01-18 21:10:26 +00:00
import Row from './Row';
2023-01-18 16:19:30 +00:00
import Icon from './Icon';
2023-01-17 23:37:29 +00:00
import { useJSONLocalStorage, useLocalStorage } from './hooks/useLocalStorage';
2023-01-18 16:19:30 +00:00
import {toot, starman, flush, getCheer} from './sound';
2023-01-17 23:37:29 +00:00
import './App.css';
2023-01-18 16:19:30 +00:00
2023-01-17 23:37:29 +00:00
interface Stats {
attempts: number;
scheduledPoops: number;
selfPoops: number;
cleanUndies: number;
};
const initialStats:Stats = {
attempts: 1,
scheduledPoops: 1,
selfPoops: 1,
cleanUndies: 1,
2023-01-18 21:10:26 +00:00
};
const initialStreakTracker:StreakTracker = {
2023-01-17 23:37:29 +00:00
streaks: [0,0,0,0],
currentStreakSince: Date.now()
2023-01-18 21:10:26 +00:00
}
2023-01-17 23:37:29 +00:00
function App() {
2023-01-17 23:37:29 +00:00
const [stats, setStats] = useJSONLocalStorage<Stats>("stats", initialStats);
const [name] = useLocalStorage<string>("name", {});
const [password] = useLocalStorage<string>("password", {});
return !name || !password ? <LoginForm /> :(
<div className="App">
2023-01-18 16:19:30 +00:00
<div className="header">
<div className="name-plate">Hello Pax!</div>
<div className="score-board">
Points: <ScoreCounter stats={stats}/>
</div>
2023-01-17 23:37:29 +00:00
</div>
2023-01-18 21:10:26 +00:00
<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} />
2023-01-17 23:37:29 +00:00
<div className="streak-counter"></div>
</div>
);
}
export default App;