11import React , { useMemo } from "react" ;
22import styled , { css } from "styled-components" ;
33
4- import { AlertMessage , DropdownCascader } from "@kleros/ui-components-library" ;
4+ import { AlertMessage , DropdownCascader , DropdownSelect } from "@kleros/ui-components-library" ;
55
66import { useNewDisputeContext } from "context/NewDisputeContext" ;
77import { rootCourtToItems , useCourtTree } from "hooks/queries/useCourtTree" ;
@@ -14,6 +14,7 @@ import { StyledSkeleton } from "components/StyledSkeleton";
1414import Header from "pages/Resolver/Header" ;
1515
1616import NavigationButtons from "../NavigationButtons" ;
17+ import { isKlerosNeo , isKlerosUniversity , isTestnetDeployment } from "src/consts" ;
1718
1819const Container = styled . div `
1920 display : flex;
@@ -49,28 +50,56 @@ const AlertMessageContainer = styled.div`
4950 margin-top : 24px ;
5051` ;
5152
53+ const StyledDropdownSelect = styled ( DropdownSelect ) `
54+ width: 84vw;
55+ margin-top: 24px;
56+ ${ landscapeStyle (
57+ ( ) => css `
58+ width : ${ responsiveSize ( 442 , 700 , 900 ) } ;
59+ `
60+ ) }
61+ ` ;
62+
5263const Court : React . FC = ( ) => {
5364 const { disputeData, setDisputeData } = useNewDisputeContext ( ) ;
5465 const { data } = useCourtTree ( ) ;
5566 const items = useMemo ( ( ) => ! isUndefined ( data ?. court ) && [ rootCourtToItems ( data . court ) ] , [ data ] ) ;
5667
57- const handleWrite = ( courtId : string ) => {
58- setDisputeData ( { ...disputeData , courtId : courtId } ) ;
68+ const disputeKitOptions = useMemo ( ( ) => {
69+ if ( isKlerosUniversity ( ) ) return [ { text : "Classic Dispute Kit" , value : 1 } ] ;
70+ if ( isKlerosNeo ( ) ) return [ { text : "Classic Dispute Kit" , value : 1 } ] ;
71+ if ( isTestnetDeployment ( ) ) return [ { text : "Classic Dispute Kit" , value : 1 } ] ;
72+ const options = [ { text : "Classic Dispute Kit" , value : 1 } ] ;
73+ if ( disputeData . courtId === "1" ) options . push ( { text : "Shutter Dispute Kit" , value : 2 } ) ;
74+ return options ;
75+ } , [ disputeData . courtId ] ) ;
76+
77+ const handleCourtWrite = ( courtId : string ) => {
78+ const newDisputeKitId = courtId === "1" ? ( disputeData . disputeKitId ?? 1 ) : 1 ;
79+ setDisputeData ( { ...disputeData , courtId, disputeKitId : newDisputeKitId } ) ;
5980 } ;
6081
82+ const handleDisputeKitChange = ( newValue : string | number ) =>
83+ setDisputeData ( { ...disputeData , disputeKitId : Number ( newValue ) } ) ;
84+
6185 return (
6286 < Container >
6387 < Header text = "Select a court to arbitrate the case" />
6488 { items ? (
6589 < StyledDropdownCascader
6690 items = { items }
67- onSelect = { ( path : string | number ) => typeof path === "string" && handleWrite ( path . split ( "/" ) . pop ( ) ! ) }
91+ onSelect = { ( path : string | number ) => typeof path === "string" && handleCourtWrite ( path . split ( "/" ) . pop ( ) ! ) }
6892 placeholder = "Select Court"
6993 value = { `/courts/${ disputeData . courtId } ` }
7094 />
7195 ) : (
7296 < StyledSkeleton width = { 240 } height = { 42 } />
7397 ) }
98+ < StyledDropdownSelect
99+ defaultValue = { disputeData . disputeKitId ?? 1 }
100+ items = { disputeKitOptions }
101+ callback = { handleDisputeKitChange }
102+ />
74103 < AlertMessageContainer >
75104 < AlertMessage
76105 title = "Check the courts available beforehand"
@@ -82,4 +111,5 @@ const Court: React.FC = () => {
82111 </ Container >
83112 ) ;
84113} ;
114+
85115export default Court ;
0 commit comments