Skip to content

Commit

Permalink
CrearMensaje, enviar page
Browse files Browse the repository at this point in the history
  • Loading branch information
Protocolelectronicsco committed Sep 21, 2023
1 parent 65f3e10 commit d5d79ed
Show file tree
Hide file tree
Showing 9 changed files with 84 additions and 36 deletions.
2 changes: 2 additions & 0 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import Catacion from './components/Catacion';
import RegistroLote from './components/RegistroLote'
import PruebaTwilio from './components/PruebaTwilio';
import SobreNosotros from './components/SobreNosotros';
import EnviarAnalisis from './components/EnviarAnalisis';

function App() {

Expand All @@ -22,6 +23,7 @@ function App() {
<Route path="catacion/" element={<Catacion/>} />
<Route path = 'RegistroCaficultor/:siguiente' element = {<RegistroCaficultor/>}></Route>
<Route path = 'RegistroLote/' element = {<RegistroLote/>}></Route>
<Route path = 'enviarAnalisis/' element = {<EnviarAnalisis/>}></Route>
<Route path = "prueba" element = {<PruebaTwilio/>}> </Route>
</Routes>
</div>
Expand Down
13 changes: 11 additions & 2 deletions src/components/AnalisisFisico.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,15 @@ export default function AnalisisFisicoPage() {
return newMalla
}
useEffect(() => {

if (newAnalisis.sampleWeight > 0) handleValidation("sampleWeight", true)
else handleValidation("sampleWeight", false)
if (newAnalisis.excelso > 0) handleValidation("excelso", true)
else handleValidation("excelso", false)
let A: number = newAnalisis.defectsWeight ? newAnalisis.defectsWeight : 0
let B: number = newAnalisis.trilla ? newAnalisis.trilla : 0
//reactLote.analysis=newAnalisis
setReactLote({...reactLote, analysis:newAnalisis})
setReactLote({...reactLote, analysis:newAnalisis, ANALYSYS:true})
setMermaMedida(Number(A) + Number(B))
}, [newAnalisis]);
function handleCodigo(e: React.ChangeEvent<HTMLInputElement>) {
Expand All @@ -122,7 +123,7 @@ export default function AnalisisFisicoPage() {
let newpcMerma: number = newMerma / newAnalisis2.sampleWeight * 100
newpcMerma = parseFloat(newpcMerma.toFixed(2))
setNewAnalisis({ ...newAnalisis2, factordeRendimiento: newfactordeRendimiento, Merma: newMerma, pcMerma: newpcMerma})

}

function handleDefectValue(event: React.ChangeEvent<HTMLSelectElement>): void {
Expand Down Expand Up @@ -276,6 +277,11 @@ export default function AnalisisFisicoPage() {
</section>
<section id="Defectos" className="field">
<h1>Defectos</h1>
<a target="_blanck"
href="https://federaciondecafeteros.org/app/uploads/2019/11/Afiche-Español-2-final.pdf"
>
Mira los defectos físicos
</a>
<div className="input-row">
<div className="InputAnalisis">
<label htmlFor="defectSelect" >Defectos:</label>
Expand Down Expand Up @@ -343,6 +349,9 @@ export default function AnalisisFisicoPage() {
</div>
<div className="resultados">
<h1 style={{fontSize:"25px", color:"black"}} >Resultados:</h1><br />
<a target="_blanck" href="https://federaciondecafeteros.org/app/uploads/2019/10/precio_cafe.pdf">
Precio del día
</a>
<h4>Factor de rendimiento: {newAnalisis.factordeRendimiento}</h4>
<h4>Porcentaje de Merma: {newAnalisis.pcMerma}%</h4>
<h4 className={newAnalisis.density?"InfoVisible":"InfoInvisible"}>Densidad: {newAnalisis?.density} g/ml</h4>
Expand Down
5 changes: 3 additions & 2 deletions src/components/BarraNavegacion.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ import React from 'react';
import { Link } from 'react-router-dom';
import { Lote } from './MyTypes';
import logo from "../assets/images/logo.svg"
import { createLote } from './LoteInfo';

function BarraNavegacion ({miLote}:{miLote:Lote}){
function BarraNavegacion ({miLote=createLote()}:{miLote?:Lote}){
return (
<div className='headerMP'>
<div className='headerLink'>
Expand All @@ -21,7 +22,7 @@ function BarraNavegacion ({miLote}:{miLote:Lote}){
<Link state={{miLote: miLote }} to="/catacion" >Catación</Link>
</div>
<div>
<Link state={{miLote: miLote }} to="/" >Enviar Análisis</Link>
<Link state={{miLote: miLote }} to="/enviarAnalisis" >Enviar Análisis</Link>
</div>
<div>
<Link to={'/SobreNosotros'}
Expand Down
32 changes: 13 additions & 19 deletions src/components/Catacion.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ const ScoreInputsContainer = styled.div`
`;

const CatacionContainer = styled.div`
background-color: #eeeded;
background-color: #ffffff8e;
display: flex;
flex-direction: row;
margin-top: 2%;
margin-bottom: 2%;
padding: 10px;
border-radius: 1rem;
box-shadow: 3px 3px 5px rgb(50, 50, 50);
box-shadow: 3px 3px 5px rgb(50, 50, 50, 0.5);
width: inherit;
overflow: auto;
scrollbar-width: 5px;
Expand Down Expand Up @@ -77,22 +77,16 @@ const AddCatacionButton = styled.button`

export default function Catacion() {
const location = useLocation();
const { miLote }: { miLote: Lote } = location.state || {};
const { miLote }: { miLote: Lote } = location.state || createLote();
const [catacionCount, setCatacionCount] = useState(0);
const [reactLote, setReactLote] = useState<Lote[]>([{...miLote}]);
const [catador, setCatador] = useState('');
const [catacionElements, setCatacionElements] = useState<CatacionLote[]>([EMPTY_CUPPING]);
const [catacionElements, setCatacionElements] = useState<CatacionLote[]>([miLote.cupping]);
const [defectValue, setDefectValue] = useState<CupDefect>({ id: 0, name: '' });
useEffect(()=>{
setReactLote(lotes=>{
lotes.map(lote=>{})
})
setCatacionElements(prevData =>
prevData.map(data =>
data.id === id ? { ...data, [Propiedad]: newValue } : data
)
);
reactLote[0].cupping=
reactLote[0].cupping = catacionElements[0]
reactLote[0].CUPPING=true
setReactLote(reactLote)
},[catacionElements])
const handleCatador = (e: React.ChangeEvent<HTMLInputElement>) => {
const newCatador= e.target.value
Expand Down Expand Up @@ -300,7 +294,7 @@ export default function Catacion() {
{catacionElements.map(catacionElement => (
<CatacionContainer key={catacionElement.id}>
<CatacionHeader>
<h2>Muestra {catacionElement.id}</h2><br />
<h2>Muestra {catacionElement?.id}</h2><br />
<LoteCodigo miLote={reactLote[catacionElement.id]} handleCodigo={(e)=>{}}/>
<LoteInfo miLote={reactLote[catacionElement.id]} />

Expand All @@ -321,7 +315,7 @@ export default function Catacion() {
handleScoreChange(catacionElement.id, "fragancia", value as puntajeSCA)
}
/>
<textarea className="atributosInput" placeholder="Fragancias" onChange={(e) => handleAtributoChange(catacionElement.id, "fraganciaA", e)} />
<textarea value={catacionElement.fraganciaA} className="atributosInput" placeholder="Fragancias" onChange={(e) => handleAtributoChange(catacionElement.id, "fraganciaA", e)} />
<p>{catacionElement?.fraganciaA}</p>
<CoffeeScoreInput
aspect="Seco"
Expand Down Expand Up @@ -352,9 +346,9 @@ export default function Catacion() {
}
/>

<textarea className="atributosInput" placeholder="Sabores" onChange={(event) => handleAtributoChange(catacionElement.id, "saborA", event)} />
<textarea className="atributosInput" placeholder="Sabores" value={catacionElement?.saborA} onChange={(event) => handleAtributoChange(catacionElement.id, "saborA", event)} />
</SCABlock>
<SCABlock>
<SCABlock>
<div style={{ display: "flex", justifyContent: "flex-end" }}>
<div className="SCAScore">
<h2>Total: {catacionElement.residual}</h2>
Expand All @@ -367,7 +361,7 @@ export default function Catacion() {
handleScoreChange(catacionElement.id, "residual", value)
}
/>
<textarea className="atributosInput" placeholder="Atributos" onChange={(e) => handleAtributoChange(catacionElement.id, "residualA", e)} />
<textarea value={catacionElement.residualA} className="atributosInput" placeholder="Atributos" onChange={(e) => handleAtributoChange(catacionElement.id, "residualA", e)} />
</SCABlock>
<SCABlock>
<div style={{ display: "flex", justifyContent: "flex-end" }}>
Expand All @@ -382,7 +376,7 @@ export default function Catacion() {
handleScoreChange(catacionElement.id, "acidez", value)
}
/>
<textarea className="atributosInput" placeholder="Atributos" onChange={(e) => handleAtributoChange(catacionElement.id, "acidezA", e)} />
<textarea value={catacionElement.acidezA} className="atributosInput" placeholder="Atributos" onChange={(e) => handleAtributoChange(catacionElement.id, "acidezA", e)} />
<CoffeeScoreInput
aspect="Intensidad"
score={catacionElement.intensidad || 8}
Expand Down
11 changes: 11 additions & 0 deletions src/components/CrearMensaje.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { Lote } from "./MyTypes";

export default function CrearMensaje(miLote:Lote):string{
let mensaje = 'Mensaje: '
if(miLote.nombreCaficultor) mensaje+= `Señor/a ${miLote?.nombreCaficultor}`
if(miLote.ANALYSYS){

}

return mensaje
}
22 changes: 22 additions & 0 deletions src/components/EnviarAnalisis.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { useLocation } from "react-router-dom";
import { Lote } from "./MyTypes";
import { createLote } from "./LoteInfo";
import BarraNavegacion from "./BarraNavegacion";
import { useState } from "react";
import CrearMensaje from "./CrearMensaje";
function EnviarAnalisis(){
const location = useLocation();
const { miLote }: { miLote: Lote } = location.state || createLote();
const [mensaje, setMensaje] = useState<string>(CrearMensaje(miLote))
const mensaje2 = CrearMensaje(miLote)
return(
<div>
<BarraNavegacion miLote={miLote}/>
<h2>Caficultor: {miLote.nombreCaficultor}</h2>
<h2>Whatsapp: {miLote.numeroCel}</h2>
<p>{mensaje2}</p>
</div>
)
}

export default EnviarAnalisis
4 changes: 3 additions & 1 deletion src/components/LoteInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import { CatacionLote, Lote, AnalisisFisico, EMPTY_CUPPING, EMPTY_ANALISIS } fro
export function createLote ():Lote{
const newLote:Lote={
cupping:EMPTY_CUPPING,
analysis: EMPTY_ANALISIS
analysis: EMPTY_ANALISIS,
ANALYSYS: false,
CUPPING: false,
}
return newLote
}
Expand Down
28 changes: 17 additions & 11 deletions src/components/MyTypes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,21 @@ export const predefinedDefects: CupDefect[] = [
export const predefinedPhysicalDefects: defectoFisico[] = [
{id:1, name: 'Otros grupo 1', group: 1 },
{id:2, name: 'Otros grupo 2', group: 2 },
{id:3, name: 'Brocado leve', group: 1 },
{id:4, name: 'Brocado severo', group: 1 },
{id:5, name: 'Negro parcial', group: 1 },
{id:6, name: 'Negro total', group: 1 },
{id:7, name: 'Vinagre', group: 1 },
{id:8, name: 'Cardenillo', group: 1 },
{id:8, name: 'Cereza', group: 1 },
{id:10, name: 'Inmaduro', group: 1 },
{id:11, name: 'Concha', group: 2 },
{id:12, name: 'Vano', group: 1 },
{id:13, name: 'Averanado', group: 1 }
{id:3, name: 'Negro parcial', group: 1 },
{id:4, name: 'Negro total', group: 1 },
{id:5, name: 'Cardenillo', group: 1 },
{id:6, name: 'Vinagre', group: 1 },
{id:7, name: 'Cristalizado', group: 1 },
{id:8, name: 'Decolorado-Reposado', group: 1 },
{id:9, name: 'Decolorado-Mantequillo', group: 1 },
{id:10, name: 'Decolorado-sobresecado', group: 1 },
{id:11, name: 'Mordido', group: 2 },
{id:12, name: 'Brocado leve', group: 1 },
{id:13, name: 'Brocado severo', group: 1 },
{id:14, name: 'Averanado/Arrugado', group: 1 },
{id:15, name: 'Inmaduro/Paloteado', group: 1 },
{id:16, name: 'Aplastado', group: 1 },
{id:17, name: 'Flojo', group: 1 },

]
export type SCAbox = {
Expand Down Expand Up @@ -185,4 +189,6 @@ export type Lote = {
peso?: number;
cupping: CatacionLote;
analysis: AnalisisFisico;
ANALYSYS: boolean;
CUPPING: boolean;
}
3 changes: 2 additions & 1 deletion src/components/RegistroLote.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { Lote } from "./MyTypes";
//@ts-ignore
import { Helmet } from 'react-helmet';
import BarraNavegacion from "./BarraNavegacion";
import { createLote } from "./LoteInfo";
type listItems = {
id: number
nombre: string
Expand Down Expand Up @@ -107,7 +108,7 @@ function generarCodigo(): string {

export default function RegistroLote() {
const location = useLocation();
const { miLote }: { miLote: Lote } = location.state || {};
const { miLote }: { miLote: Lote } = location.state || createLote();
const [registroLote, setRegistroLote] = useState<Lote>(miLote)
//Falta Altura (msnm)

Expand Down

0 comments on commit d5d79ed

Please sign in to comment.