@@ -43,7 +43,7 @@ const Projects: React.FC = async () => { | |||||
color="secondary" | color="secondary" | ||||
startIcon={<Add />} | startIcon={<Add />} | ||||
LinkComponent={Link} | LinkComponent={Link} | ||||
href="/projects/create/sub" | |||||
href="/projects/createSub" | |||||
> | > | ||||
{t("Create Sub Project")} | {t("Create Sub Project")} | ||||
</Button>} | </Button>} | ||||
@@ -15,9 +15,9 @@ const pathToLabelMap: { [path: string]: string } = { | |||||
"/home": "User Workspace", | "/home": "User Workspace", | ||||
"/projects": "Projects", | "/projects": "Projects", | ||||
"/projects/create": "Create Project", | "/projects/create": "Create Project", | ||||
"/projects/create/sub": "Sub Project", | |||||
"/projects/createSub": "Sub Project", | |||||
"/projects/edit": "Edit Project", | "/projects/edit": "Edit Project", | ||||
"/projects/edit/sub": "Sub Project", | |||||
"/projects/editSub": "Sub Project", | |||||
"/tasks": "Task Template", | "/tasks": "Task Template", | ||||
"/tasks/create": "Create Task Template", | "/tasks/create": "Create Task Template", | ||||
"/staffReimbursement": "Staff Reimbursement", | "/staffReimbursement": "Staff Reimbursement", | ||||
@@ -72,11 +72,11 @@ function ControlledAutoComplete< | |||||
</li> | </li> | ||||
); | ); | ||||
}} | }} | ||||
// renderTags={(tagValue, getTagProps) => { | |||||
// return tagValue.map((option, index) => ( | |||||
// <Chip {...getTagProps({ index })} key={option?.id} label={option.label ?? option.name} /> | |||||
// )) | |||||
// }} | |||||
renderTags={(tagValue, getTagProps) => { | |||||
return tagValue.map((option, index) => ( | |||||
<Chip {...getTagProps({ index })} key={option?.id} label={option.label ?? option.name} /> | |||||
)) | |||||
}} | |||||
onChange={(event, value) => { | onChange={(event, value) => { | ||||
field.onChange(value?.map(v => v.id)) | field.onChange(value?.map(v => v.id)) | ||||
}} | }} | ||||
@@ -99,11 +99,11 @@ function ControlledAutoComplete< | |||||
</MenuItem> | </MenuItem> | ||||
); | ); | ||||
}} | }} | ||||
// renderTags={(tagValue, getTagProps) => { | |||||
// return tagValue.map((option, index) => ( | |||||
// <Chip {...getTagProps({ index })} key={option?.id} label={option.label ?? option.name} /> | |||||
// )) | |||||
// }} | |||||
renderTags={(tagValue, getTagProps) => { | |||||
return tagValue.map((option, index) => ( | |||||
<Chip {...getTagProps({ index })} key={option?.id} label={option.label ?? option.name} /> | |||||
)) | |||||
}} | |||||
onChange={(event, value) => { | onChange={(event, value) => { | ||||
field.onChange(value?.id ?? null) | field.onChange(value?.id ?? null) | ||||
}} | }} | ||||
@@ -50,6 +50,16 @@ const Milestone: React.FC<Props> = ({ allTasks, isActive }) => { | |||||
const [currentTaskGroupId, setCurrentTaskGroupId] = useState( | const [currentTaskGroupId, setCurrentTaskGroupId] = useState( | ||||
taskGroups[0].id, | taskGroups[0].id, | ||||
); | ); | ||||
/*const onSelectTaskGroup = useCallback( | |||||
(event: SelectChangeEvent<TaskGroup["id"]>) => { | |||||
const id = event.target.value; | |||||
const newTaksGroupId = typeof id === "string" ? parseInt(id) : id; | |||||
setCurrentTaskGroupId(newTaksGroupId); | |||||
}, | |||||
[], | |||||
);*/ | |||||
const onSelectTaskGroup = useCallback( | const onSelectTaskGroup = useCallback( | ||||
(event: SyntheticEvent<Element, Event>, value: NonNullable<TaskGroup>) => { | (event: SyntheticEvent<Element, Event>, value: NonNullable<TaskGroup>) => { | ||||
const id = value.id; | const id = value.id; | ||||
@@ -113,6 +113,7 @@ const ProjectClientDetails: React.FC<Props> = ({ | |||||
// get customer (client) contact combo | // get customer (client) contact combo | ||||
const [firstCustomerLoaded, setFirstCustomerLoaded] = useState(false) | const [firstCustomerLoaded, setFirstCustomerLoaded] = useState(false) | ||||
const [isMainProjectInfoLoading, setIsMainProjectInfoLoading] = useState(false) | |||||
useEffect(() => { | useEffect(() => { | ||||
if (selectedCustomerId !== undefined) { | if (selectedCustomerId !== undefined) { | ||||
fetchCustomer(selectedCustomerId).then(({ contacts, subsidiaryIds }) => { | fetchCustomer(selectedCustomerId).then(({ contacts, subsidiaryIds }) => { | ||||
@@ -120,8 +121,10 @@ const ProjectClientDetails: React.FC<Props> = ({ | |||||
setCustomerSubsidiaryIds(subsidiaryIds); | setCustomerSubsidiaryIds(subsidiaryIds); | ||||
// if (subsidiaryIds.length > 0) setValue("clientSubsidiaryId", subsidiaryIds[0]) | // if (subsidiaryIds.length > 0) setValue("clientSubsidiaryId", subsidiaryIds[0]) | ||||
// else | |||||
if (isEditMode && !firstCustomerLoaded) { setFirstCustomerLoaded(true) } else setValue("clientSubsidiaryId", null) | |||||
// else | |||||
if (isEditMode && !firstCustomerLoaded) { setFirstCustomerLoaded(true) } | |||||
else if (!isEditMode && isMainProjectInfoLoading) { setIsMainProjectInfoLoading(false) } | |||||
else setValue("clientSubsidiaryId", null) | |||||
// if (contacts.length > 0) setValue("clientContactId", contacts[0].id) | // if (contacts.length > 0) setValue("clientContactId", contacts[0].id) | ||||
// else setValue("clientContactId", undefined) | // else setValue("clientContactId", undefined) | ||||
}); | }); | ||||
@@ -160,6 +163,7 @@ const ProjectClientDetails: React.FC<Props> = ({ | |||||
const mainProject = mainProjects.find(project => project.projectId === mainProjectId); | const mainProject = mainProjects.find(project => project.projectId === mainProjectId); | ||||
if (mainProject !== undefined) { | if (mainProject !== undefined) { | ||||
setIsMainProjectInfoLoading(() => true) | |||||
setValue("projectName", mainProject.projectName) | setValue("projectName", mainProject.projectName) | ||||
setValue("projectCategoryId", mainProject.projectCategoryId) | setValue("projectCategoryId", mainProject.projectCategoryId) | ||||
setValue("projectLeadId", mainProject.projectLeadId) | setValue("projectLeadId", mainProject.projectLeadId) | ||||
@@ -62,7 +62,7 @@ const ProjectSearch: React.FC<Props> = ({ projects, projectCategories }) => { | |||||
const onProjectClick = useCallback( | const onProjectClick = useCallback( | ||||
(project: ProjectResult) => { | (project: ProjectResult) => { | ||||
if (Boolean(project.mainProject)) { | if (Boolean(project.mainProject)) { | ||||
router.push(`/projects/edit/sub?id=${project.id}`); | |||||
router.push(`/projects/editSub?id=${project.id}`); | |||||
} else router.push(`/projects/edit?id=${project.id}`); | } else router.push(`/projects/edit?id=${project.id}`); | ||||
}, | }, | ||||
[router], | [router], | ||||