Skip to content

Commit d8c769c

Browse files
frozenheliumtnagorra
authored andcommitted
Update usage of project in edit tutorial form
1 parent 5502182 commit d8c769c

File tree

4 files changed

+8
-32
lines changed

4 files changed

+8
-32
lines changed

app/views/EditTutorial/index.tsx

Lines changed: 5 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -34,25 +34,19 @@ import InlineLayout from '#components/InlineLayout';
3434
import NonFieldError from '#components/NonFieldError';
3535
import PageLayout from '#components/PageLayout';
3636
import ProjectSpecificDetails from '#components/ProjectSpecificDetails';
37-
import SelectInput from '#components/SelectInput';
3837
import TextInput from '#components/TextInput';
3938
import TextOutput from '#components/TextOutput';
4039
import {
4140
AssetMimetypeEnum,
4241
ProjectTypeEnum,
4342
TutorialUpdateInput,
44-
useProjectOptionsQuery,
4543
useProjectOutputAssetsQuery,
4644
useTutorialDetailsQuery,
4745
useTutorialProjectDetailQuery,
4846
useUpdateTutorialMutation,
4947
} from '#generated/types/graphql';
5048
import useAlert from '#hooks/useAlert';
51-
import {
52-
idSelector,
53-
nameSelector,
54-
projectTypeToKeyMap,
55-
} from '#utils/common';
49+
import { projectTypeToKeyMap } from '#utils/common';
5650
import {
5751
alertCombinedError,
5852
checkAndAlertGraphQLResultError,
@@ -133,10 +127,6 @@ function NewTutorial(props: Props) {
133127
updateTutorial,
134128
] = useUpdateTutorialMutation();
135129

136-
const [{
137-
data: projectOptionsResponse,
138-
}] = useProjectOptionsQuery();
139-
140130
const [{
141131
// fetching: tutorialDataPending,
142132
data: tutorialData,
@@ -211,22 +201,22 @@ function NewTutorial(props: Props) {
211201
data: projectAssetsResponse,
212202
}] = useProjectOutputAssetsQuery({
213203
variables: {
214-
projectId: value.project ?? '',
204+
projectId: tutorialData?.tutorial.projectId ?? '',
215205
pagination: {
216206
offset: 0,
217207
limit: 10,
218208
},
219209
},
220-
pause: isNotDefined(value.project),
210+
pause: isNotDefined(tutorialData?.tutorial.projectId),
221211
});
222212

223213
const [{
224214
data: projectDetailResponse,
225215
}] = useTutorialProjectDetailQuery({
226216
variables: {
227-
projectId: value.project ?? '',
217+
projectId: tutorialData?.tutorial.projectId ?? '',
228218
},
229-
pause: isNotDefined(value.project),
219+
pause: isNotDefined(tutorialData?.tutorial.projectId),
230220
});
231221

232222
useEffect(() => {
@@ -524,18 +514,6 @@ function NewTutorial(props: Props) {
524514
withContentBackgroundAndPadding
525515
spacing="lg"
526516
>
527-
<SelectInput
528-
label="Select a project"
529-
name="project"
530-
hint="Informations like zoom level, tile server, etc will be inherited from the reference project"
531-
options={projectOptionsResponse?.projects.results}
532-
keySelector={idSelector}
533-
labelSelector={nameSelector}
534-
value={value.project}
535-
onChange={setFieldValue}
536-
error={error?.project}
537-
disabled={inputsDisabled || isDefined(tutorialIdFromParams)}
538-
/>
539517
{isDefined(projectDetailResponse) && (
540518
<>
541519
<Container

app/views/EditTutorial/schema.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@ const tutorialUpdate: TutorialUpdateFormSchema = {
3838
required: true,
3939
requiredValidation: requiredStringCondition,
4040
},
41-
// FIXME: project should not be included here
42-
project: {},
4341
status: {},
4442
informationPages: {
4543
keySelector: (informationPage) => informationPage.clientId,

app/views/NewTutorial/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import SelectInput from '#components/SelectInput';
3030
import TextInput from '#components/TextInput';
3131
import TextOutput from '#components/TextOutput';
3232
import {
33-
ProjectAssetMimetypeEnum,
33+
AssetMimetypeEnum,
3434
TutorialCreateInput,
3535
useNewTutorialMutation,
3636
useProjectOptionsQuery,
@@ -282,7 +282,7 @@ function NewTutorial(props: Props) {
282282
end={(
283283
<>
284284
{/* eslint-disable-next-line max-len */}
285-
{projectAsset.mimetype === ProjectAssetMimetypeEnum.Geojson && (
285+
{projectAsset.mimetype === AssetMimetypeEnum.Geojson && (
286286
<a
287287
// className={styles.projectAssetDownloadLink}
288288
href={`https://geojson.io/#data=data:text/x-url,${encodeURIComponent(projectAsset.file.url)}`}

0 commit comments

Comments
 (0)