|
| 1 | +// Copyright (c) 2021 Terminus, Inc. |
| 2 | +// |
| 3 | +// This program is free software: you can use, redistribute, and/or modify |
| 4 | +// it under the terms of the GNU Affero General Public License, version 3 |
| 5 | +// or later ("AGPL"), as published by the Free Software Foundation. |
| 6 | +// |
| 7 | +// This program is distributed in the hope that it will be useful, but WITHOUT |
| 8 | +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 9 | +// FITNESS FOR A PARTICULAR PURPOSE. |
| 10 | +// |
| 11 | +// You should have received a copy of the GNU Affero General Public License |
| 12 | +// along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 13 | + |
| 14 | +import React from 'react'; |
| 15 | +import routeInfoStore from 'core/stores/route'; |
| 16 | +import { getReleaseDetail } from 'project/services/release'; |
| 17 | +import ReleaseForm from './form'; |
| 18 | +import ReleaseApplicationDetail from './application-detail'; |
| 19 | + |
| 20 | +const ReleaseUpdate = () => { |
| 21 | + const { params } = routeInfoStore.getState((s) => s); |
| 22 | + const { releaseID } = params; |
| 23 | + const [releaseDetail, setReleaseDetail] = React.useState<RELEASE.ReleaseDetail>({} as RELEASE.ReleaseDetail); |
| 24 | + const { isProjectRelease } = releaseDetail; |
| 25 | + |
| 26 | + const getDetail = React.useCallback(async () => { |
| 27 | + if (releaseID) { |
| 28 | + const res = await getReleaseDetail({ releaseID }); |
| 29 | + if (res.success) { |
| 30 | + const { data } = res; |
| 31 | + setReleaseDetail(data); |
| 32 | + } |
| 33 | + } |
| 34 | + }, [releaseID, setReleaseDetail]); |
| 35 | + |
| 36 | + React.useEffect(() => { |
| 37 | + getDetail(); |
| 38 | + }, [getDetail]); |
| 39 | + |
| 40 | + return <div>{isProjectRelease ? <ReleaseForm /> : <ReleaseApplicationDetail isEdit={true} />}</div>; |
| 41 | +}; |
| 42 | + |
| 43 | +export default ReleaseUpdate; |
0 commit comments