You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

172 rivejä
5.5 KiB

  1. import * as React from "react";
  2. import Grid from "@mui/material/Grid";
  3. import { useState, useEffect, useMemo } from "react";
  4. import Paper from "@mui/material/Paper";
  5. import { TFunction } from "i18next";
  6. import { useTranslation } from "react-i18next";
  7. import { Card, CardHeader } from "@mui/material";
  8. import CustomSearchForm from "../CustomSearchForm/CustomSearchForm";
  9. import CustomDatagrid from "../CustomDatagrid/CustomDatagrid";
  10. import ReactApexChart from "react-apexcharts";
  11. import { ApexOptions } from "apexcharts";
  12. import { GridColDef, GridRowSelectionModel } from "@mui/x-data-grid";
  13. import ReportProblemIcon from "@mui/icons-material/ReportProblem";
  14. import dynamic from "next/dynamic";
  15. import "../../app/global.css";
  16. import { AnyARecord, AnyCnameRecord } from "dns";
  17. import SearchBox, { Criterion } from "../SearchBox";
  18. import ProgressByClientSearch from "@/components/ProgressByClientSearch";
  19. import { Suspense } from "react";
  20. interface Props {
  21. Title: string;
  22. TotalActiveProjectNumber: number;
  23. TotalFees: number;
  24. TotalBudget: number;
  25. TotalCumulative: number;
  26. TotalInvoicedAmount: number;
  27. TotalReceivedAmount: number;
  28. CashFlowStatus: string;
  29. CostPerformanceIndex: number;
  30. ClickedIndex: number;
  31. Index: number;
  32. }
  33. const ProjectFinancialCard: React.FC<Props> = ({
  34. Title,
  35. TotalActiveProjectNumber,
  36. TotalFees,
  37. TotalBudget,
  38. TotalCumulative,
  39. TotalInvoicedAmount,
  40. TotalReceivedAmount,
  41. CashFlowStatus,
  42. CostPerformanceIndex,
  43. ClickedIndex,
  44. Index,
  45. }) => {
  46. const [SearchCriteria, setSearchCriteria] = React.useState({});
  47. const { t } = useTranslation("dashboard");
  48. const borderColor =
  49. CashFlowStatus === "Negative"
  50. ? "border-red-300 border-solid"
  51. : "border-green-200 border-solid";
  52. const selectedBackgroundColor =
  53. ClickedIndex === Index ? "rgb(235 235 235)" : "rgb(255 255 255)";
  54. return (
  55. <Card
  56. style={{
  57. maxWidth: "25%",
  58. minWidth: "280px",
  59. boxShadow:
  60. "0 0px 10px 0 rgba(0, 0, 0, 0.08), 0 0px 10px 0 rgba(0, 0, 0, 0.08)",
  61. backgroundColor: selectedBackgroundColor,
  62. }}
  63. className={`${borderColor}`}
  64. >
  65. <div
  66. className="text-xl mt-2 font-medium"
  67. style={{ width: "100%", textAlign: "center", color: "#898d8d" }}
  68. >
  69. {Title}
  70. </div>
  71. <hr />
  72. <div className="text-sm font-medium ml-5" style={{ color: "#898d8d" }}>
  73. Total Active Project
  74. </div>
  75. <div className="text-lg font-medium ml-5" style={{ color: "#6b87cf" }}>
  76. {TotalActiveProjectNumber.toLocaleString()}
  77. </div>
  78. <hr />
  79. <div className="text-sm font-medium ml-5" style={{ color: "#898d8d" }}>
  80. Total Fees
  81. </div>
  82. <div className="text-lg font-medium ml-5" style={{ color: "#6b87cf" }}>
  83. {TotalFees.toLocaleString(undefined, { minimumFractionDigits: 2, maximumFractionDigits: 2 })}
  84. </div>
  85. <hr />
  86. <div className="text-sm font-medium ml-5" style={{ color: "#898d8d" }}>
  87. Total Budget
  88. </div>
  89. <div className="text-lg font-medium ml-5" style={{ color: "#6b87cf" }}>
  90. {TotalBudget.toLocaleString(undefined, { minimumFractionDigits: 2, maximumFractionDigits: 2 })}
  91. </div>
  92. <hr />
  93. <div className="text-sm font-medium ml-5" style={{ color: "#898d8d" }}>
  94. Total Cumulative Expenditure
  95. </div>
  96. <div className="text-lg font-medium ml-5" style={{ color: "#6b87cf" }}>
  97. {TotalCumulative.toLocaleString(undefined, { minimumFractionDigits: 2, maximumFractionDigits: 2 })}
  98. </div>
  99. <hr />
  100. <div className="text-sm font-medium ml-5" style={{ color: "#898d8d" }}>
  101. Total Invoiced Amount
  102. </div>
  103. <div className="text-lg font-medium ml-5" style={{ color: "#6b87cf" }}>
  104. {TotalInvoicedAmount.toLocaleString(undefined, { minimumFractionDigits: 2, maximumFractionDigits: 2 })}
  105. </div>
  106. <hr />
  107. <div className="text-sm font-medium ml-5" style={{ color: "#898d8d" }}>
  108. Total Received Amount
  109. </div>
  110. <div className="text-lg font-medium ml-5" style={{ color: "#6b87cf" }}>
  111. {TotalReceivedAmount.toLocaleString(undefined, { minimumFractionDigits: 2, maximumFractionDigits: 2 })}
  112. </div>
  113. <hr />
  114. <div className="text-sm font-medium ml-5" style={{ color: "#898d8d" }}>
  115. Cash Flow Status
  116. </div>
  117. {CashFlowStatus === "Negative" && (
  118. <>
  119. <div
  120. className="text-lg font-medium ml-5"
  121. style={{ color: "#f896aa" }}
  122. >
  123. {CashFlowStatus}
  124. </div>
  125. <hr />
  126. </>
  127. )}
  128. {CashFlowStatus === "Positive" && (
  129. <>
  130. <div
  131. className="text-lg font-medium ml-5"
  132. style={{ color: "#71d19e" }}
  133. >
  134. {CashFlowStatus}
  135. </div>
  136. <hr />
  137. </>
  138. )}
  139. <div
  140. className="text-sm mt-2 font-medium ml-5"
  141. style={{ color: "#898d8d" }}
  142. >
  143. Cost Performance Index (CPI)
  144. </div>
  145. {Number(CostPerformanceIndex) < 1 && (
  146. <>
  147. <div
  148. className="text-lg font-medium ml-5 mb-2"
  149. style={{ color: "#f896aa" }}
  150. >
  151. {CostPerformanceIndex}
  152. </div>
  153. </>
  154. )}
  155. {Number(CostPerformanceIndex) >= 1 && (
  156. <>
  157. <div
  158. className="text-lg font-medium ml-5 mb-2"
  159. style={{ color: "#71d19e" }}
  160. >
  161. {CostPerformanceIndex}
  162. </div>
  163. </>
  164. )}
  165. </Card>
  166. );
  167. };
  168. export default ProjectFinancialCard;