@@ -12,12 +12,22 @@ import {
1212
1313import { Input } from "@/components/ui/input" ;
1414import { Label } from "@/components/ui/label" ;
15- import React , { useState } from "react" ;
15+ import React , { useEffect , useState } from "react" ;
1616import SetZone from "../../maps/SetZone" ;
1717import useCreateSTS , { STS } from "@/hooks/entityCreation/useCreateSTS" ;
1818import { message } from "antd" ;
1919import { Contractor } from "@/data/roles" ;
2020import useCreateContractor from "@/hooks/entityCreation/useCreateContractor" ;
21+ import useGetAllSTS from "@/hooks/stsdata/useGetAllSTS" ;
22+ import {
23+ Select ,
24+ SelectContent ,
25+ SelectGroup ,
26+ SelectItem ,
27+ SelectLabel ,
28+ SelectTrigger ,
29+ SelectValue ,
30+ } from "@/components/ui/select" ;
2131
2232interface DialogWrapperProps {
2333 children : React . ReactNode ;
@@ -33,11 +43,14 @@ export const AddNewContractor: React.FC<DialogWrapperProps> = ({
3343 const [ workforceSize , setWorkForceSize ] = useState ( 0 ) ;
3444 const [ paymentPerTon , setPaymentPerTon ] = useState ( 0 ) ;
3545 const [ requiredWastePerDay , setRequiredWastePerDay ] = useState ( 0 ) ;
36- const [ contractDuration , setContractDuration ] = useState ( 0 ) ;
46+ const [ contractDuration , setContractDuration ] = useState ( "" ) ;
3747 const [ area , setArea ] = useState ( "" ) ;
38- const [ assignedSTS , setAssignedSTS ] = useState ( "" ) ;
48+ const [ stsId , setStsId ] = useState ( "" ) ;
3949 const { createContractor } = useCreateContractor ( ) ;
4050
51+ const { stsList } = useGetAllSTS ( ) ;
52+ useEffect ( ( ) => { } , [ stsList ] ) ;
53+
4154 const handleSaveChanges = async ( ) => {
4255 const data : Contractor = {
4356 name,
@@ -49,7 +62,7 @@ export const AddNewContractor: React.FC<DialogWrapperProps> = ({
4962 requiredWastePerDay,
5063 contractDuration,
5164 area,
52- assignedSTS ,
65+ stsId ,
5366 } ;
5467
5568 console . log ( data ) ;
@@ -164,10 +177,9 @@ export const AddNewContractor: React.FC<DialogWrapperProps> = ({
164177 < Input
165178 id = "workforceSize"
166179 placeholder = "Add Workforcesize here"
167- className = "col-span-3"
168- type = "number"
180+ className = "col-span-3"
169181 value = { contractDuration }
170- onChange = { ( e ) => setContractDuration ( parseInt ( e . target . value ) ) }
182+ onChange = { ( e ) => setContractDuration ( e . target . value ) }
171183 />
172184 </ div >
173185 < div className = "grid grid-cols-4 items-center gap-4" >
@@ -183,16 +195,30 @@ export const AddNewContractor: React.FC<DialogWrapperProps> = ({
183195 />
184196 </ div >
185197 < div className = "grid grid-cols-4 items-center gap-4" >
186- < Label htmlFor = "assignedSTS" className = "text-right" >
198+ < Label htmlFor = "assignedSTS" className = "text-right " >
187199 Assigned STS
188200 </ Label >
189- < Input
190- id = "assignedSTS"
191- placeholder = "Add Workforcesize here"
192- className = "col-span-3"
193- value = { assignedSTS }
194- onChange = { ( e ) => setAssignedSTS ( e . target . value ) }
195- />
201+ < Select
202+ value = { stsId }
203+ onValueChange = { ( e ) => setStsId ( e ) }
204+ >
205+ < SelectTrigger className = "col-span-3" >
206+ < SelectValue
207+ id = "assignedSTS"
208+ placeholder = "Select assigned STS from the list"
209+ />
210+ </ SelectTrigger >
211+ < SelectContent >
212+ < SelectGroup >
213+ < SelectLabel > STS</ SelectLabel >
214+ { stsList . map ( ( sts , index : number ) => (
215+ < SelectItem key = { index } value = { sts . id } >
216+ { sts . name }
217+ </ SelectItem >
218+ ) ) }
219+ </ SelectGroup >
220+ </ SelectContent >
221+ </ Select >
196222 </ div >
197223 </ div >
198224 < DialogFooter >
0 commit comments