MSP-3289 add initial value for app modal form
This commit is contained in:
1 parent
f20b30636c
commit
68f563e826
3 files changed
+28
-7
No files matched your search
@@ -2,7 +2,7 @@ import { LinkOutlined } from '@ant-design/icons'
|
||||
import { List, message, Spin, Tooltip } from 'antd'
|
||||
import { FormComponents, Layout } from 'isp-ui-kit'
|
||||
import { ColumnItem } from 'isp-ui-kit/dist/Layout/Column/column.type'
|
||||
import { Dispatch, FC, SetStateAction, useState } from 'react'
|
||||
import { Dispatch, FC, SetStateAction, useEffect, useState } from 'react'
|
||||
import { useForm } from 'react-hook-form'
|
||||
import { useNavigate, useParams, useSearchParams } from 'react-router-dom'
|
||||
|
||||
@@ -42,10 +42,12 @@ const ApplicationsContent: FC<ApplicationsContentPropTypes> = ({
|
||||
selectedItemId,
|
||||
setCurrentApplicationsApp
|
||||
}) => {
|
||||
const { data: applications, isLoading: isLoadingApplicationsContent = [] } =
|
||||
applicationsApi.useGetApplicationsByServiceIdQuery({
|
||||
id: selectedItemId
|
||||
})
|
||||
const {
|
||||
data: applications = [],
|
||||
isLoading: isLoadingApplicationsContent = []
|
||||
} = applicationsApi.useGetApplicationsByServiceIdQuery({
|
||||
id: selectedItemId
|
||||
})
|
||||
|
||||
const [createApplicationService] =
|
||||
applicationsApi.useCreateApplicationServiceMutation()
|
||||
@@ -69,6 +71,16 @@ const ApplicationsContent: FC<ApplicationsContentPropTypes> = ({
|
||||
} = useForm<ApplicationAppType>({
|
||||
mode: 'onChange'
|
||||
})
|
||||
|
||||
useEffect(() => {
|
||||
const currentItem = applications.find(
|
||||
(application) => application.app.id.toString() === appId
|
||||
)
|
||||
if (currentItem) {
|
||||
reset(currentItem.app)
|
||||
}
|
||||
}, [appId, applications])
|
||||
|
||||
const updateApplicationModal = () => {
|
||||
setShowApplicationsModal({
|
||||
...showApplicationsModal,
|
||||
|
||||
@@ -12,8 +12,8 @@ import Modal from '@widgets/Modal'
|
||||
import ApplicationsContent from '@components/ApplicationsContent'
|
||||
|
||||
import {
|
||||
NewApplicationsGroupType,
|
||||
ApplicationsGroupType,
|
||||
NewApplicationsGroupType,
|
||||
UpdateApplicationsGroupType
|
||||
} from '@pages/ApplicationsPage/applications.type.ts'
|
||||
|
||||
@@ -73,6 +73,15 @@ const ApplicationsPage = () => {
|
||||
mode: 'onChange'
|
||||
})
|
||||
|
||||
useEffect(() => {
|
||||
const currentItem = applicationsGroup.find(
|
||||
(group) => group.id.toString() === selectedItemId
|
||||
)
|
||||
if (currentItem) {
|
||||
reset(currentItem)
|
||||
}
|
||||
}, [selectedItemId,applicationsGroup])
|
||||
|
||||
if (isErrorApplicationsGroup) {
|
||||
return <EmptyData />
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ const applicationsGroupApi = createApi({
|
||||
baseQuery: axiosBaseQuery({ baseUrl: apiPaths.baseSystemUrl }),
|
||||
endpoints: (builder) => ({
|
||||
getApplicationsGroupByDomainId: builder.query<
|
||||
ApplicationsGroupType,
|
||||
ApplicationsGroupType[],
|
||||
{ id: number }
|
||||
>({
|
||||
query: (id) => ({
|
||||
|
||||
Reference in new issue
Block a user