Skip to content

Commit 63ecfcf

Browse files
Merge pull request #50 from CivicTechAtlanta/steve-fixes-v2
save fixes
2 parents ecff7b7 + 9bf79b4 commit 63ecfcf

File tree

9 files changed

+58
-57
lines changed

9 files changed

+58
-57
lines changed

src/app/calculator-flow/components/ChlorineWeightFlow.tsx

Lines changed: 14 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,8 @@ import { formatSig2 } from "@/app/utils/format";
1515

1616
type ChlorineWeightCalc = {
1717
chlorineWeight: number;
18-
msVolume: number | string;
1918
waterIngress: number | string;
2019
desiredConcentration: number;
21-
dripRate: number | string;
2220
chlorinePercentage: number | string;
2321
};
2422

@@ -30,25 +28,26 @@ export default function ChlorineWeightFormula({ onCalculate, sharedState }: { on
3028

3129
const [showModal, setShowModal] = useState(null as string | null);
3230

31+
console.log("SharedState", sharedState)
32+
3333
const [formData, setFormData] = useState({
34-
motherSolution: sharedState.msVolume || '',
3534
waterIngress: sharedState.reservoirIngress || '',
3635
desiredConcentration: sharedState.desiredConcentration || '',
37-
dripRate: sharedState.desiredDripRate || '',
3836
chlorinePercentage: sharedState.chlorinePercentage || '',
37+
rechargeTimeDays: sharedState.refillTime || '',
3938
});
4039

4140
// Calculate with chlorine percentage given as a whole number (e.g., 70 => 0.70)
4241
const chlorinePct = (Number(formData.chlorinePercentage) || 0) / 100;
43-
const chlorineWeight = .36 * ((Number(formData.motherSolution) * Number(formData.waterIngress) * Number(formData.desiredConcentration)) / (Number(formData.dripRate) * chlorinePct))
42+
43+
const chlorineWeight = ( Number(formData.waterIngress) * (Number(formData.rechargeTimeDays) * 86400) * Number(formData.desiredConcentration) ) / (10 * chlorinePct)
4444

4545
const handleClick = () => {
4646
if (
47-
formData.motherSolution === '' ||
4847
formData.waterIngress === '' ||
4948
formData.desiredConcentration === '' ||
50-
formData.dripRate === '' ||
51-
formData.chlorinePercentage === ''
49+
formData.chlorinePercentage === '' ||
50+
formData.rechargeTimeDays === ''
5251
) {
5352
setErrorMessage('Please fill all inputs');
5453
setShowText(false);
@@ -57,10 +56,8 @@ export default function ChlorineWeightFormula({ onCalculate, sharedState }: { on
5756
setShowText(true);
5857
onCalculate({
5958
chlorineWeight: chlorineWeight,
60-
msVolume: formData.motherSolution,
6159
waterIngress: formData.waterIngress,
6260
desiredConcentration: Number(formData.desiredConcentration),
63-
dripRate: formData.dripRate,
6461
chlorinePercentage: formData.chlorinePercentage
6562
});
6663
}
@@ -96,35 +93,28 @@ export default function ChlorineWeightFormula({ onCalculate, sharedState }: { on
9693

9794
<div className="input-wrapper">
9895
<Input
99-
label={`${t('Mother Solution')} (${t('liters')})`}
100-
name='motherSolution'
101-
value={formData.motherSolution}
102-
placeholder='600'
96+
label={`${t('Refill Time')} (${t('days')})`}
97+
name='rechargeTimeDays'
98+
value={formData.rechargeTimeDays}
99+
placeholder='7'
103100
handleChange={handleChange}
104101
/>
105102
<Input
106-
label={`${t('Water Ingress')} (${t('liters')}/${'second'})`}
103+
label={`${t('Water Ingress')} (${t('liters')}/${t('second')})`}
107104
name='waterIngress'
108105
value={formData.waterIngress}
109106
placeholder='20'
110107
handleChange={handleChange}
111108
/>
112109
<Input
113-
label={`${t('Desired Concentration')} (${t('miligrams')}/${'liter'})`}
110+
label={`${t('Desired Concentration')} (${t('milligrams')}/${t('liter')})`}
114111
name='desiredConcentration'
115112
value={formData.desiredConcentration}
116113
placeholder='1'
117114
handleChange={handleChange}
118115
/>
119116
<Input
120-
label={`${t('Drip Rate')} (${t('liters')}/${'hour'})`}
121-
name='dripRate'
122-
value={formData.dripRate}
123-
placeholder='2'
124-
handleChange={handleChange}
125-
/>
126-
<Input
127-
label={`${t('Chlorine Percentage')}`}
117+
label={`${t('Chlorine Percentage')} (%)`}
128118
name='chlorinePercentage'
129119
value={formData.chlorinePercentage}
130120
placeholder='70'

src/app/calculator-flow/components/DripRateCalculatorFlow.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export default function DripRateFormula({ onCalculate, sharedState }: {
4949
</div>
5050

5151
<div className="input-group">
52-
<label>{`${t('Refill time')} (${t('days')})`}</label>
52+
<label>{`${t('Refill Time')} (${t('days')})`}</label>
5353
<input type="number" value={refillTime} onChange={(event) => { setRefillTime(Number(event.target.value)) }} />
5454
</div>
5555

src/app/calculator-flow/components/MotherSolutionConcentrationFlow.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export default function MotherSolutionConcentrationFormula({ onCalculate, shared
4141
<h2>{`${t('The concentration of the mother solution is')}:`}</h2>
4242

4343
<p className="answer">
44-
{`${formatSig2(concentratedMotherSolution)} ${t('mg')}/${t('L')}`}
44+
{`${formatSig2(concentratedMotherSolution)} ${t('milligrams')}/${t('liters')}`}
4545
</p>
4646
</div>
4747
<Modal

src/app/calculator-flow/page.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,8 +287,8 @@ export default function CalculatorFlow() {
287287
/>
288288
</label>
289289
<div style={{display:'flex',gap:12,justifyContent:'flex-end'}}>
290-
<button onClick={() => setShowSavePopup(false)} style={{padding:'8px 16px'}}>{t('Cancel')}</button>
291-
<button onClick={saveSharedState} style={{padding:'8px 16px',background:'#288DCE',color:'#fff',border:'none',borderRadius:4}}>{t('Save')}</button>
290+
<button onClick={() => setShowSavePopup(false)} style={{padding:'8px 16px'}}>{t('configurations.cancel')}</button>
291+
<button onClick={saveSharedState} style={{padding:'8px 16px',background:'#288DCE',color:'#fff',border:'none',borderRadius:4}}>{t('configurations.save')}</button>
292292
</div>
293293
</div>
294294
</div>

src/app/chlorine-weight/page.tsx

Lines changed: 14 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -20,24 +20,21 @@ export default function ChlorineWeightFormula() {
2020
const [showModal, setShowModal] = useState(null as string | null);
2121

2222
const [formData, setFormData] = useState({
23-
motherSolution: '',
2423
waterIngress: '',
2524
desiredConcentration: '',
26-
dripRate: '',
2725
chlorinePercentage: '',
26+
rechargeTimeDays: '',
2827
});
2928

30-
// Calculate with chlorine percentage given as a whole number (e.g., 70 => 0.70)
3129
const chlorinePct = (Number(formData.chlorinePercentage) || 0) / 100;
32-
const chlorineWeight = .36 * ((Number(formData.motherSolution) * Number(formData.waterIngress) * Number(formData.desiredConcentration)) / (Number(formData.dripRate) * chlorinePct))
30+
const chlorineWeight = ( Number(formData.waterIngress) * (Number(formData.rechargeTimeDays) * 86400) * Number(formData.desiredConcentration) ) / (10 * chlorinePct)
3331

3432
const handleClick = () => {
3533
if (
36-
formData.motherSolution === '' ||
3734
formData.waterIngress === '' ||
3835
formData.desiredConcentration === '' ||
39-
formData.dripRate === '' ||
40-
formData.chlorinePercentage === ''
36+
formData.chlorinePercentage === '' ||
37+
formData.rechargeTimeDays === ''
4138
) {
4239
setErrorMessage('Please fill all inputs');
4340
setShowText(false);
@@ -79,35 +76,28 @@ export default function ChlorineWeightFormula() {
7976

8077
<div className="input-wrapper">
8178
<Input
82-
label={`${t('Mother Solution')} (${t('liters')})`}
83-
name='motherSolution'
84-
value={formData.motherSolution}
85-
placeholder='600'
79+
label={`${t('Refill Time')} (${t('days')})`}
80+
name='rechargeTimeDays'
81+
value={formData.rechargeTimeDays}
82+
placeholder='7'
8683
handleChange={handleChange}
8784
/>
8885
<Input
89-
label={`${t('Water Ingress')} (${t('liters')}/${'second'})`}
86+
label={`${t('Water Ingress')} (${t('liters')}/${t('second')})`}
9087
name='waterIngress'
9188
value={formData.waterIngress}
9289
placeholder='20'
9390
handleChange={handleChange}
9491
/>
9592
<Input
96-
label={`${t('Desired Concentration')} (${t('miligrams')}/${'liter'})`}
93+
label={`${t('Desired Concentration')} (${t('milligrams')}/${t('liter')})`}
9794
name='desiredConcentration'
9895
value={formData.desiredConcentration}
9996
placeholder='1'
10097
handleChange={handleChange}
10198
/>
10299
<Input
103-
label={`${t('Drip Rate')} (${t('liters')}/${'hour'})`}
104-
name='dripRate'
105-
value={formData.dripRate}
106-
placeholder='2'
107-
handleChange={handleChange}
108-
/>
109-
<Input
110-
label={`${t('Chlorine Percentage')}`}
100+
label={`${t('Chlorine Percentage')} (%)`}
111101
name='chlorinePercentage'
112102
value={formData.chlorinePercentage}
113103
placeholder='70'
@@ -116,13 +106,13 @@ export default function ChlorineWeightFormula() {
116106

117107
{errorMessage && <p style={{ color: 'red' }}>{errorMessage}</p>}
118108

109+
<button className="button" onClick={handleClear}>{t('Clear')}</button>
110+
119111
{showText ? (
120112
<p>{`${t('The weight of chlorine needed is')}: ${formatSig2(chlorineWeight)} ${t('grams')}`}</p>
121113
) : (
122-
<button className="button primary" onClick={handleClick}>{t('Show Chlorine Weight')}</button>
114+
<button className="button primary" onClick={handleClick}>{t('Submit')}</button>
123115
)}
124-
125-
<button className="button" onClick={handleClear}>{t('Clear')}</button>
126116
</div>
127117

128118
<Modal

src/app/drip-rate/page.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@ export default function DripRateFormula() {
3131
return (
3232
<div className="center">
3333
<Home />
34-
<h1 className="pageHeader">{t('Drip Rate Formula')}
34+
<h1 className="pageHeader">{t('Recharge Time Formula')}
3535
<svg onClick={() => setShowModal('info')} fill="#288DCE" viewBox="0 0 50 50"><path d="M 25 2 C 12.309295 2 2 12.309295 2 25 C 2 37.690705 12.309295 48 25 48 C 37.690705 48 48 37.690705 48 25 C 48 12.309295 37.690705 2 25 2 z M 25 4 C 36.609824 4 46 13.390176 46 25 C 46 36.609824 36.609824 46 25 46 C 13.390176 46 4 36.609824 4 25 C 4 13.390176 13.390176 4 25 4 z M 25 11 A 3 3 0 0 0 22 14 A 3 3 0 0 0 25 17 A 3 3 0 0 0 28 14 A 3 3 0 0 0 25 11 z M 21 21 L 21 23 L 22 23 L 23 23 L 23 36 L 22 36 L 21 36 L 21 38 L 22 38 L 23 38 L 27 38 L 28 38 L 29 38 L 29 36 L 28 36 L 27 36 L 27 21 L 26 21 L 22 21 L 21 21 z" /></svg>
3636
</h1>
3737
<div className="input-wrapper">
3838

3939
<div className="input-group">
40-
<label>{`${t('Mother Solution Volume')} (${t('L')})`}</label>
40+
<label>{`${t('Mother Solution Volume')} (${t('liters')})`}</label>
4141
<input type="number" value={motherSolutionVolume} onChange={(event) => { setMotherSolutionVolume(Number(event.target.value)) }} />
4242
</div>
4343

src/app/locales/en.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
"The ingress formula is": "The ingress formula is",
3333
"days": "days",
3434
"hours": "hours",
35+
"liter": "liter",
3536
"liters": "liters",
3637
"minute": "minute",
3738
"second": "second",
@@ -82,6 +83,15 @@
8283

8384
"mother solution max weight text 1" : "There is a recommended maximum weight of the mother tank, which is 50 kilograms. This is to ensure that the tank is manageable and the water is not strongly chlorinated.",
8485

86+
"Mother Tank Maximum Weight Formula": "Mother Tank Maximum Weight Formula",
87+
"The maximum weight of the mother tank is": "The maximum weight of the mother tank is",
88+
89+
"Save Configuration": "Save Configuration",
90+
"Configuration Name": "Configuration Name",
91+
"Description": "Description",
92+
"Enter a name": "Enter a name",
93+
"Enter a description": "Enter a description",
94+
8595
"configurations.no_configurations": "No configurations",
8696
"configurations.add_configuration_message": "Add a configuration to see it here.",
8797
"configurations.configuration": "Configuration",

src/app/locales/es.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
"The ingress formula is": "La fórmula de entrada es",
3232
"days": "días",
3333
"hours": "horas",
34+
"liter": "litro",
3435
"liters": "litros",
3536
"second": "segundo",
3637
"minute": "minuto",
@@ -83,6 +84,16 @@
8384
"flow rate text 1" : "El caudal de entrada del reservorio es la tasa a la que el agua entra en el reservorio en litros por segundo. Se recomienda medir regularmente este caudal, ya que diferentes factores, como el clima o la época del año, pueden afectar la entrada de agua.",
8485
"flow rate text 2" : "Siempre que tenga el tamaño del contenedor y el tiempo que tarda en llenarse, puede usar cualquier contenedor para medir el caudal.",
8586

87+
"mother solution max weight header 1" : "El Peso Máximo del Tanque Madre",
88+
89+
"mother solution max weight text 1" : "Existe un peso máximo recomendado para el tanque madre, que es de 50 kilogramos. Esto es para asegurar que el tanque sea manejable y que el agua no esté fuertemente clorada.",
90+
91+
"Save Configuration": "Guardar Configuración",
92+
"Configuration Name": "Nombre de Configuración",
93+
"Description": "Descripción",
94+
"Enter a name": "Ingrese un nombre",
95+
"Enter a description": "Ingrese una descripción",
96+
8697
"configurations.no_configurations": "Sin configuraciones",
8798
"configurations.add_configuration_message": "Agregue una configuración para verla aquí.",
8899
"configurations.configuration": "Configuración",

src/app/mother-solution-concentration/components/Form.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,9 @@ export default function Form({ onCalculate, sharedState }: FormProps) {
6767
onCalculate(newConcentratedMotherSolution);
6868
};
6969

70-
const motherSolutionVolumeLabel = `${t('Mother Solution Volume')} (${t('L')})`;
71-
const weightOfChlorineLabel = `${'Weight of Chlorine'} (${t('g')})`;
72-
const desiredReservoirConcentrationLabel = `${'Desired Reservoir Concentration'} (${t('mg')}/${t('L')})`;
70+
const motherSolutionVolumeLabel = `${t('Mother Solution Volume')} (${t('liters')})`;
71+
const weightOfChlorineLabel = `${t('Weight of Chlorine')} (${t('grams')})`;
72+
const desiredReservoirConcentrationLabel = `${t('Desired Reservoir Concentration')} (${t('milligrams')}/${t('liters')})`;
7373

7474
return (
7575
<form className="form" onSubmit={handleSubmit}>

0 commit comments

Comments
 (0)