Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrating to CareUI components in ResourceDetailsUpdate.tsx component #5647

Merged
merged 16 commits into from
Jun 28, 2023
Merged
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 23 additions & 16 deletions src/Components/Resource/ResourceDetailsUpdate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import {
} from "../../Redux/actions";
import { LegacySelectField } from "../Common/HelperInputFields";
import { RESOURCE_CHOICES } from "../../Common/constants";
import { UserSelect } from "../Common/UserSelect";
import { CircularProgress } from "@material-ui/core";
import {
Card,
Expand All @@ -32,6 +31,7 @@ import {
} from "@material-ui/core";
import { Cancel, Submit } from "../Common/components/ButtonV2";
import useAppHistory from "../../Common/hooks/useAppHistory";
import UserAutocompleteFormField from "../Common/UserAutocompleteFormField";
const Loading = loadable(() => import("../Common/Loading"));
const PageTitle = loadable(() => import("../Common/PageTitle"));

Expand Down Expand Up @@ -111,9 +111,12 @@ export const ResourceDetailsUpdate = (props: resourceProps) => {
getUserList({ id: state.form.assigned_to })
);

if (res && res.data && res.data.count)

if (res && res.data && res.data.count){
SetAssignedUser(res.data.results[0]);

}


setAssignedUserLoading(false);
}
}
Expand Down Expand Up @@ -143,12 +146,13 @@ export const ResourceDetailsUpdate = (props: resourceProps) => {

const handleOnSelect = (user: any) => {
const form = { ...state.form };
form["assigned_to"] = user?.id;
SetAssignedUser(user);
form["assigned_to"] = user?.value?.id;
SetAssignedUser(user.value);
dispatch({ type: "set_form", form });
};

const setFacility = (selected: any, name: string) => {

const form = { ...state.form };
form[name] = selected;
dispatch({ type: "set_form", form });
Expand Down Expand Up @@ -248,18 +252,19 @@ export const ResourceDetailsUpdate = (props: resourceProps) => {
/>
</div>
<div className="md:col-span-1">
<InputLabel>Assigned To</InputLabel>
<div className="">
{assignedUserLoading ? (
<CircularProgress size={20} />
) : (
<UserSelect
multiple={false}
selected={assignedUser}
setSelected={handleOnSelect}
errors={""}
facilityId={state.form?.approving_facility_object?.id}
/>

<UserAutocompleteFormField
label="Assigned To"
value = {assignedUser===null?undefined:assignedUser}
onChange={handleOnSelect}
error=""
name="assigned_to"
/>

)}
</div>
</div>
Expand All @@ -270,8 +275,10 @@ export const ResourceDetailsUpdate = (props: resourceProps) => {
name="approving_facility"
facilityType={1500}
selected={state.form.approving_facility_object}
setSelected={(obj) =>
setSelected={(obj) =>{
setFacility(obj, "approving_facility_object")

}
}
errors={state.errors.approving_facility}
/>
Expand Down Expand Up @@ -321,7 +328,7 @@ export const ResourceDetailsUpdate = (props: resourceProps) => {
<div className="md:col-span-2">
<InputLabel>Request Title*</InputLabel>
<LegacyTextInputField
rows={5}
minRows={5}
name="title"
variant="outlined"
margin="dense"
Expand All @@ -336,7 +343,7 @@ export const ResourceDetailsUpdate = (props: resourceProps) => {
<div className="md:col-span-2">
<InputLabel>Description of request*</InputLabel>
<LegacyMultilineInputField
rows={5}
minRows={5}
name="reason"
variant="outlined"
margin="dense"
Expand Down