diff --git a/README.md b/README.md
index 664e951..92e035b 100644
--- a/README.md
+++ b/README.md
@@ -141,9 +141,8 @@ const billetBank = {
## TODO
-- [ ] Add tutorial for updating Pie Charts
-- [ ] Add tutorial for updating Statistics
+- [ ] Redo whole tutorial section
- [ ] Change cache warning on client to display time since cache refresh
- [ ] Investigate the feasibility of sorting by rank after billet sorting (Subsorting? Consider using QuickSort)
-- [ ] Add graphical data visualization
+- [x] Add graphical data visualization
- [ ] Code Refactorizing
\ No newline at end of file
diff --git a/client/src/App.js b/client/src/App.js
index da6eee7..b01b4e6 100644
--- a/client/src/App.js
+++ b/client/src/App.js
@@ -2,9 +2,9 @@ import React, { useEffect, useState } from "react";
import "./App.css";
import Collapsible from "react-collapsible";
import lists from "./modules/Generic/BilletBank";
-import MilpacParse from "./modules/Generic/MilpacParse";
import ErrorMessage from "./errorMessage";
import Statistics from "./modules/Generic/Statistics";
+import CombinedFunction from "./modules/Generic/CombinedFunction";
const CLIENT_TOKEN = process.env.REACT_APP_CLIENT_TOKEN;
const combatApiUrl = process.env.REACT_APP_COMBAT_API_URL;
@@ -141,323 +141,61 @@ function MilpacRequest() {
) : (
<>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
[]);
+
+ //console.log (billetBankObject)
+
+ if (props.usePrimaryOnly === true) {
+ for (let milpacIdCombat in milpacArray[0].combat.profiles) {
+ let name = milpacArray[0].combat.profiles[milpacIdCombat].realName;
+ let rank = milpacArray[0].combat.profiles[milpacIdCombat].rank.rankFull;
+ let primary = milpacArray[0].combat.profiles[milpacIdCombat].primary;
+ let fullName = rank + " " + name;
+ let primarySortKey =
+ milpacArray[0].combat.profiles[milpacIdCombat].primary.positionId;
+
+ for (let index in billetBankObject) {
+ if (billetBankObject[index].includes(primary.positionId)) {
+ array[index].push({
+ fullName: fullName,
+ position: primary,
+ isPrimary: "true",
+ sortKey: primarySortKey,
+ itemKey: milpacIdCombat,
+ listKey: primarySortKey + milpacIdCombat,
+ });
+ uniqueNamesSet.add(fullName);
+
+ // Sorting the array based on the order of positionIds in the billetBankObject array
+ array[index].sort((a, b) => {
+ const aIndex = billetBankObject[index].indexOf(a.sortKey);
+ const bIndex = billetBankObject[index].indexOf(b.sortKey);
+ return aIndex - bIndex;
+ });
+ }
+ }
+ }
+ } else if (props.usePrimaryOnly !== true) {
+ for (let milpacIdCombat in milpacArray[0].combat.profiles) {
+ let name = milpacArray[0].combat.profiles[milpacIdCombat].realName;
+ let rank = milpacArray[0].combat.profiles[milpacIdCombat].rank.rankFull;
+ let primary = milpacArray[0].combat.profiles[milpacIdCombat].primary;
+ let fullName = rank + " " + name;
+ let primarySortKey =
+ milpacArray[0].combat.profiles[milpacIdCombat].primary.positionId;
+
+ for (let index in billetBankObject) {
+ if (billetBankObject[index].includes(primary.positionId)) {
+ array[index].push({
+ fullName: fullName,
+ position: primary,
+ isPrimary: "true",
+ sortKey: primarySortKey,
+ itemKey: milpacIdCombat,
+ listKey: primarySortKey + milpacIdCombat,
+ });
+ uniqueNamesSet.add(fullName);
+ }
+
+ for (let index2 in milpacArray[0].combat.profiles[milpacIdCombat]
+ .secondaries) {
+ let secondary =
+ milpacArray[0].combat.profiles[milpacIdCombat].secondaries[index2];
+ let secondarySortKey =
+ milpacArray[0].combat.profiles[milpacIdCombat].secondaries[index2]
+ .positionId;
+
+ if (!billetBankObject[index].includes(secondary.positionId)) {
+ continue;
+ }
+
+ array[index].push({
+ fullName: fullName,
+ position: secondary,
+ isPrimary: "false",
+ sortKey: secondarySortKey,
+ itemKey: milpacIdCombat,
+ listKey: secondarySortKey + milpacIdCombat,
+ });
+ uniqueNamesSet.add(fullName);
+ }
+ }
+ }
+
+ for (let milpacIdReserve in milpacArray[0].reserve.profiles) {
+ let rName = milpacArray[0].reserve.profiles[milpacIdReserve].realName;
+ let rRank =
+ milpacArray[0].reserve.profiles[milpacIdReserve].rank.rankFull;
+ let rPrimary = milpacArray[0].reserve.profiles[milpacIdReserve].primary;
+ let rFullName = rRank + " " + rName;
+ let rPrimarySortKey =
+ milpacArray[0].reserve.profiles[milpacIdReserve].primary.positionId;
+
+ for (let index in billetBankObject) {
+ if (billetBankObject[index].includes(rPrimary.positionId)) {
+ array[index].push({
+ fullName: rFullName,
+ position: rPrimary,
+ isPrimary: "true",
+ sortKey: rPrimarySortKey,
+ itemKey: milpacIdReserve,
+ listKey: rPrimarySortKey + milpacIdReserve,
+ });
+ uniqueNamesSet.add(rFullName);
+ }
+
+ for (let rIndex in milpacArray[0].reserve.profiles[milpacIdReserve]
+ .secondaries) {
+ let rSecondary =
+ milpacArray[0].reserve.profiles[milpacIdReserve].secondaries[
+ rIndex
+ ];
+ let rSecondarySortKey =
+ milpacArray[0].reserve.profiles[milpacIdReserve].secondaries[rIndex]
+ .positionId;
+
+ if (!billetBankObject[index].includes(rSecondary.positionId)) {
+ continue;
+ }
+
+ array[index].push({
+ fullName: rFullName,
+ position: rSecondary,
+ isPrimary: "false",
+ sortKey: rSecondarySortKey,
+ itemKey: milpacIdReserve,
+ listKey: rSecondarySortKey + milpacIdReserve,
+ });
+ uniqueNamesSet.add(rFullName);
+ }
+
+ // Sorting the array based on the order of positionIds in the billetBankObject array
+ array[index].sort((a, b) => {
+ const aIndex = billetBankObject[index].indexOf(a.sortKey);
+ const bIndex = billetBankObject[index].indexOf(b.sortKey);
+ return aIndex - bIndex;
+ });
+ }
+ }
+ }
+
+ return (
+
+
+
+
+
+
+ {array.map((subArray, index) => (
+
+
+
+ {headerTitles[index]}
+ |
+
+ Unit Strength: {array[index].length}
+ |
+
+ {subArray.map((item, subIndex) => (
+
+
+
+ {item.fullName}
+
+ |
+ {item.position.positionTitle} |
+
+ ))}
+
+ ))}
+
+
+
+
+
+
+ );
+}
+
+export default CombinedFunction;
diff --git a/client/src/modules/Generic/MilpacParse.js b/client/src/modules/Generic/MilpacParse.js
deleted file mode 100644
index 4d19474..0000000
--- a/client/src/modules/Generic/MilpacParse.js
+++ /dev/null
@@ -1,208 +0,0 @@
-import React from "react";
-
-function MilpacParse(props) {
- const uniqueNamesSet = new Set();
- var array = [];
- var milpacArray = props.milpacArray;
- var billetIDs = props.billetIDs;
- var usePrimaryOnly = props.usePrimaryOnly;
- var subtitle = props.subtitle;
-
- if (usePrimaryOnly !== true) {
- for (var milpacIdCombat in milpacArray[0].combat.profiles) {
- var name = milpacArray[0].combat.profiles[milpacIdCombat].realName;
- var rank = milpacArray[0].combat.profiles[milpacIdCombat].rank.rankFull;
- var primary = milpacArray[0].combat.profiles[milpacIdCombat].primary;
- var fullName = rank + " " + name;
- var primarySortKey =
- milpacArray[0].combat.profiles[milpacIdCombat].primary.positionId;
-
- if (billetIDs.includes(primary.positionId)) {
- array.push({
- fullName: fullName,
- position: primary,
- isPrimary: "true",
- sortKey: primarySortKey,
- itemKey: milpacIdCombat,
- listKey: primarySortKey + milpacIdCombat,
- });
- uniqueNamesSet.add(fullName);
- }
-
- for (var index in milpacArray[0].combat.profiles[milpacIdCombat]
- .secondaries) {
- var secondary =
- milpacArray[0].combat.profiles[milpacIdCombat].secondaries[index];
- var secondarySortKey =
- milpacArray[0].combat.profiles[milpacIdCombat].secondaries[index]
- .positionId;
-
- if (!billetIDs.includes(secondary.positionId)) {
- continue;
- }
-
- array.push({
- fullName: fullName,
- position: secondary,
- isPrimary: "false",
- sortKey: secondarySortKey,
- itemKey: milpacIdCombat,
- listKey: secondarySortKey + milpacIdCombat,
- });
- uniqueNamesSet.add(fullName);
- }
- }
-
- for (var milpacIdReserve in milpacArray[0].reserve.profiles) {
- var rName = milpacArray[0].reserve.profiles[milpacIdReserve].realName;
- var rRank =
- milpacArray[0].reserve.profiles[milpacIdReserve].rank.rankFull;
- var rPrimary = milpacArray[0].reserve.profiles[milpacIdReserve].primary;
- var rFullName = rRank + " " + rName;
- var rPrimarySortKey =
- milpacArray[0].reserve.profiles[milpacIdReserve].primary.positionId;
-
- if (billetIDs.includes(rPrimary.positionId)) {
- array.push({
- fullName: rFullName,
- position: rPrimary,
- isPrimary: "true",
- sortKey: rPrimarySortKey,
- itemKey: milpacIdReserve,
- listKey: rPrimarySortKey + milpacIdReserve,
- });
- uniqueNamesSet.add(rFullName);
- }
-
- for (var rIndex in milpacArray[0].reserve.profiles[milpacIdReserve]
- .secondaries) {
- var rSecondary =
- milpacArray[0].reserve.profiles[milpacIdReserve].secondaries[rIndex];
- var rSecondarySortKey =
- milpacArray[0].reserve.profiles[milpacIdReserve].secondaries[rIndex]
- .positionId;
-
- if (!billetIDs.includes(rSecondary.positionId)) {
- continue;
- }
-
- array.push({
- fullName: rFullName,
- position: rSecondary,
- isPrimary: "false",
- sortKey: rSecondarySortKey,
- itemKey: milpacIdReserve,
- listKey: rSecondarySortKey + milpacIdReserve,
- });
- uniqueNamesSet.add(rFullName);
- }
- }
-
- // Sorting the array based on the order of positionIds in the billetIDs array
- array.sort((a, b) => {
- const aIndex = billetIDs.indexOf(a.sortKey);
- const bIndex = billetIDs.indexOf(b.sortKey);
- return aIndex - bIndex;
- });
-
- return (
-
-
-
{subtitle}
-
Unit Strength: {uniqueNamesSet.size}
-
-
-
-
-
- Name |
- Billet |
-
-
-
- {array.map((obj) => {
- return (
-
-
-
- {obj.fullName}
-
- |
- {obj.position.positionTitle} |
-
- );
- })}
-
-
-
-
- );
- } else if (usePrimaryOnly === true) {
- for (milpacIdCombat in milpacArray[0].combat.profiles) {
- name = milpacArray[0].combat.profiles[milpacIdCombat].realName;
- rank = milpacArray[0].combat.profiles[milpacIdCombat].rank.rankFull;
- primary = milpacArray[0].combat.profiles[milpacIdCombat].primary;
- fullName = rank + " " + name;
- primarySortKey =
- milpacArray[0].combat.profiles[milpacIdCombat].primary.positionId;
-
- if (billetIDs.includes(primary.positionId)) {
- array.push({
- fullName: fullName,
- position: primary,
- isPrimary: "true",
- sortKey: primarySortKey,
- itemKey: milpacIdCombat,
- listKey: primarySortKey + milpacIdCombat,
- });
- uniqueNamesSet.add(fullName);
- }
- }
-
- // Sorting the array based on the order of positionIds in the billetIDs array
- array.sort((a, b) => {
- const aIndex = billetIDs.indexOf(a.sortKey);
- const bIndex = billetIDs.indexOf(b.sortKey);
- return aIndex - bIndex;
- });
-
- return (
-
-
-
{subtitle}
-
Unit Strength: {uniqueNamesSet.size}
-
-
-
-
-
- Name |
- Billet |
-
-
-
- {array.map((obj) => {
- return (
-
-
-
- {obj.fullName}
-
- |
- {obj.position.positionTitle} |
-
- );
- })}
-
-
-
-
- );
- }
-}
-
-export default MilpacParse;