Skip to content

Commit

Permalink
Revert "Revert "temp storage""
Browse files Browse the repository at this point in the history
  • Loading branch information
Gemini2035 authored Jul 26, 2024
1 parent 82b1fb1 commit 240d78f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ export const SheetGroupItem: FC<SheetGroupItemProp> = ({
{groupInfo.opers?.length
? groupInfo.opers?.map((item) => (
<OperatorInGroupItem
key={item.name}
operatorInfo={item}
onOperatorSkillChange={onOperatorSkillChange}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,12 @@ interface SheetOperatorEditorFormProp {
opers?: Group['opers']
}

type FormHTMLElement = DetailedHTMLProps<
React.FormHTMLAttributes<HTMLFormElement>,
HTMLFormElement
>

const SheetOperatorEditorForm: FC<SheetOperatorEditorFormProp> = ({
name,
opers = [],
}) => {
const { existedOperators, existedGroups } = useSheet()
const { existedOperators, existedGroups, removeOperator, submitGroup } =
useSheet()
const [selectedOperators, setSelectedOperators] = useState<
OperatorInSheetOperatorEditor[]
>(
Expand All @@ -79,13 +75,29 @@ const SheetOperatorEditorForm: FC<SheetOperatorEditorFormProp> = ({
})),
)

const onSubmit: FormHTMLElement['onSubmit'] = (e) => {
const onSubmit: DetailedHTMLProps<
React.FormHTMLAttributes<HTMLFormElement>,
HTMLFormElement
>['onSubmit'] = (e) => {
e.preventDefault()
const deleteArray: number[] = []
const opers = selectedOperators.map(({ groupName, operName }) => {
if (groupName) {
const targetGroup = existedGroups.find(({ name }) => name === groupName)
return existedGroups
.find(({ name }) => name === groupName)
?.opers?.find(({ name }) => name === operName)
} else {
const index = existedOperators.findIndex(
({ name }) => name === operName,
)
deleteArray.push(index)
return existedOperators[index]
}
})
}

const onReset: FormHTMLElement['onReset'] = (e) => {
// e.preventDefault()
console.log('111')
const onReset = () => {
setSelectedOperators(
opers.map(({ name: operName }) => ({
groupName: name,
Expand All @@ -96,7 +108,7 @@ const SheetOperatorEditorForm: FC<SheetOperatorEditorFormProp> = ({

return (
<SheetContainerSkeleton title="选择干员" icon="select">
<form className="mt-3" onSubmit={onSubmit} onReset={onReset}>
<form className="mt-3" onSubmit={onSubmit}>
<div className="max-h-96 overflow-y-auto overflow-x-hidden">
<OperatorSelectorSkeleton
icon="person"
Expand Down Expand Up @@ -175,6 +187,7 @@ const SheetOperatorEditorForm: FC<SheetOperatorEditorFormProp> = ({
<Button
type="reset"
text="继续"
onClick={onReset}
className={clsx(Classes.POPOVER_DISMISS, 'mx-1')}
/>
<Button text="取消" className={Classes.POPOVER_DISMISS} />
Expand Down

0 comments on commit 240d78f

Please sign in to comment.