Commit f7d3771d authored by Chunchi Che's avatar Chunchi Che

add onBlockClick

parent bad1375c
Pipeline #21448 failed with stages
in 14 minutes and 17 seconds
...@@ -3,7 +3,8 @@ import "@/styles/mat.css"; ...@@ -3,7 +3,8 @@ import "@/styles/mat.css";
import classnames from "classnames"; import classnames from "classnames";
import React, { MouseEventHandler } from "react"; import React, { MouseEventHandler } from "react";
import { CardState, DuelFieldState } from "@/stores"; import { CardState, clearAllPlaceInteradtivities, DuelFieldState } from "@/stores";
import { sendSelectPlaceResponse } from "@/api";
export const Block: React.FC<{ export const Block: React.FC<{
isExtra?: boolean; isExtra?: boolean;
...@@ -43,7 +44,7 @@ export function BlockRow<T extends DuelFieldState>(props: { ...@@ -43,7 +44,7 @@ export function BlockRow<T extends DuelFieldState>(props: {
{props.leftState ? ( {props.leftState ? (
<Block <Block
highlight={props.leftState.placeInteractivity !== undefined} highlight={props.leftState.placeInteractivity !== undefined}
onClick={() => {}} onClick={() => {onBlockClick(props.leftState!);}}
outerLeft outerLeft
/> />
) : ( ) : (
...@@ -54,14 +55,16 @@ export function BlockRow<T extends DuelFieldState>(props: { ...@@ -54,14 +55,16 @@ export function BlockRow<T extends DuelFieldState>(props: {
key={idx} key={idx}
highlight={block.placeInteractivity !== undefined} highlight={block.placeInteractivity !== undefined}
onClick={() => { onClick={() => {
// TODO onBlockClick(block);
}} }}
/> />
))} ))}
{props.rightState ? ( {props.rightState ? (
<Block <Block
highlight={props.rightState.placeInteractivity !== undefined} highlight={props.rightState.placeInteractivity !== undefined}
onClick={() => {}} onClick={() => {
onBlockClick(props.rightState!);
}}
outerRight outerRight
/> />
) : ( ) : (
...@@ -84,6 +87,12 @@ export const ExtraBlockRow: React.FC<{ ...@@ -84,6 +87,12 @@ export const ExtraBlockRow: React.FC<{
opLeft.placeInteractivity !== undefined opLeft.placeInteractivity !== undefined
} }
isExtra={true} isExtra={true}
onClick={
() => {
onBlockClick(meLeft);
onBlockClick(opLeft);
}
}
/> />
<Block <Block
highlight={ highlight={
...@@ -91,9 +100,20 @@ export const ExtraBlockRow: React.FC<{ ...@@ -91,9 +100,20 @@ export const ExtraBlockRow: React.FC<{
opRight.placeInteractivity !== undefined opRight.placeInteractivity !== undefined
} }
isExtra={true} isExtra={true}
onClick={() => { onClick={
// TODO () => {
}} onBlockClick(meRight);
onBlockClick(opRight);
}
}
/> />
</div> </div>
); );
const onBlockClick = (state: CardState) => {
if (state.placeInteractivity) {
sendSelectPlaceResponse(state.placeInteractivity.response);
clearAllPlaceInteradtivities(0);
clearAllPlaceInteradtivities(1);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment