-
Notifications
You must be signed in to change notification settings - Fork 1
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 #949 from wri/release/youthful-yucca
[RELEASE] Youthful Yucca
- Loading branch information
Showing
235 changed files
with
7,110 additions
and
2,644 deletions.
There are no files selected for viewing
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
115 changes: 115 additions & 0 deletions
115
src/admin/apiProvider/dataProviders/impactStoriesDataProvider.ts
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,115 @@ | ||
import lo from "lodash"; | ||
import { DataProvider } from "react-admin"; | ||
|
||
import { | ||
DeleteV2AdminImpactStoriesIdError, | ||
fetchDeleteV2AdminImpactStoriesId, | ||
fetchGetV2AdminImpactStories, | ||
fetchGetV2AdminImpactStoriesId, | ||
fetchPostV2AdminImpactStories, | ||
fetchPostV2AdminImpactStoriesBulkDelete, | ||
fetchPutV2AdminImpactStoriesId, | ||
GetV2AdminImpactStoriesError, | ||
GetV2AdminImpactStoriesIdError, | ||
PostV2AdminImpactStoriesBulkDeleteError, | ||
PostV2AdminImpactStoriesError, | ||
PutV2AdminImpactStoriesIdError | ||
} from "@/generated/apiComponents"; | ||
|
||
import { getFormattedErrorForRA } from "../utils/error"; | ||
import { apiListResponseToRAListResult, raListParamsToQueryParams } from "../utils/listing"; | ||
import { handleUploads } from "../utils/upload"; | ||
|
||
// @ts-ignore | ||
export const impactStoriesDataProvider: DataProvider = { | ||
async getList(_, params) { | ||
try { | ||
const response = await fetchGetV2AdminImpactStories({ | ||
queryParams: raListParamsToQueryParams(params, []) | ||
}); | ||
return apiListResponseToRAListResult(response); | ||
} catch (err) { | ||
throw getFormattedErrorForRA(err as GetV2AdminImpactStoriesError); | ||
} | ||
}, | ||
// @ts-ignore | ||
async getOne(_, params) { | ||
try { | ||
const list = await fetchGetV2AdminImpactStoriesId({ | ||
pathParams: { id: params.id } | ||
}); | ||
const response = { data: list }; | ||
//@ts-ignore | ||
return { data: { ...response.data, id: response.data.id } }; | ||
} catch (err) { | ||
throw getFormattedErrorForRA(err as GetV2AdminImpactStoriesIdError); | ||
} | ||
}, | ||
//@ts-ignore | ||
async create(__, params) { | ||
const uploadKeys = ["thumbnail"]; | ||
const body: any = lo.omit(params.data, uploadKeys); | ||
try { | ||
const response = await fetchPostV2AdminImpactStories({ | ||
body: body | ||
}); | ||
// @ts-expect-error | ||
const uuid = response.data.uuid as string; | ||
await handleUploads(params, uploadKeys, { | ||
uuid, | ||
model: "impact-story" | ||
}); | ||
// @ts-expect-error | ||
return { data: { ...response.data, id: response.id } }; | ||
} catch (err) { | ||
throw getFormattedErrorForRA(err as PostV2AdminImpactStoriesError); | ||
} | ||
}, | ||
//@ts-ignore | ||
async update(__, params) { | ||
const uuid = params.id as string; | ||
const uploadKeys = ["thumbnail"]; | ||
const body = lo.omit(params.data, uploadKeys); | ||
|
||
try { | ||
await handleUploads(params, uploadKeys, { | ||
uuid, | ||
model: "impact-story" | ||
}); | ||
|
||
const response = await fetchPutV2AdminImpactStoriesId({ | ||
body, | ||
pathParams: { id: uuid } | ||
}); | ||
|
||
console.log("Params", params.data); | ||
// @ts-expect-error | ||
return { data: { ...response.data, id: response.data.uuid } }; | ||
} catch (err) { | ||
throw getFormattedErrorForRA(err as PutV2AdminImpactStoriesIdError); | ||
} | ||
}, | ||
|
||
//@ts-ignore | ||
async delete(__, params) { | ||
try { | ||
await fetchDeleteV2AdminImpactStoriesId({ | ||
pathParams: { id: params.id as string } | ||
}); | ||
return { data: { id: params.id } }; | ||
} catch (err) { | ||
throw getFormattedErrorForRA(err as DeleteV2AdminImpactStoriesIdError); | ||
} | ||
}, | ||
// @ts-ignore | ||
async deleteMany(_, params) { | ||
try { | ||
await fetchPostV2AdminImpactStoriesBulkDelete({ | ||
body: { uuids: params.ids.map(String) } | ||
}); | ||
return { data: params.ids }; | ||
} catch (err) { | ||
throw getFormattedErrorForRA(err as PostV2AdminImpactStoriesBulkDeleteError); | ||
} | ||
} | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import DownloadIcon from "@mui/icons-material/GetApp"; | ||
import { Button, CreateButton, FilterButton, TopToolbar } from "react-admin"; | ||
import { When } from "react-if"; | ||
|
||
interface ListActionsProps { | ||
onExport?: () => void; | ||
} | ||
|
||
const ListActionsImpactStories = (props: ListActionsProps) => ( | ||
<TopToolbar> | ||
<FilterButton className="filter-button-page-admin" /> | ||
<When condition={!!props.onExport}> | ||
<Button className="button-page-admin" label="Export" startIcon={<DownloadIcon />} onClick={props.onExport} /> | ||
</When> | ||
<CreateButton className="filter-button-page-admin-blue" label="Add Story" /> | ||
</TopToolbar> | ||
); | ||
|
||
export default ListActionsImpactStories; |
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 was deleted.
Oops, something went wrong.
Oops, something went wrong.