1
1
import React , { useMemo } from "react" ;
2
2
import styled , { css } from "styled-components" ;
3
3
4
- import { AlertMessage , DropdownCascader } from "@kleros/ui-components-library" ;
4
+ import { AlertMessage , DropdownCascader , DropdownSelect } from "@kleros/ui-components-library" ;
5
5
6
6
import { useNewDisputeContext } from "context/NewDisputeContext" ;
7
7
import { rootCourtToItems , useCourtTree } from "hooks/queries/useCourtTree" ;
@@ -14,6 +14,7 @@ import { StyledSkeleton } from "components/StyledSkeleton";
14
14
import Header from "pages/Resolver/Header" ;
15
15
16
16
import NavigationButtons from "../NavigationButtons" ;
17
+ import { isKlerosNeo , isKlerosUniversity , isTestnetDeployment } from "src/consts" ;
17
18
18
19
const Container = styled . div `
19
20
display : flex;
@@ -49,28 +50,56 @@ const AlertMessageContainer = styled.div`
49
50
margin-top : 24px ;
50
51
` ;
51
52
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
+
52
63
const Court : React . FC = ( ) => {
53
64
const { disputeData, setDisputeData } = useNewDisputeContext ( ) ;
54
65
const { data } = useCourtTree ( ) ;
55
66
const items = useMemo ( ( ) => ! isUndefined ( data ?. court ) && [ rootCourtToItems ( data . court ) ] , [ data ] ) ;
56
67
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 } ) ;
59
80
} ;
60
81
82
+ const handleDisputeKitChange = ( newValue : string | number ) =>
83
+ setDisputeData ( { ...disputeData , disputeKitId : Number ( newValue ) } ) ;
84
+
61
85
return (
62
86
< Container >
63
87
< Header text = "Select a court to arbitrate the case" />
64
88
{ items ? (
65
89
< StyledDropdownCascader
66
90
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 ( ) ! ) }
68
92
placeholder = "Select Court"
69
93
value = { `/courts/${ disputeData . courtId } ` }
70
94
/>
71
95
) : (
72
96
< StyledSkeleton width = { 240 } height = { 42 } />
73
97
) }
98
+ < StyledDropdownSelect
99
+ defaultValue = { disputeData . disputeKitId ?? 1 }
100
+ items = { disputeKitOptions }
101
+ callback = { handleDisputeKitChange }
102
+ />
74
103
< AlertMessageContainer >
75
104
< AlertMessage
76
105
title = "Check the courts available beforehand"
@@ -82,4 +111,5 @@ const Court: React.FC = () => {
82
111
</ Container >
83
112
) ;
84
113
} ;
114
+
85
115
export default Court ;
0 commit comments