-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1206 from Chia-Network/refactor/upsert-unit-upser…
…t-project Refactor/upsert unit and project modal frameworks
- Loading branch information
Showing
8 changed files
with
226 additions
and
103 deletions.
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
src/renderer/components/blocks/modals/UpsertProjectModal.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import React from 'react'; | ||
import { ComponentCenteredSpinner, Modal } from '@/components'; | ||
import { useWildCardUrlHash } from '@/hooks'; | ||
import { useGetProjectQuery } from '@/api'; | ||
import { FormattedMessage } from 'react-intl'; | ||
|
||
interface UpsertModalProps { | ||
onClose: () => void; | ||
} | ||
|
||
const UpsertProjectModal: React.FC<UpsertModalProps> = ({ onClose }: UpsertModalProps) => { | ||
const [, createProjectModalActive] = useWildCardUrlHash('create-project'); | ||
const [projectUpsertFragment] = useWildCardUrlHash('edit-project'); | ||
const warehouseProjectId = projectUpsertFragment.replace('edit-project-', ''); | ||
const { data: projectData, isLoading: projectLoading } = useGetProjectQuery({ warehouseProjectId }); | ||
|
||
const ModalHeader: React.FC = () => { | ||
return ( | ||
<Modal.Header> | ||
{createProjectModalActive ? <FormattedMessage id="create-project" /> : <FormattedMessage id="edit-project" />} | ||
</Modal.Header> | ||
); | ||
}; | ||
|
||
if (projectLoading) { | ||
return ( | ||
<Modal show={true} onClose={onClose}> | ||
<ModalHeader /> | ||
<Modal.Body> | ||
<ComponentCenteredSpinner /> | ||
</Modal.Body> | ||
</Modal> | ||
); | ||
} | ||
|
||
return ( | ||
<Modal show={true} onClose={onClose}> | ||
<ModalHeader /> | ||
<Modal.Body> | ||
<p>the project form goes here {projectData?.warehouseProjectId}</p> | ||
</Modal.Body> | ||
</Modal> | ||
); | ||
}; | ||
|
||
export { UpsertProjectModal }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import React from 'react'; | ||
import { ComponentCenteredSpinner, Modal } from '@/components'; | ||
import { useWildCardUrlHash } from '@/hooks'; | ||
import { useGetUnitQuery } from '@/api'; | ||
import { FormattedMessage } from 'react-intl'; | ||
|
||
interface UpsertModalProps { | ||
onClose: () => void; | ||
} | ||
|
||
const UpsertUnitModal: React.FC<UpsertModalProps> = ({ onClose }: UpsertModalProps) => { | ||
const [, createUnitModalActive] = useWildCardUrlHash('create-unit'); | ||
const [unitUpsertFragment] = useWildCardUrlHash('edit-unit'); | ||
const warehouseUnitId = unitUpsertFragment.replace('edit-unit-', ''); | ||
const { data: unitData, isLoading: unitLoading } = useGetUnitQuery({ warehouseUnitId }); | ||
|
||
const ModalHeader: React.FC = () => { | ||
return ( | ||
<Modal.Header> | ||
{createUnitModalActive ? <FormattedMessage id="create-unit" /> : <FormattedMessage id="edit-unit" />} | ||
</Modal.Header> | ||
); | ||
}; | ||
|
||
if (unitLoading) { | ||
return ( | ||
<Modal show={true} onClose={onClose}> | ||
<ModalHeader /> | ||
<Modal.Body> | ||
<ComponentCenteredSpinner /> | ||
</Modal.Body> | ||
</Modal> | ||
); | ||
} | ||
|
||
return ( | ||
<Modal show={true} onClose={onClose}> | ||
<ModalHeader /> | ||
<Modal.Body> | ||
<p>the unit form goes here {unitData?.warehouseUnitId}</p> | ||
</Modal.Body> | ||
</Modal> | ||
); | ||
}; | ||
|
||
export { UpsertUnitModal }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.