Skip to content

Commit

Permalink
Add Waste Entry
Browse files Browse the repository at this point in the history
  • Loading branch information
JHM69 committed May 11, 2024
1 parent cee0166 commit 708bcdf
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ private void uploadPost(int notification_id, String currentUser_id, String descr
postMapFinal.put(getSaltString(), postMap);


if(posttype.equals("issue")){
if(posttype != null && posttype.equals("issue")){
postMapFinal.put("posttype", "issue");
postMap.put("isAnonymous", isAnonymous);
postMap.put("states", "Pending");
Expand Down
47 changes: 47 additions & 0 deletions react-app/components/WasteEntryForm/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ const WasteEntryForm = ({ type, defaultValues, onFormSubmit, ...props }) => {
? new Date(defaultValues.timeOfArrival).toISOString().slice(0, 16)
: '' // Converts to "YYYY-MM-DDTHH:MM" format
setValue('timeOfArrival', formattedTimeOfArrival)
setValue('contractorId', defaultValues.contractorId)
setValue('wasteType', defaultValues.wasteType)
setValue('vehicleType', defaultValues.vehicleType)
}
}, [defaultValues, setValue])

Expand Down Expand Up @@ -52,6 +55,50 @@ const WasteEntryForm = ({ type, defaultValues, onFormSubmit, ...props }) => {
})}
/>

<Input
name="contractorId"
label="Contractor ID"
placeholder="Contractor ID..."
type="text"
error={errors.contractorId ? errors.contractorId.message : false}
register={register('contractorId', {
required: {
value: true,
message: 'Contractor ID is required'
}
})}
/>

<Input
name="wasteType"
label="Waste Type"
placeholder="Waste Type..."
type="text"
error={errors.wasteType ? errors.wasteType.message : false}
register={register('wasteType', {
required: {
value: true,
message: 'Waste Type is required'
}
})}
/>

<Input
name="vehicleType"
label="Vehicle Type"
placeholder="Vehicle Type..."
type="text"
error={errors.vehicleType ? errors.vehicleType.message : false}
register={register('vehicleType', {
required: {
value: true,
message: 'Vehicle Type is required'
}
})}
/>



{/* <Input
name="timeOfArrival"
label="Time of Arrival"
Expand Down
26 changes: 15 additions & 11 deletions react-app/pages/vehicle-entry/[stsId].js
Original file line number Diff line number Diff line change
Expand Up @@ -140,38 +140,42 @@ export default function VehicleEntry () {
)}
</div>

<div className="flex flex-row gap-3 md:px-6">
<div className="flex w-2/3 flex-col">
<div className="flex flex-col gap-3 md:px-6">

<div className="flex w-full flex-col">
<div className="mt-3 flex items-center justify-between">
<h1 className="text-2xl font-bold text-gray-700">
Vehicle Entries{' '}
Waste Entries
</h1>
<div className="flex items-center space-x-2">
{stsId && <AddStsEntry stsId={stsId} />}
{stsId && <AddWasteEntry stsId={stsId} />}
</div>
</div>
{loading ? (
<StsItemsSkeleton />
<WasteItemsSkeleton />
) : (
<StsEntryItems vehicleEntries={vehicleEntries} />
<WasteEntryItems wasteEntries={wasteEntries} />
)}
</div>

<div className="flex w-1/3 flex-col">

<div className="flex w-full flex-col">
<div className="mt-3 flex items-center justify-between">
<h1 className="text-2xl font-bold text-gray-700">
Waste Entries
Vehicle Entries{' '}
</h1>
<div className="flex items-center space-x-2">
{stsId && <AddWasteEntry stsId={stsId} />}
{stsId && <AddStsEntry stsId={stsId} />}
</div>
</div>
{loading ? (
<WasteItemsSkeleton />
<StsItemsSkeleton />
) : (
<WasteEntryItems wasteEntries={wasteEntries} />
<StsEntryItems vehicleEntries={vehicleEntries} />
)}
</div>


</div>
</div>
</NoSSR>
Expand Down

0 comments on commit 708bcdf

Please sign in to comment.