Advertisement
shawon_majid

HeirApplicationAdd.js

Feb 13th, 2024
864
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import axios from "axios";
  2. import React, { useState } from "react";
  3. import { NavLink } from "react-router-dom";
  4. import backendURL from "../consts";
  5.  
  6. // const HeirInformation = ({ inheritor, index }) => {
  7. //   return (
  8. //     <tr key={index}>
  9. //       <th scope="row" className="text-center">
  10. //         {index + 1}
  11. //       </th>
  12. //       <td className="text-center">
  13. //         <input
  14. //           type="text"
  15. //           className="form-control"
  16. //           id="text"
  17. //           placeholder="নাম"
  18. //           name="inheritorName"
  19. //           value={inheritor.inheritorName}
  20. //           onChange={(e) => {}}
  21. //         />
  22. //       </td>
  23. //       <td className="text-center">
  24. //         <input
  25. //           type="text"
  26. //           className="form-control"
  27. //           id="text"
  28. //           placeholder="সম্পর্ক"
  29. //         />
  30. //       </td>
  31. //       <td className="text-center">
  32. //         <input
  33. //           type="text"
  34. //           className="form-control"
  35. //           id="text"
  36. //           placeholder="মন্তব্য"
  37. //         />
  38. //       </td>
  39. //       <td className="text-center">
  40. //         {index == 0 ? null : (
  41. //           <button
  42. //             type="button"
  43. //             className="btn-icon btn-outline-lightblue font-weight-bold mr-2"
  44. //           >
  45. //             -
  46. //           </button>
  47. //         )}
  48. //         <button
  49. //           type="button"
  50. //           className="btn-icon btn-outline-lightblue font-weight-bold mr-2"
  51. //         >
  52. //           +
  53. //         </button>
  54. //       </td>
  55. //     </tr>
  56. //   );
  57. // };
  58.  
  59. const HeirApplicationAdd = () => {
  60.   const [heirInfo, setHeirInfo] = useState({
  61.     applicantsName: "",
  62.     fathersName: "",
  63.     mothersName: "",
  64.     spousesName: "",
  65.     voterIdNo: "",
  66.     mobileNo: "",
  67.     nationality: "",
  68.     wardNo: 5,
  69.     postOffice: "",
  70.     upozilla: "",
  71.     district: "",
  72.     nameOfDead: "",
  73.     fathersNameOfDead: "",
  74.     mothersNameOfDead: "",
  75.     spousesNameOfDead: "",
  76.     voterIdNoOfDead: "",
  77.     mobileNoOfDead: "",
  78.     nationalityOfDead: "",
  79.     wardNoOfDead: "",
  80.     postOfficeOfDead: "",
  81.     upozillaOfDead: "",
  82.     districtOfDead: "",
  83.     listOfInheritors: [
  84.       {
  85.         inheritorName: "",
  86.         relationship: "",
  87.         comment: "",
  88.       },
  89.       {
  90.         inheritorName: "",
  91.         relationship: "",
  92.         comment: "",
  93.       },
  94.     ],
  95.   });
  96.  
  97.   const handleChange = (e) => {
  98.     const { name, value } = e.target;
  99.     setHeirInfo({ ...heirInfo, [name]: value });
  100.   };
  101.  
  102.   const handleSubmit = async (e) => {
  103.     e.preventDefault();
  104.     // axios call for sending to database
  105.     try {
  106.       await axios.post(
  107.         backendURL + "/api/inheritance-certificate/add",
  108.         heirInfo
  109.       );
  110.     } catch (err) {
  111.       console.log(err);
  112.     }
  113.   };
  114.  
  115.   const HeirInformation = ({ inheritor, index }) => {
  116.     return (
  117.       <tr>
  118.         <th scope="row" className="text-center">
  119.           {index + 1}
  120.         </th>
  121.         <td className="text-center">
  122.           <input
  123.             type="text"
  124.             className="form-control"
  125.             id="text"
  126.             placeholder="নাম"
  127.             name="inheritorName"
  128.             value={inheritor.inheritorName}
  129.             onChange={(e) => {
  130.               const { name, value } = e.target;
  131.  
  132.               setHeirInfo({
  133.                 ...heirInfo,
  134.                 listOfInheritors: heirInfo.listOfInheritors.map((item, idx) =>
  135.                   idx === index ? { ...item, [name]: value } : item
  136.                 ),
  137.               });
  138.             }}
  139.           />
  140.         </td>
  141.         <td className="text-center">
  142.           <input
  143.             type="text"
  144.             className="form-control"
  145.             id="text"
  146.             placeholder="সম্পর্ক"
  147.           />
  148.         </td>
  149.         <td className="text-center">
  150.           <input
  151.             type="text"
  152.             className="form-control"
  153.             id="text"
  154.             placeholder="মন্তব্য"
  155.           />
  156.         </td>
  157.         <td className="text-center">
  158.           {index == 0 ? null : (
  159.             <button
  160.               type="button"
  161.               className="btn-icon btn-outline-lightblue font-weight-bold mr-2"
  162.             >
  163.               -
  164.             </button>
  165.           )}
  166.           <button
  167.             type="button"
  168.             className="btn-icon btn-outline-lightblue font-weight-bold mr-2"
  169.           >
  170.             +
  171.           </button>
  172.         </td>
  173.       </tr>
  174.     );
  175.   };
  176.  
  177.   return (
  178.     <>
  179.       <div className="content-wrapper">
  180.         {/* ---------------- Content Header Page Header ---------------- */}
  181.         <div className="content-header">
  182.           <div className="container-fluid">
  183.             <div className="row mb-2">
  184.               <div className="col-sm-6">
  185.                 <h1 className="m-0">ওয়ারিশান সনদের আবেদন</h1>
  186.               </div>
  187.               <div className="col-sm-6">
  188.                 <ol className="breadcrumb float-sm-right">
  189.                   <li className="breadcrumb-item">
  190.                     <NavLink to="/">হোম</NavLink>
  191.                   </li>
  192.                   <li className="breadcrumb-item active">
  193.                     ওয়ারিশান সনদের আবেদন
  194.                   </li>
  195.                 </ol>
  196.               </div>
  197.             </div>
  198.           </div>
  199.         </div>
  200.         {/* ---------------- Main Content Start ---------------- */}
  201.         <section className="content">
  202.           <div className="container-fluid">
  203.             {/* ---------------- Container Start ---------------- */}
  204.             <div className="row">
  205.               <div className="col-lg-3 col-md-3 col-sm-3"></div>
  206.               <div className="col-lg-3 col-md-3 col-sm-3"></div>
  207.               <div className="col-lg-3 col-md-3 col-sm-3"></div>
  208.               <div className="col-lg-3 col-md-3 col-sm-3">
  209.                 <button type="button" className="btn btn-block btn-lightblue">
  210.                   সবগুলো দেখুন
  211.                 </button>
  212.               </div>
  213.             </div>
  214.             <div className="row mt-3 p-3 rounded main-bg">
  215.               {/* <div className="col-lg-6 col-md-6 col-sm-6">
  216.                 <div className="form-group">
  217.                   <label htmlFor="text">Text</label>
  218.                   <input
  219.                     type="text"
  220.                     className="form-control"
  221.                     id="text"
  222.                     placeholder="Text"
  223.                   />
  224.                 </div>
  225.               </div> */}
  226.               <div className="col-lg-12 col-md-12 col-sm-12 pt-4 pb-3">
  227.                 <h4 className="text-center">আবেদনকারীর তথ্য</h4>
  228.               </div>
  229.  
  230.               <div className="col-lg-6 col-md-6 col-sm-6">
  231.                 <div className="form-group">
  232.                   <label htmlFor="text">আবেদনকারীর নাম</label>
  233.                   <input
  234.                     type="text"
  235.                     className="form-control"
  236.                     id="text"
  237.                     placeholder="আবেদনকারীর নাম"
  238.                     name="applicantsName"
  239.                     value={heirInfo.applicantsName}
  240.                     onChange={handleChange}
  241.                   />
  242.                 </div>
  243.               </div>
  244.               <div className="col-lg-6 col-md-6 col-sm-6">
  245.                 <div className="form-group">
  246.                   <label htmlFor="text">পিতার নাম</label>
  247.                   <input
  248.                     type="text"
  249.                     className="form-control"
  250.                     id="text"
  251.                     placeholder="পিতার নাম"
  252.                     name="fathersName"
  253.                     value={heirInfo.fathersName}
  254.                     onChange={handleChange}
  255.                   />
  256.                 </div>
  257.               </div>
  258.               <div className="col-lg-6 col-md-6 col-sm-6">
  259.                 <div className="form-group">
  260.                   <label htmlFor="text">মাতার নাম</label>
  261.                   <input
  262.                     type="text"
  263.                     className="form-control"
  264.                     id="text"
  265.                     placeholder="মাতার নাম"
  266.                     name="mothersName"
  267.                     value={heirInfo.mothersName}
  268.                     onChange={handleChange}
  269.                   />
  270.                 </div>
  271.               </div>
  272.               <div className="col-lg-6 col-md-6 col-sm-6">
  273.                 <div className="form-group">
  274.                   <label htmlFor="text">স্বামী/স্ত্রী-র নাম</label>
  275.                   <input
  276.                     type="text"
  277.                     className="form-control"
  278.                     id="text"
  279.                     placeholder="স্বামী/স্ত্রী-র নাম"
  280.                     name="spousesName"
  281.                     value={heirInfo.spousesName}
  282.                     onChange={handleChange}
  283.                   />
  284.                 </div>
  285.               </div>
  286.               <div className="col-lg-6 col-md-6 col-sm-6">
  287.                 <div className="form-group">
  288.                   <label htmlFor="text">ভোটার আইডি নং</label>
  289.                   <input
  290.                     type="text"
  291.                     className="form-control"
  292.                     id="text"
  293.                     placeholder="ভোটার আইডি নং"
  294.                     name="voterIdNo"
  295.                     value={heirInfo.voterIdNo}
  296.                     onChange={handleChange}
  297.                   />
  298.                 </div>
  299.               </div>
  300.               <div className="col-lg-3 col-md-3 col-sm-3">
  301.                 <div className="form-group">
  302.                   <label htmlFor="text">মোবাইল নং</label>
  303.                   <input
  304.                     type="text"
  305.                     className="form-control"
  306.                     id="text"
  307.                     placeholder="মোবাইল নং"
  308.                     name="mobileNo"
  309.                     value={heirInfo.mobileNo}
  310.                     onChange={handleChange}
  311.                   />
  312.                 </div>
  313.               </div>
  314.  
  315.               <div className="col-lg-3 col-md-3 col-sm-3">
  316.                 <div className="form-group">
  317.                   <label htmlFor="text">জাতীয়তা</label>
  318.                   <input
  319.                     type="text"
  320.                     className="form-control"
  321.                     id="text"
  322.                     placeholder="জাতীয়তা"
  323.                     name="nationality"
  324.                     value={heirInfo.nationality}
  325.                     onChange={handleChange}
  326.                   />
  327.                 </div>
  328.               </div>
  329.               <div className="col-lg-3 col-md-3 col-sm-3">
  330.                 <div className="form-group">
  331.                   <label htmlFor="text">ওয়ার্ড নং</label>
  332.                   <input
  333.                     type="text"
  334.                     className="form-control"
  335.                     id="text"
  336.                     placeholder="ওয়ার্ড নং"
  337.                     name="wardNo"
  338.                     value={heirInfo.wardNo}
  339.                     onChange={handleChange}
  340.                   />
  341.                 </div>
  342.               </div>
  343.               <div className="col-lg-3 col-md-3 col-sm-3">
  344.                 <div className="form-group">
  345.                   <label htmlFor="text">ডাকঘর</label>
  346.                   <input
  347.                     type="text"
  348.                     className="form-control"
  349.                     id="text"
  350.                     placeholder="ডাকঘর"
  351.                     name="postOffice"
  352.                     value={heirInfo.postOffice}
  353.                     onChange={handleChange}
  354.                   />
  355.                 </div>
  356.               </div>
  357.               <div className="col-lg-3 col-md-3 col-sm-3">
  358.                 <div className="form-group">
  359.                   <label htmlFor="text">উপজেলা</label>
  360.                   <input
  361.                     type="text"
  362.                     className="form-control"
  363.                     id="text"
  364.                     placeholder="উপজেলা"
  365.                     name="upozilla"
  366.                     value={heirInfo.upozilla}
  367.                     onChange={handleChange}
  368.                   />
  369.                 </div>
  370.               </div>
  371.               <div className="col-lg-3 col-md-3 col-sm-3">
  372.                 <div className="form-group">
  373.                   <label htmlFor="text">জেলা</label>
  374.                   <input
  375.                     type="text"
  376.                     className="form-control"
  377.                     id="text"
  378.                     placeholder="জেলা"
  379.                     name="district"
  380.                     value={heirInfo.district}
  381.                     onChange={handleChange}
  382.                   />
  383.                 </div>
  384.               </div>
  385.  
  386.               <div className="col-lg-12 col-md-12 col-sm-12 pt-4 pb-3">
  387.                 <h4 className="text-center">মৃত ব্যক্তির তথ্য</h4>
  388.               </div>
  389.  
  390.               <div className="col-lg-6 col-md-6 col-sm-6">
  391.                 <div className="form-group">
  392.                   <label htmlFor="text">মৃত ব্যক্তির নাম</label>
  393.                   <input
  394.                     type="text"
  395.                     className="form-control"
  396.                     id="text"
  397.                     placeholder="মৃত ব্যক্তির নাম"
  398.                     name="nameOfDead"
  399.                     value={heirInfo.nameOfDead}
  400.                     onChange={handleChange}
  401.                   />
  402.                 </div>
  403.               </div>
  404.               <div className="col-lg-6 col-md-6 col-sm-6">
  405.                 <div className="form-group">
  406.                   <label htmlFor="text">পিতার নাম</label>
  407.                   <input
  408.                     type="text"
  409.                     className="form-control"
  410.                     id="text"
  411.                     placeholder="পিতার নাম"
  412.                     name="fathersNameOfDead"
  413.                     value={heirInfo.fathersNameOfDead}
  414.                     onChange={handleChange}
  415.                   />
  416.                 </div>
  417.               </div>
  418.               <div className="col-lg-6 col-md-6 col-sm-6">
  419.                 <div className="form-group">
  420.                   <label htmlFor="text">মাতার নাম</label>
  421.                   <input
  422.                     type="text"
  423.                     className="form-control"
  424.                     id="text"
  425.                     placeholder="মাতার নাম"
  426.                     name="mothersNameOfDead"
  427.                     value={heirInfo.mothersNameOfDead}
  428.                     onChange={handleChange}
  429.                   />
  430.                 </div>
  431.               </div>
  432.               <div className="col-lg-6 col-md-6 col-sm-6">
  433.                 <div className="form-group">
  434.                   <label htmlFor="text">স্বামী/স্ত্রী-র নাম</label>
  435.                   <input
  436.                     type="text"
  437.                     className="form-control"
  438.                     id="text"
  439.                     placeholder="স্বামী/স্ত্রী-র নাম"
  440.                     name="spousesNameOfDead"
  441.                     value={heirInfo.spousesNameOfDead}
  442.                     onChange={handleChange}
  443.                   />
  444.                 </div>
  445.               </div>
  446.               <div className="col-lg-6 col-md-6 col-sm-6">
  447.                 <div className="form-group">
  448.                   <label htmlFor="text">ভোটার আইডি নং</label>
  449.                   <input
  450.                     type="text"
  451.                     className="form-control"
  452.                     id="text"
  453.                     placeholder="ভোটার আইডি নং"
  454.                     name="voterIdNoOfDead"
  455.                     value={heirInfo.voterIdNoOfDead}
  456.                     onChange={handleChange}
  457.                   />
  458.                 </div>
  459.               </div>
  460.               <div className="col-lg-3 col-md-3 col-sm-3">
  461.                 <div className="form-group">
  462.                   <label htmlFor="text">মোবাইল নং</label>
  463.                   <input
  464.                     type="text"
  465.                     className="form-control"
  466.                     id="text"
  467.                     placeholder="মোবাইল নং"
  468.                     name="mobileNoOfDead"
  469.                     value={heirInfo.mobileNoOfDead}
  470.                     onChange={handleChange}
  471.                   />
  472.                 </div>
  473.               </div>
  474.  
  475.               <div className="col-lg-3 col-md-3 col-sm-3">
  476.                 <div className="form-group">
  477.                   <label htmlFor="text">জাতীয়তা</label>
  478.                   <input
  479.                     type="text"
  480.                     className="form-control"
  481.                     id="text"
  482.                     placeholder="জাতীয়তা"
  483.                     name="nationalityOfDead"
  484.                     value={heirInfo.nationalityOfDead}
  485.                     onChange={handleChange}
  486.                   />
  487.                 </div>
  488.               </div>
  489.               <div className="col-lg-3 col-md-3 col-sm-3">
  490.                 <div className="form-group">
  491.                   <label htmlFor="text">ওয়ার্ড নং</label>
  492.                   <input
  493.                     type="text"
  494.                     className="form-control"
  495.                     id="text"
  496.                     placeholder="ওয়ার্ড নং"
  497.                     name="wardNoOfDead"
  498.                     value={heirInfo.wardNoOfDead}
  499.                     onChange={handleChange}
  500.                   />
  501.                 </div>
  502.               </div>
  503.               <div className="col-lg-3 col-md-3 col-sm-3">
  504.                 <div className="form-group">
  505.                   <label htmlFor="text">ডাকঘর</label>
  506.                   <input
  507.                     type="text"
  508.                     className="form-control"
  509.                     id="text"
  510.                     placeholder="ডাকঘর"
  511.                     name="postOfficeOfDead"
  512.                     value={heirInfo.postOfficeOfDead}
  513.                     onChange={handleChange}
  514.                   />
  515.                 </div>
  516.               </div>
  517.               <div className="col-lg-3 col-md-3 col-sm-3">
  518.                 <div className="form-group">
  519.                   <label htmlFor="text">উপজেলা</label>
  520.                   <input
  521.                     type="text"
  522.                     className="form-control"
  523.                     id="text"
  524.                     placeholder="উপজেলা"
  525.                     name="upozillaOfDead"
  526.                     value={heirInfo.upozillaOfDead}
  527.                     onChange={handleChange}
  528.                   />
  529.                 </div>
  530.               </div>
  531.               <div className="col-lg-3 col-md-3 col-sm-3">
  532.                 <div className="form-group">
  533.                   <label htmlFor="text">জেলা</label>
  534.                   <input
  535.                     type="text"
  536.                     className="form-control"
  537.                     id="text"
  538.                     placeholder="জেলা"
  539.                     name="districtOfDead"
  540.                     value={heirInfo.districtOfDead}
  541.                     onChange={handleChange}
  542.                   />
  543.                 </div>
  544.               </div>
  545.  
  546.               <div className="col-lg-12 col-md-12 col-sm-12 pt-4 pb-3">
  547.                 <h4 className="text-center">ওয়ারিশানগনের তথ্য দিন</h4>
  548.               </div>
  549.  
  550.               <div className="col-lg-12 col-md-12 col-sm-12 table-responsive">
  551.                 <table className="table table-striped" width="100%;">
  552.                   <thead>
  553.                     <tr>
  554.                       <th scope="col" className="text-center">
  555.                         #
  556.                       </th>
  557.                       <th scope="col" className="text-center">
  558.                         নাম
  559.                       </th>
  560.                       <th scope="col" className="text-center">
  561.                         সম্পর্ক
  562.                       </th>
  563.                       <th scope="col" className="text-center">
  564.                         মন্তব্য
  565.                       </th>
  566.                       <th scope="col" className="text-center actionTable">
  567.                         একশন
  568.                       </th>
  569.                     </tr>
  570.                   </thead>
  571.                   <tbody>
  572.                     {heirInfo.listOfInheritors.map((inheritor, index) => (
  573.                       <HeirInformation
  574.                         key={index}
  575.                         inheritor={inheritor}
  576.                         index={index}
  577.                       />
  578.                     ))}
  579.                   </tbody>
  580.                   <tfoot>
  581.                     {/* <tr>
  582.                       <th className="text-center"> </th>
  583.                       <th> </th>
  584.                       <th> </th>
  585.                       <th scope="row" className="text-center"></th>
  586.                       <th scope="row" className="text-right"></th>
  587.                       <th className="text-center"> </th>
  588.                     </tr> */}
  589.                   </tfoot>
  590.                 </table>
  591.               </div>
  592.  
  593.               <div className="col-lg-4 col-md-4 col-sm-4"></div>
  594.               <div className="col-lg-4 col-md-4 col-sm-4">
  595.                 <button
  596.                   type="button"
  597.                   className="btn btn-block btn-lightblue"
  598.                   onClick={handleSubmit}
  599.                 >
  600.                   জমা দিন
  601.                 </button>
  602.               </div>
  603.               <div className="col-lg-4 col-md-4 col-sm-4"></div>
  604.             </div>
  605.             {/* ---------------- Container End ---------------- */}
  606.           </div>
  607.         </section>
  608.         {/* ---------------- Main Content End ---------------- */}
  609.       </div>
  610.     </>
  611.   );
  612. };
  613.  
  614. export default HeirApplicationAdd;
  615.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement