import React, { useState } from 'react'; export const SeismicDiaphragmSheet: React.FC = () => { // Shared inputs / Constants const [parallel, setParallel] = useState({ V: 30, // kips levels: [ { id: 'Roof', name: 'Roof', cvx: 0.491, wi: 75 }, // Wi from screenshot { id: '2', name: '2', cvx: 0.509, wi: 250 }, { id: '1', name: '1', cvx: 0.000, wi: 0 }, { id: 'Base', name: 'Base', cvx: 1.000, wi: 0 }, // For sum check ] }); const [normal, setNormal] = useState({ V: 46, // kips levels: [ { id: 'Roof', name: 'Roof', cvx: 0.543, wi: 132 }, { id: '2', name: '2', cvx: 0.457, wi: 381 }, { id: '1', name: '1', cvx: 0.000, wi: 0 }, { id: 'Base', name: 'Base', cvx: 1.000, wi: 0 }, ] }); // Min/Max Factors const sds = 0.527; // Placeholder or passed prop const ie = 1.25; const fpxMinCoeff = 0.2 * sds * ie; const fpxMaxCoeff = 0.4 * sds * ie; // Calculation Helper const calculateTable = (V: number, rows: typeof parallel.levels) => { return rows.map(r => { const fx = r.cvx * V; // Fx = Cvx * V return { ...r, fx }; }); }; // Process Accumulation const processFpx = (rowsWithFx: any[]) => { // Need to iterate from Roof down? // Actually table order is Roof, 2, 1, Base. // Fpx accumulation logic: return rowsWithFx.map((r, i) => { // For accumulated sums, we need to sum from 0 to i? // Sum(Fi) / Sum(wi) let sumFi = 0; let sumWi = 0; for (let j = 0; j <= i; j++) { // Assuming rows[0] is Roof (top) sumFi += rowsWithFx[j].fx; sumWi += rowsWithFx[j].wi; } // Fpx = (sumFi / sumWi) * wpx // wpx is r.wi const fpx_calc = sumWi > 0 ? (sumFi / sumWi) * r.wi : 0; // Check Limits const fpx_min = fpxMinCoeff * r.wi; const fpx_max = fpxMaxCoeff * r.wi; const design_fpx = Math.max(Math.min(fpx_calc, fpx_max), fpx_min); return { ...r, sumFi, sumWi, fpx: fpx_calc, design: design_fpx }; }); }; const parallelResults = processFpx(calculateTable(parallel.V, parallel.levels)); const normalResults = processFpx(calculateTable(normal.V, normal.levels)); return (

Diaphragm Forces excluding parallel exterior walls

{/* Parallel Table */}

Diaphragm Force Fpx Parallel to Bldg Length V= setParallel({ ...parallel, V: parseFloat(e.target.value) })} style={{ width: '50px' }} />k

{parallelResults.map((r, i) => ( ))}
LevelCvxFxSum FxSum WiFpxDesign Fpx
{r.name} { const newL = [...parallel.levels]; newL[i].cvx = parseFloat(e.target.value); setParallel({ ...parallel, levels: newL }); }} style={{ width: '50px' }} /> {r.fx.toFixed(2)} {r.sumFi.toFixed(1)} { const newL = [...parallel.levels]; newL[i].wi = parseFloat(e.target.value); setParallel({ ...parallel, levels: newL }); }} style={{ width: '50px' }} /> {r.fpx.toFixed(1)} {r.design.toFixed(1)}
{/* Normal Table */}

Diaphragm Force Fpx Normal to Bldg Length V= setNormal({ ...normal, V: parseFloat(e.target.value) })} style={{ width: '50px' }} />k

{normalResults.map((r, i) => ( ))}
LevelCvxFxSum FxSum WiFpxDesign Fpx
{r.name} { const newL = [...normal.levels]; newL[i].cvx = parseFloat(e.target.value); setNormal({ ...normal, levels: newL }); }} style={{ width: '50px' }} /> {r.fx.toFixed(2)} {r.sumFi.toFixed(1)} { const newL = [...normal.levels]; newL[i].wi = parseFloat(e.target.value); setNormal({ ...normal, levels: newL }); }} style={{ width: '50px' }} /> {r.fpx.toFixed(1)} {r.design.toFixed(1)}

User Overrides at each level in addition to above

Parallel to Bldg Length
{/* Placeholder Inputs */}
Adjust ps weight | Adjust wt in kips
Normal to Bldg Length
{/* Placeholder Inputs */}
Adjust psf weight | Adjust wt in kips
); };