diff --git a/src/components/equipment-cards/equipment-card.module.css b/src/components/equipment-cards/equipment-card.module.css
index 4f63b44..00fb13e 100644
--- a/src/components/equipment-cards/equipment-card.module.css
+++ b/src/components/equipment-cards/equipment-card.module.css
@@ -2,6 +2,8 @@
position: relative;
padding: var(--mantine-spacing-md);
transition: border-color 150ms ease;
+
+ display: flex !important;
&[data-checked] {
border-color: var(--mantine-primary-color-filled);
diff --git a/src/components/equipment-cards/index.js b/src/components/equipment-cards/index.js
index f08e566..658e638 100644
--- a/src/components/equipment-cards/index.js
+++ b/src/components/equipment-cards/index.js
@@ -16,14 +16,13 @@ export default function EquipmentCards(props) {
{equipment.map((equip) => (
<>
{selectable ? onSelect(equip, !equip.selected)} checked={!!equip.selected}>
-
-
-
- {equip.eqname}
-
-
-
- : onSelect(equip, !equip.selected)} checked={!!equip.selected}>
+
+
+ {equip.eqname}
+
+
+
+ :
{equip.eqname}
diff --git a/src/components/ploy-cards/index.js b/src/components/ploy-cards/index.js
index cfb07ad..389358b 100644
--- a/src/components/ploy-cards/index.js
+++ b/src/components/ploy-cards/index.js
@@ -1,19 +1,32 @@
-import { Card, SimpleGrid, Stack, Title } from "@mantine/core";
+import { Badge, Card, Checkbox, Group, SimpleGrid, Stack, Title } from "@mantine/core";
import { convertShapes } from "../../utils/shapes";
+import classes from './ploy-card.module.css';
export default function PloyCards(props) {
- const { killteam } = props;
+ const { killteam, selectable = false, selectedPloys: selectedPloyIds = "", onSelect = () => { } } = props;
+ const selectedPloys = new Set(selectedPloyIds.split(','));
return (
Strategic Ploys
{killteam?.ploys?.strat?.map((ploy) => (
-
-
- {ploy.ployname}
-
-
-
+ <>
+ {selectable ? onSelect(ploy, !selectedPloys.has(ploy.ployid))} checked={selectedPloys.has(ploy.ployid)}>
+
+
+
+ {ploy.ployname}
+ {`${ploy.CP} CP`}
+
+
+
+ :
+
+ {ploy.ployname}
+
+
+ }
+ >
))}
Firefight Ploys
@@ -21,7 +34,10 @@ export default function PloyCards(props) {
{killteam?.ploys?.tac?.map((ploy) => (
- {ploy.ployname}
+
+ {ploy.ployname}
+ {`${ploy.CP} CP`}
+
diff --git a/src/components/ploy-cards/ploy-card.module.css b/src/components/ploy-cards/ploy-card.module.css
new file mode 100644
index 0000000..00fb13e
--- /dev/null
+++ b/src/components/ploy-cards/ploy-card.module.css
@@ -0,0 +1,21 @@
+.root {
+ position: relative;
+ padding: var(--mantine-spacing-md);
+ transition: border-color 150ms ease;
+
+ display: flex !important;
+
+ &[data-checked] {
+ border-color: var(--mantine-primary-color-filled);
+ }
+
+ @mixin hover {
+ @mixin light {
+ background-color: var(--mantine-color-gray-0);
+ }
+
+ @mixin dark {
+ background-color: var(--mantine-color-dark-6);
+ }
+ }
+ }
\ No newline at end of file
diff --git a/src/pages/dashboard/index.js b/src/pages/dashboard/index.js
index 0b68d20..4da1ed8 100644
--- a/src/pages/dashboard/index.js
+++ b/src/pages/dashboard/index.js
@@ -59,6 +59,38 @@ export default function Dashboard() {
handleSaveUpdateRoster(newRoster);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [roster]);
+ const handleSelectPloy = React.useCallback((ploy, checked) => {
+ const newPloys = (checked ? [...(roster.ployids.split(',').filter((id) => !!id)), ploy.ployid] : [...(roster.ployids.split(',').filter((id) => !!id).filter((pl) => pl !== ploy.ployid))]);
+ const newRoster = {
+ "userid": userData.userId,
+ "rosterid": roster.rosterid,
+ "rostername": roster.rostername,
+ "factionid": roster.factionid,
+ "killteamid": roster.killteamid,
+ "seq": roster.seq,
+ "notes": roster.notes,
+ "CP": roster.CP,
+ "TP": roster.TP,
+ "VP": roster.VP,
+ "RP": roster.RP,
+ "ployids": newPloys.join(','),
+ "portraitcopyok": roster.portraitcopyok,
+ "keyword": roster.keyword,
+ "reqpts": roster.reqpts,
+ "stratnotes": roster.stratnotes,
+ "eqnotes": roster.eqnotes,
+ "specopnotes": roster.specopnotes
+ };
+ setRoster({
+ ...roster,
+ ...newRoster
+ });
+ api.request(`/roster.php`, {
+ method: "POST",
+ body: JSON.stringify(newRoster)
+ })
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, [roster]);
const handleSelectEquipment = React.useCallback((equipment, checked) => {
const newEq = {
"userid": userData.userid,
@@ -68,28 +100,22 @@ export default function Dashboard() {
"eqid": equipment.eqid
};
if (checked) {
+ setRoster({
+ ...roster,
+ rostereqs: [...roster?.rostereqs?.map((eq) => eq.eqid === equipment.eqid ? ({ ...eq, selected: 1 }) : eq)]
+ });
api.request(`/rostereq.php`, {
method: "POST",
body: JSON.stringify(newEq)
- }).then((data) => {
- if (data?.eqid) {
- setRoster({
- ...roster,
- rostereqs: [...roster?.rostereqs?.map((eq) => eq.eqid === equipment.eqid ? ({ ...eq, selected: 1 }) : eq)]
- });
- }
})
} else {
+ setRoster({
+ ...roster,
+ rostereqs: [...roster?.rostereqs?.map((eq) => eq.eqid === equipment.eqid ? ({ ...eq, selected: 0 }) : eq)]
+ });
api.request(`/rostereq.php`, {
method: "DELETE",
body: JSON.stringify(newEq)
- }).then((data) => {
- if (data?.success) {
- setRoster({
- ...roster,
- rostereqs: [...roster?.rostereqs?.map((eq) => eq.eqid === equipment.eqid ? ({ ...eq, selected: 0 }) : eq)]
- });
- }
})
}
// eslint-disable-next-line react-hooks/exhaustive-deps
@@ -147,7 +173,7 @@ export default function Dashboard() {
});
}
// eslint-disable-next-line react-hooks/exhaustive-deps
- }, [canEdit, handleUpdateOperativeWounds, handleSelectEquipment, handleQuickUpdateRoster]);
+ }, [canEdit]);
if (isFetchinigTeam) {
return ();
}
@@ -215,7 +241,7 @@ export default function Dashboard() {
-
+
{killteam.edition === "kt24" &&