Skip to content

Commit

Permalink
bugs fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
hemants1703 committed Feb 16, 2024
1 parent 7c35f35 commit 0adce03
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 26 deletions.
18 changes: 6 additions & 12 deletions src/components/Chantcounter.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,17 @@ import { useState, useEffect } from "react";
import "../styles/Chantcounter.css";

export default function Chantcounter({ handleMalaCount }) {
const [chantCount, setChantCount] = useState("0107");
const [chantCount, setChantCount] = useState(105);

useEffect(() => {
if (chantCount === "0108") {
handleMalaCount(chantCount);
if (chantCount === 108) {
handleMalaCount();
setChantCount(0);
}
}, [chantCount]);
}, [chantCount, handleMalaCount]);

const updateChantCount = () => {
setChantCount((prevCount) => {
let newCount = parseInt(prevCount) + 1;
if (newCount === 108) {
handleMalaCount(newCount.toString().padStart(4, "0"));
newCount = 0;
}
return newCount.toString().padStart(4, "0");
});
setChantCount((prevCount) => prevCount + 1);
};

return (
Expand Down
2 changes: 1 addition & 1 deletion src/components/Malacounter.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import "../styles/Malacounter.css";
export default function Malacounter({ count }) {
return (
<div id="malaCounter">
<p>{count}</p>
<p>{count < 9 ? "0" + count.toString() : count.toString()}</p>
</div>
);
}
21 changes: 10 additions & 11 deletions src/containers/Homepage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,19 @@ import Malacounter from "../components/Malacounter";
import Chantcounter from "../components/Chantcounter";
import Prabhupictures from "../components/Prabhupictures";

import React, { useState, useEffect } from "react";
import { useState, useEffect } from "react";
import Quotes from "../components/Quotes";

export default function Homepage() {
const [randomIndex, setRandomIndex] = useState(0);
const [malaCount, setMalaCount] = useState("00");

const handleMalaCount = (chantCount) => {
if (chantCount === "0107") {
setMalaCount((prevMalaCount) => {
let newMalaCount = parseInt(prevMalaCount) + 1;
return newMalaCount.toString().padStart(2, "0");
});
}
const [malaCount, setMalaCount] = useState(0);

const handleMalaCount = () => {
console.log("108 chants completed!");
setMalaCount((prevMalaCount) => {
let newMalaCount = prevMalaCount + 1;
return newMalaCount;
});
};

useEffect(() => {
Expand All @@ -43,7 +42,7 @@ export default function Homepage() {
/>
<div id="counterContainer">
<Malacounter count={malaCount} />
<Chantcounter onChantCount={handleMalaCount} />
<Chantcounter handleMalaCount={handleMalaCount} />
</div>
</>
);
Expand Down
1 change: 1 addition & 0 deletions src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
* {
margin: 0;
padding: 0;
font-family: 'Hanuman', serif;
}

body {
Expand Down
3 changes: 2 additions & 1 deletion src/styles/Chantcounter.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
color: #000;
background-color: #fff;
border-radius: 9px;
padding: 15px 105px;
padding: 10px 105px;
font-size: xx-large;
border: 0;
box-shadow: 0 0 10px rgba(219, 172, 52);
height: 100%;
width: 100%;
cursor: pointer;
animation: glow 2s infinite;
}
Expand Down
2 changes: 1 addition & 1 deletion src/styles/Homepage.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
justify-content: space-between;
width: 360px;
margin: auto;
gap: 10px;
Expand Down

0 comments on commit 0adce03

Please sign in to comment.