From 37f64d4e188fc26ac436d335289c3d380bf616c2 Mon Sep 17 00:00:00 2001 From: Scott Benton Date: Wed, 24 Apr 2024 00:53:35 -0400 Subject: [PATCH] feat(homebrew): Assets, moves, and oracles can now be moved between collections and categories --- .../assets/NewAssetCard/AssetHeader.tsx | 12 +- .../AssetsSection/AssetPreviewCard.tsx | 183 ++++++++++++++++++ .../AssetsSection/Assets/MoveAssetDialog.tsx | 83 ++++++++ .../AssetsSection/AssetsSection.tsx | 76 ++++---- .../MovesSection/MoveCard.tsx | 66 +++++++ .../MovesSection/MoveMoveDialog.tsx | 77 ++++++++ .../MovesSection/MovesEditorPane.tsx | 40 ++-- .../OracleSection/OracleEditorPane.tsx | 2 + .../MoveOracleCollectionDialog.tsx | 126 ++++++++++++ .../OracleCollectionsSection.tsx | 4 +- .../Sections/OracleInfoSection.tsx | 19 ++ .../MoveOracleTableDialog.tsx | 78 ++++++++ .../OracleTablesSection/OracleTableCard.tsx | 87 ++++++--- .../OracleTablesSection.tsx | 9 +- src/stores/homebrew/homebrew.slice.type.ts | 16 +- 15 files changed, 772 insertions(+), 106 deletions(-) create mode 100644 src/pages/Homebrew/HomebrewEditorPage/AssetsSection/AssetPreviewCard.tsx create mode 100644 src/pages/Homebrew/HomebrewEditorPage/AssetsSection/Assets/MoveAssetDialog.tsx create mode 100644 src/pages/Homebrew/HomebrewEditorPage/MovesSection/MoveCard.tsx create mode 100644 src/pages/Homebrew/HomebrewEditorPage/MovesSection/MoveMoveDialog.tsx create mode 100644 src/pages/Homebrew/HomebrewEditorPage/OracleSection/Sections/OracleCollectionsSection/MoveOracleCollectionDialog.tsx create mode 100644 src/pages/Homebrew/HomebrewEditorPage/OracleSection/Sections/OracleTablesSection/MoveOracleTableDialog.tsx diff --git a/src/components/features/assets/NewAssetCard/AssetHeader.tsx b/src/components/features/assets/NewAssetCard/AssetHeader.tsx index 3e280ad4..eacf1623 100644 --- a/src/components/features/assets/NewAssetCard/AssetHeader.tsx +++ b/src/components/features/assets/NewAssetCard/AssetHeader.tsx @@ -7,10 +7,11 @@ import DeleteIcon from "@mui/icons-material/Delete"; export interface AssetHeaderProps { asset: Datasworn.Asset; onAssetRemove?: () => void; + actions?: React.ReactNode; } export function AssetHeader(props: AssetHeaderProps) { - const { asset, onAssetRemove } = props; + const { asset, onAssetRemove, actions } = props; const isLocal = getIsLocalEnvironment(); @@ -36,10 +37,13 @@ export function AssetHeader(props: AssetHeaderProps) { )} + {actions} {onAssetRemove && ( - - - + + + + + )} diff --git a/src/pages/Homebrew/HomebrewEditorPage/AssetsSection/AssetPreviewCard.tsx b/src/pages/Homebrew/HomebrewEditorPage/AssetsSection/AssetPreviewCard.tsx new file mode 100644 index 00000000..d9b19b91 --- /dev/null +++ b/src/pages/Homebrew/HomebrewEditorPage/AssetsSection/AssetPreviewCard.tsx @@ -0,0 +1,183 @@ +import { Datasworn } from "@datasworn/core"; +import { Box, Card, IconButton, Tooltip } from "@mui/material"; +import { AssetAbilities } from "components/features/assets/NewAssetCard/AssetAbilities"; +import { AssetControls } from "components/features/assets/NewAssetCard/AssetControls"; +import { AssetHeader } from "components/features/assets/NewAssetCard/AssetHeader"; +import { AssetNameAndDescription } from "components/features/assets/NewAssetCard/AssetNameAndDescription"; +import { AssetOptions } from "components/features/assets/NewAssetCard/AssetOptions"; +import { convertIdPart } from "functions/dataswornIdEncoder"; +import { StoredHomebrewAsset } from "types/homebrew/HomebrewAssets.type"; +import EditIcon from "@mui/icons-material/Edit"; +import MoveIcon from "@mui/icons-material/DriveFileMove"; + +export interface AssetPreviewCardProps { + storedAsset: StoredHomebrewAsset; + collectionName: string; + handleDeleteAsset: () => void; + handleEditAsset: () => void; + handleMoveAsset: () => void; +} + +export function AssetPreviewCard(props: AssetPreviewCardProps) { + const { + storedAsset, + collectionName, + handleDeleteAsset, + handleEditAsset, + handleMoveAsset, + } = props; + + const { label, requirement, abilities, options, controls } = storedAsset; + + const dataswornAbilities: Datasworn.AssetAbility[] = abilities.map( + (ability, index) => ({ + _id: index + "", + text: ability.text, + name: ability.name, + enabled: ability.defaultEnabled ?? false, + }) + ); + + const dataswornOptions: Record = {}; + options?.forEach((option) => { + let optionId: string; + + try { + optionId = convertIdPart(option.label); + } catch (e) { + return; + } + if (option.type === "text") { + dataswornOptions[optionId] = { + label: option.label, + field_type: "text", + value: "", + }; + } else { + const choices: Record = + {}; + + (option.options ?? []).forEach((optionChoice) => { + choices[optionChoice] = { + label: optionChoice, + choice_type: "choice", + }; + }); + + dataswornOptions[optionId] = { + label: option.label, + field_type: "select_enhancement", + value: "", + choices, + }; + } + }); + + const dataswornControls: Record = {}; + controls?.forEach((control) => { + let controlId: string; + + try { + controlId = convertIdPart(control.label); + } catch (e) { + return; + } + if (control.type === "checkbox") { + dataswornControls[controlId] = { + field_type: "checkbox", + label: control.label, + value: false, + is_impact: false, + disables_asset: false, + }; + } else if (control.type === "select") { + const choices: Record = + {}; + + (control.options ?? []).forEach((optionChoice) => { + choices[optionChoice] = { + label: optionChoice, + choice_type: "choice", + }; + }); + + dataswornControls[controlId] = { + label: control.label, + field_type: "select_enhancement", + value: "", + choices, + }; + } else if (control.type === "conditionMeter") { + dataswornControls[controlId] = { + label: control.label, + field_type: "condition_meter", + value: control.max, + max: control.max, + min: control.min, + rollable: true, + }; + } + }); + + const asset: Datasworn.Asset = { + _id: "", + name: label, + count_as_impact: false, + shared: false, + _source: { title: "", authors: [], date: "", url: "", license: "" }, + + requirement: requirement, + category: collectionName, + abilities: dataswornAbilities, + options: dataswornOptions, + controls: dataswornControls, + }; + + return ( + + + + + + + + + + + + + + } + /> + `1px solid ${theme.palette.divider}`} + sx={(theme) => ({ + borderBottomLeftRadius: theme.shape.borderRadius, + borderBottomRightRadius: theme.shape.borderRadius, + })} + > + + {}} /> + + {}} /> + + + ); +} diff --git a/src/pages/Homebrew/HomebrewEditorPage/AssetsSection/Assets/MoveAssetDialog.tsx b/src/pages/Homebrew/HomebrewEditorPage/AssetsSection/Assets/MoveAssetDialog.tsx new file mode 100644 index 00000000..5b14219b --- /dev/null +++ b/src/pages/Homebrew/HomebrewEditorPage/AssetsSection/Assets/MoveAssetDialog.tsx @@ -0,0 +1,83 @@ +import { + Autocomplete, + Box, + Button, + Dialog, + DialogActions, + DialogContent, + ListItemText, + TextField, +} from "@mui/material"; +import { DialogTitleWithCloseButton } from "components/shared/DialogTitleWithCloseButton"; +import { useEffect, useState } from "react"; +import { useStore } from "stores/store"; +import { StoredHomebrewAssetCollection } from "types/homebrew/HomebrewAssets.type"; + +export interface MoveAssetDialogProps { + onClose: () => void; + state?: { + assetId: string; + assetCollectionId: string; + }; + collections: Record; +} + +export function MoveAssetDialog(props: MoveAssetDialogProps) { + const { state, onClose, collections } = props; + const { assetId, assetCollectionId } = state ?? {}; + + const [selectedAssetCollection, setSelectedAssetCollection] = + useState(assetCollectionId); + + useEffect(() => { + setSelectedAssetCollection(assetCollectionId); + }, [assetCollectionId]); + + const updateAsset = useStore((store) => store.homebrew.updateAsset); + + const handleSave = () => { + if (assetId && selectedAssetCollection) { + updateAsset(assetId, { categoryKey: selectedAssetCollection }) + .then(() => { + onClose(); + }) + .catch(() => {}); + } + }; + + return ( + + + Move Asset + + + option} + getOptionLabel={(key) => collections[key]?.label} + renderInput={(params) => ( + + )} + renderOption={(props, option) => ( + + + + )} + value={selectedAssetCollection ?? null} + onChange={(evt, value) => { + setSelectedAssetCollection(value ?? undefined); + }} + /> + + + + + + + ); +} diff --git a/src/pages/Homebrew/HomebrewEditorPage/AssetsSection/AssetsSection.tsx b/src/pages/Homebrew/HomebrewEditorPage/AssetsSection/AssetsSection.tsx index e38ec9ce..dba1c92c 100644 --- a/src/pages/Homebrew/HomebrewEditorPage/AssetsSection/AssetsSection.tsx +++ b/src/pages/Homebrew/HomebrewEditorPage/AssetsSection/AssetsSection.tsx @@ -2,8 +2,6 @@ import { Box, Breadcrumbs, Button, - Card, - IconButton, Link, Stack, Typography, @@ -16,8 +14,8 @@ import { useStore } from "stores/store"; import { MarkdownRenderer } from "components/shared/MarkdownRenderer"; import { AssetDialog } from "./Assets/AssetDialog"; import { useConfirm } from "material-ui-confirm"; -import EditIcon from "@mui/icons-material/Edit"; -import DeleteIcon from "@mui/icons-material/Delete"; +import { AssetPreviewCard } from "./AssetPreviewCard"; +import { MoveAssetDialog } from "./Assets/MoveAssetDialog"; export interface AssetsSectionProps { homebrewId: string; @@ -34,6 +32,10 @@ export function AssetsSection(props: AssetsSectionProps) { open: boolean; assetId?: string; }>({ open: false }); + const [moveAssetDialogState, setMoveAssetDialogState] = useState<{ + assetId: string; + assetCollectionId: string; + }>(); const assetCollections = useStore( (store) => @@ -162,37 +164,36 @@ export function AssetsSection(props: AssetsSectionProps) { } /> - {filteredAssetIds.map((assetKey) => ( - - {assets[assetKey].label} - - - setAssetDialogState({ open: true, assetId: assetKey }) - } - > - - - - handleDeleteAsset(assets[assetKey].label, assetKey) - } - > - - - - - ))} + + {filteredAssetIds.map((assetKey) => ( + + handleDeleteAsset(assets[assetKey].label, assetKey) + } + handleEditAsset={() => + setAssetDialogState({ open: true, assetId: assetKey }) + } + handleMoveAsset={() => + setMoveAssetDialogState({ + assetId: assetKey, + assetCollectionId: assets[assetKey].categoryKey, + }) + } + /> + ))} + ) : ( <> @@ -233,6 +234,11 @@ export function AssetsSection(props: AssetsSectionProps) { existingAssetId={assetDialogState.assetId} /> )} + setMoveAssetDialogState(undefined)} + collections={assetCollections} + /> ); } diff --git a/src/pages/Homebrew/HomebrewEditorPage/MovesSection/MoveCard.tsx b/src/pages/Homebrew/HomebrewEditorPage/MovesSection/MoveCard.tsx new file mode 100644 index 00000000..8eac051c --- /dev/null +++ b/src/pages/Homebrew/HomebrewEditorPage/MovesSection/MoveCard.tsx @@ -0,0 +1,66 @@ +import { Box, Card, IconButton, Tooltip, Typography } from "@mui/material"; +import { + StoredMove, + StoredMoveCategory, +} from "types/homebrew/HomebrewMoves.type"; +import MoveIcon from "@mui/icons-material/DriveFileMove"; +import EditIcon from "@mui/icons-material/Edit"; +import DeleteIcon from "@mui/icons-material/Delete"; +import { useState } from "react"; +import { MoveMoveDialog } from "./MoveMoveDialog"; + +export interface MoveCardProps { + moveId: string; + move: StoredMove; + moveCategories: Record; + handleEdit: () => void; + handleDelete: () => void; +} + +export function MoveCard(props: MoveCardProps) { + const { moveId, move, moveCategories, handleEdit, handleDelete } = props; + + const [moveMoveDialogOpen, setMoveMoveDialogOpen] = useState(false); + + return ( + <> + + {move.label} + + + setMoveMoveDialogOpen(true)}> + + + + + handleEdit()}> + + + + + handleDelete()}> + + + + + + setMoveMoveDialogOpen(false)} + moveId={moveId} + moveCategoryId={move.categoryId} + categories={moveCategories} + /> + + ); +} diff --git a/src/pages/Homebrew/HomebrewEditorPage/MovesSection/MoveMoveDialog.tsx b/src/pages/Homebrew/HomebrewEditorPage/MovesSection/MoveMoveDialog.tsx new file mode 100644 index 00000000..4417b52b --- /dev/null +++ b/src/pages/Homebrew/HomebrewEditorPage/MovesSection/MoveMoveDialog.tsx @@ -0,0 +1,77 @@ +import { + Autocomplete, + Box, + Button, + Dialog, + DialogActions, + DialogContent, + ListItemText, + TextField, +} from "@mui/material"; +import { DialogTitleWithCloseButton } from "components/shared/DialogTitleWithCloseButton"; +import { useState } from "react"; +import { useStore } from "stores/store"; +import { StoredMoveCategory } from "types/homebrew/HomebrewMoves.type"; + +export interface MoveMoveDialogProps { + open: boolean; + moveId: string; + moveCategoryId: string; + categories: Record; + onClose: () => void; +} + +export function MoveMoveDialog(props: MoveMoveDialogProps) { + const { open, moveId, moveCategoryId, categories, onClose } = props; + + const [categoryId, setCategoryId] = useState( + moveCategoryId + ); + + const updateMove = useStore((store) => store.homebrew.updateMove); + const handleMove = () => { + if (categoryId) { + updateMove(moveId, { categoryId }) + .then(() => { + onClose(); + }) + .catch(() => {}); + } + }; + + return ( + + + Move Move + + + option} + getOptionLabel={(key) => categories[key]?.label} + renderInput={(params) => ( + + )} + renderOption={(props, option) => ( + + + + )} + value={categoryId ?? null} + onChange={(evt, value) => { + setCategoryId(value ?? undefined); + }} + /> + + + + + + + ); +} diff --git a/src/pages/Homebrew/HomebrewEditorPage/MovesSection/MovesEditorPane.tsx b/src/pages/Homebrew/HomebrewEditorPage/MovesSection/MovesEditorPane.tsx index dd7bc6eb..d2a2663b 100644 --- a/src/pages/Homebrew/HomebrewEditorPage/MovesSection/MovesEditorPane.tsx +++ b/src/pages/Homebrew/HomebrewEditorPage/MovesSection/MovesEditorPane.tsx @@ -23,6 +23,7 @@ import { useStore } from "stores/store"; import { useConfirm } from "material-ui-confirm"; import EditIcon from "@mui/icons-material/Edit"; import DeleteIcon from "@mui/icons-material/Delete"; +import { MoveCard } from "./MoveCard"; export interface MovesEditorPaneProps { homebrewId: string; @@ -171,35 +172,18 @@ export function MovesEditorPane(props: MovesEditorPaneProps) { {sortedMoveIds.length > 0 ? ( <> {sortedMoveIds.map((moveId) => ( - - {moves[moveId].label} - - - setMoveDialogState({ open: true, openMoveId: moveId }) - } - > - - - - handleDeleteMove(moves[moveId].label, moveId) - } - > - - - - + moveId={moveId} + move={moves[moveId]} + moveCategories={categories} + handleEdit={() => + setMoveDialogState({ open: true, openMoveId: moveId }) + } + handleDelete={() => + handleDeleteMove(moves[moveId].label, moveId) + } + /> ))} ) : ( diff --git a/src/pages/Homebrew/HomebrewEditorPage/OracleSection/OracleEditorPane.tsx b/src/pages/Homebrew/HomebrewEditorPage/OracleSection/OracleEditorPane.tsx index 4d604131..edf4d0ca 100644 --- a/src/pages/Homebrew/HomebrewEditorPage/OracleSection/OracleEditorPane.tsx +++ b/src/pages/Homebrew/HomebrewEditorPage/OracleSection/OracleEditorPane.tsx @@ -101,6 +101,7 @@ export function OracleEditorPane(props: OracleEditorPaneProps) { closeCurrentOracleCollection={() => setOpenCollectionId(breadcrumbs[breadcrumbs.length - 1].id) } + oracleCollections={oracleCollections} /> )} )} ; + onClose: () => void; +} + +export function MoveOracleCollectionDialog( + props: MoveOracleCollectionDialogProps +) { + const { + open, + oracleCollectionId, + parentOracleCollectionId, + onClose, + oracleCollections, + } = props; + + const [collectionId, setCollectionId] = useState( + parentOracleCollectionId + ); + + useEffect(() => { + setCollectionId(parentOracleCollectionId); + }, [parentOracleCollectionId]); + + console.debug(parentOracleCollectionId, collectionId, oracleCollections); + + const updateOracleCollection = useStore( + (store) => store.homebrew.updateOracleCollection + ); + const handleMove = () => { + updateOracleCollection( + oracleCollectionId, + collectionId + ? { parentOracleCollectionId: collectionId } + : { parentOracleCollectionId: deleteField() } + ) + .then(() => { + onClose(); + }) + .catch(() => {}); + }; + + return ( + + + Move Oracle Collection + + + + !isDescendantOf( + oracleCollectionId, + collectionKey, + oracleCollections + ) + )} + getOptionKey={(option) => option} + getOptionLabel={(key) => oracleCollections[key]?.label} + renderInput={(params) => ( + + )} + renderOption={(props, option) => ( + + + + )} + value={collectionId ?? null} + onChange={(evt, value) => { + setCollectionId(value ?? undefined); + }} + /> + + + + + + + ); +} + +function isDescendantOf( + currentCollectionId: string, + collectionToCheckId: string, + collections: Record +) { + if (currentCollectionId === collectionToCheckId) { + return true; + } + let parentId = collections[collectionToCheckId].parentOracleCollectionId; + while (parentId) { + if (parentId === currentCollectionId) { + return true; + } + parentId = collections[parentId].parentOracleCollectionId; + } + return false; +} diff --git a/src/pages/Homebrew/HomebrewEditorPage/OracleSection/Sections/OracleCollectionsSection/OracleCollectionsSection.tsx b/src/pages/Homebrew/HomebrewEditorPage/OracleSection/Sections/OracleCollectionsSection/OracleCollectionsSection.tsx index 70770d48..3edca33c 100644 --- a/src/pages/Homebrew/HomebrewEditorPage/OracleSection/Sections/OracleCollectionsSection/OracleCollectionsSection.tsx +++ b/src/pages/Homebrew/HomebrewEditorPage/OracleSection/Sections/OracleCollectionsSection/OracleCollectionsSection.tsx @@ -42,10 +42,10 @@ export function OracleCollectionsSection(props: OracleCollectionsSectionProps) { /> {sortedCollectionIds.length === 0 && ( diff --git a/src/pages/Homebrew/HomebrewEditorPage/OracleSection/Sections/OracleInfoSection.tsx b/src/pages/Homebrew/HomebrewEditorPage/OracleSection/Sections/OracleInfoSection.tsx index 0d1db724..293ad895 100644 --- a/src/pages/Homebrew/HomebrewEditorPage/OracleSection/Sections/OracleInfoSection.tsx +++ b/src/pages/Homebrew/HomebrewEditorPage/OracleSection/Sections/OracleInfoSection.tsx @@ -6,11 +6,13 @@ import { useConfirm } from "material-ui-confirm"; import { useState } from "react"; import { useStore } from "stores/store"; import { StoredOracleCollection } from "types/homebrew/HomebrewOracles.type"; +import { MoveOracleCollectionDialog } from "./OracleCollectionsSection/MoveOracleCollectionDialog"; export interface OracleInfoSectionProps { homebrewId: string; oracleCollectionId: string; oracleCollection: StoredOracleCollection; + oracleCollections: Record; openCollectionDialog: () => void; closeCurrentOracleCollection: () => void; } @@ -20,6 +22,7 @@ export function OracleInfoSection(props: OracleInfoSectionProps) { homebrewId, oracleCollectionId, oracleCollection, + oracleCollections, openCollectionDialog, closeCurrentOracleCollection, } = props; @@ -56,6 +59,9 @@ export function OracleInfoSection(props: OracleInfoSectionProps) { .catch(() => {}); }; + const [moveCollectionDialogOpen, setMoveCollectionDialogOpen] = + useState(false); + return ( <> Delete Collection + + + + + ); +} diff --git a/src/pages/Homebrew/HomebrewEditorPage/OracleSection/Sections/OracleTablesSection/OracleTableCard.tsx b/src/pages/Homebrew/HomebrewEditorPage/OracleSection/Sections/OracleTablesSection/OracleTableCard.tsx index 8d321cb4..7b2222ba 100644 --- a/src/pages/Homebrew/HomebrewEditorPage/OracleSection/Sections/OracleTablesSection/OracleTableCard.tsx +++ b/src/pages/Homebrew/HomebrewEditorPage/OracleSection/Sections/OracleTablesSection/OracleTableCard.tsx @@ -1,18 +1,25 @@ -import { Box, Card, IconButton, Typography } from "@mui/material"; +import { Box, Card, IconButton, Tooltip, Typography } from "@mui/material"; import EditIcon from "@mui/icons-material/Edit"; -import { StoredOracleTable } from "types/homebrew/HomebrewOracles.type"; +import { + StoredOracleCollection, + StoredOracleTable, +} from "types/homebrew/HomebrewOracles.type"; import { useStore } from "stores/store"; import DeleteIcon from "@mui/icons-material/Delete"; import { useConfirm } from "material-ui-confirm"; +import { useState } from "react"; +import MoveIcon from "@mui/icons-material/DriveFileMove"; +import { MoveOracleTableDialog } from "./MoveOracleTableDialog"; export interface OracleTableCardProps { oracleId: string; oracle: StoredOracleTable; onClick: () => void; + collections: Record; } export function OracleTableCard(props: OracleTableCardProps) { - const { oracleId, oracle, onClick } = props; + const { oracleId, oracle, onClick, collections } = props; const confirm = useConfirm(); const deleteOracle = useStore((store) => store.homebrew.deleteOracleTable); @@ -33,33 +40,53 @@ export function OracleTableCard(props: OracleTableCardProps) { .catch(() => {}); }; + const [moveOracleDialogOpen, setMoveOracleDialogOpen] = useState(false); + return ( - - - - Table - - {oracle.label} - - - - - - - - - - + <> + + + + Table + + {oracle.label} + + + + setMoveOracleDialogOpen(true)}> + + + + + + + + + + + + + + + + setMoveOracleDialogOpen(false)} + oracleCollectionId={oracle.oracleCollectionId} + oracleId={oracleId} + oracleCollections={collections} + /> + ); } diff --git a/src/pages/Homebrew/HomebrewEditorPage/OracleSection/Sections/OracleTablesSection/OracleTablesSection.tsx b/src/pages/Homebrew/HomebrewEditorPage/OracleSection/Sections/OracleTablesSection/OracleTablesSection.tsx index de0ebe4e..b5fd4a80 100644 --- a/src/pages/Homebrew/HomebrewEditorPage/OracleSection/Sections/OracleTablesSection/OracleTablesSection.tsx +++ b/src/pages/Homebrew/HomebrewEditorPage/OracleSection/Sections/OracleTablesSection/OracleTablesSection.tsx @@ -2,18 +2,22 @@ import { Button, List } from "@mui/material"; import { EmptyState } from "components/shared/EmptyState"; import { SectionHeading } from "components/shared/SectionHeading"; import { useState } from "react"; -import { StoredOracleTable } from "types/homebrew/HomebrewOracles.type"; +import { + StoredOracleCollection, + StoredOracleTable, +} from "types/homebrew/HomebrewOracles.type"; import { OracleTableDialog } from "./OracleTableDialog"; import { OracleTableCard } from "./OracleTableCard"; export interface OracleTablesSectionProps { homebrewId: string; tables: Record; + collections: Record; parentCollectionKey: string; } export function OracleTablesSection(props: OracleTablesSectionProps) { - const { homebrewId, tables, parentCollectionKey } = props; + const { homebrewId, tables, collections, parentCollectionKey } = props; const [oracleTableDialogState, setOracleTableDialogState] = useState<{ open: boolean; @@ -52,6 +56,7 @@ export function OracleTablesSection(props: OracleTablesSectionProps) { editingOracleTableId: key, }) } + collections={collections} /> ))} diff --git a/src/stores/homebrew/homebrew.slice.type.ts b/src/stores/homebrew/homebrew.slice.type.ts index 01524887..d5c8125b 100644 --- a/src/stores/homebrew/homebrew.slice.type.ts +++ b/src/stores/homebrew/homebrew.slice.type.ts @@ -1,5 +1,5 @@ import { Datasworn } from "@datasworn/core"; -import { Unsubscribe } from "firebase/firestore"; +import { PartialWithFieldValue, Unsubscribe } from "firebase/firestore"; import { StoredHomebrewAsset, StoredHomebrewAssetCollection, @@ -112,7 +112,7 @@ export interface HomebrewSliceActions { ) => Promise; updateOracleCollection: ( oracleCollectionId: string, - oracleCollection: StoredOracleCollection + oracleCollection: PartialWithFieldValue ) => Promise; deleteOracleCollection: ( homebrewId: string, @@ -122,7 +122,7 @@ export interface HomebrewSliceActions { createOracleTable: (oracleTable: StoredOracleTable) => Promise; updateOracleTable: ( oracleTableId: string, - oracleTable: StoredOracleTable + oracleTable: PartialWithFieldValue ) => Promise; deleteOracleTable: (oracleTableId: string) => Promise; @@ -139,7 +139,10 @@ export interface HomebrewSliceActions { ) => Promise; createMove: (move: StoredMove) => Promise; - updateMove: (moveId: string, move: StoredMove) => Promise; + updateMove: ( + moveId: string, + move: PartialWithFieldValue + ) => Promise; deleteMove: (moveId: string) => Promise; updateDataswornMoves: (homebrewId: string) => void; @@ -157,7 +160,10 @@ export interface HomebrewSliceActions { ) => Promise; createAsset: (asset: StoredHomebrewAsset) => Promise; - updateAsset: (assetId: string, asset: StoredHomebrewAsset) => Promise; + updateAsset: ( + assetId: string, + asset: PartialWithFieldValue + ) => Promise; deleteAsset: (assetId: string) => Promise; updateDataswornAssets: (homebrewId: string) => void;