1
1
import React from "react" ;
2
- import { Box , Divider , Grid } from "@mui/material" ;
2
+ import { Box , Typography } from "@mui/material" ;
3
3
import CippFormPage from "/src/components/CippFormPages/CippFormPage" ;
4
4
import { Layout as DashboardLayout } from "/src/layouts/index.js" ;
5
- import { useForm } from "react-hook-form" ;
5
+ import { useForm , useWatch } from "react-hook-form" ;
6
6
import CippFormComponent from "/src/components/CippComponents/CippFormComponent" ;
7
7
import { useSettings } from "/src/hooks/use-settings" ;
8
- import { darken , lighten , styled } from "@mui/system" ;
8
+ import { Grid , darken , lighten , styled } from "@mui/system" ;
9
+ import { CippPropertyList } from "/src/components/CippComponents/CippPropertyList" ;
10
+ import { CippPropertyListCard } from "../../../../components/CippCards/CippPropertyListCard" ;
11
+ import { getCippFormatting } from "../../../../utils/get-cipp-formatting" ;
12
+ import { getCippTranslation } from "../../../../utils/get-cipp-translation" ;
9
13
10
14
const Page = ( ) => {
11
15
const userSettingsDefaults = useSettings ( ) ;
@@ -19,6 +23,12 @@ const Page = () => {
19
23
iagree : false ,
20
24
} ,
21
25
} ) ;
26
+
27
+ const selectedSku = useWatch ( {
28
+ control : formControl . control ,
29
+ name : "sku" ,
30
+ } ) ;
31
+
22
32
const GroupHeader = styled ( "div" ) ( ( { theme } ) => ( {
23
33
position : "sticky" ,
24
34
top : "-8px" ,
@@ -46,7 +56,7 @@ const Page = () => {
46
56
< Box sx = { { my : 2 } } >
47
57
< Grid container spacing = { 2 } >
48
58
{ /* Conditional Access Policy Selector */ }
49
- < Grid item xs = { 6 } >
59
+ < Grid size = { { xs : 6 } } >
50
60
< CippFormComponent
51
61
type = "autoComplete"
52
62
creatable = { false }
@@ -57,20 +67,69 @@ const Page = () => {
57
67
url : "/api/ListCSPsku" ,
58
68
labelField : ( option ) => `${ option ?. name [ 0 ] ?. value } (${ option ?. sku } )` ,
59
69
valueField : "sku" ,
70
+
71
+ addedField : {
72
+ billingCycle : "billingCycle" ,
73
+ commitmentTerm : "commitmentTerm" ,
74
+ description : "description" ,
75
+ } ,
60
76
} }
61
77
multiple = { false }
62
78
formControl = { formControl }
79
+ required = { true }
80
+ validators = { {
81
+ validate : ( option ) => {
82
+ return option ?. value ? true : "This field is required." ;
83
+ } ,
84
+ } }
85
+ sortOptions = { true }
63
86
/>
64
87
</ Grid >
65
- < Grid item xs = { 6 } >
88
+ < Grid size = { { xs : 6 } } >
66
89
< CippFormComponent
67
90
type = "number"
68
91
label = "Quantity of licenses to purchase."
69
92
name = "Quantity"
70
93
formControl = { formControl }
94
+ validators = { {
95
+ required : "This field is required." ,
96
+ min : {
97
+ value : 1 ,
98
+ message : "Minimum value is 1." ,
99
+ } ,
100
+ } }
101
+ required = { true }
71
102
/>
72
103
</ Grid >
73
- < Grid item xs = { 12 } >
104
+ { selectedSku ?. value && (
105
+ < Grid size = { { xs : 12 } } >
106
+ { console . log ( selectedSku ) }
107
+ < CippPropertyListCard
108
+ title = "Selected SKU Details"
109
+ variant = "outlined"
110
+ showDivider = { false }
111
+ propertyItems = { [
112
+ { label : "Name" , value : selectedSku ?. label } ,
113
+ {
114
+ label : "Billing Cycle" ,
115
+ value : getCippTranslation ( selectedSku ?. addedFields ?. billingCycle ) ,
116
+ } ,
117
+ {
118
+ label : "Commitment Term" ,
119
+ value : getCippTranslation ( selectedSku ?. addedFields ?. commitmentTerm ) ,
120
+ } ,
121
+ {
122
+ label : "Description" ,
123
+ value : getCippFormatting (
124
+ selectedSku ?. addedFields ?. description ?. [ 0 ] ?. value ,
125
+ "htmlDescription"
126
+ ) ,
127
+ } ,
128
+ ] }
129
+ />
130
+ </ Grid >
131
+ ) }
132
+ < Grid size = { { xs : 12 } } >
74
133
< CippFormComponent
75
134
type = "checkbox"
76
135
label = "I understand that buy pressing submit this license will be purchased according to the terms and conditions for this SKU with Sherweb."
0 commit comments