Skip to content

Commit f09808d

Browse files
authored
Merge pull request #949 from wri/release/youthful-yucca
[RELEASE] Youthful Yucca
2 parents 46e6e94 + d135965 commit f09808d

File tree

235 files changed

+7110
-2644
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

235 files changed

+7110
-2644
lines changed

.eslintrc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ module.exports = {
5353
}
5454
],
5555
"no-unused-vars": "off",
56-
"react-hooks/exhaustive-deps": "warn",
56+
"react-hooks/exhaustive-deps": "error",
5757
"prettier/prettier": [
5858
"error",
5959
{},

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
"nookies": "^2.5.2",
6666
"prettier-plugin-tailwindcss": "^0.2.2",
6767
"query-string": "^7.1.1",
68+
"quill": "2.0.3",
6869
"ra-input-rich-text": "^4.12.2",
6970
"react": "18.2.0",
7071
"react-admin": "^4.7.4",
12.5 KB
Loading

public/images/impact-story-1.png

545 KB
Loading

public/images/impact-story-2.png

124 KB
Loading

public/images/mask.png

1.78 KB
Loading

public/images/maskRight.png

1.63 KB
Loading

src/admin/apiProvider/authProvider.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
import { AuthProvider } from "react-admin";
1+
import { AuthProvider, UserIdentity } from "react-admin";
22

33
import { loadLogin, logout } from "@/connections/Login";
44
import { loadMyUser } from "@/connections/User";
55
import Log from "@/utils/log";
66

7+
export type TMUserIdentity = UserIdentity & { primaryRole: string };
8+
79
export const authProvider: AuthProvider = {
810
login: async () => {
911
Log.error("Admin app does not support direct login");
@@ -29,7 +31,7 @@ export const authProvider: AuthProvider = {
2931
const { user } = await loadMyUser();
3032
if (user == null) throw "No user logged in.";
3133

32-
return { id: user.uuid, fullName: user.fullName ?? undefined, primaryRole: user.primaryRole };
34+
return { id: user.uuid, fullName: user.fullName ?? undefined, primaryRole: user.primaryRole } as TMUserIdentity;
3335
},
3436

3537
// get the user permissions (optional)

src/admin/apiProvider/dataProviders/fundingProgrammeDataProvider.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,6 @@ export const fundingProgrammeDataProvider: FundingDataProvider = {
152152
}
153153
});
154154
}
155-
156155
await handleUploads(params, uploadKeys, {
157156
//@ts-ignore
158157
uuid: resp.data.uuid,
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
import lo from "lodash";
2+
import { DataProvider } from "react-admin";
3+
4+
import {
5+
DeleteV2AdminImpactStoriesIdError,
6+
fetchDeleteV2AdminImpactStoriesId,
7+
fetchGetV2AdminImpactStories,
8+
fetchGetV2AdminImpactStoriesId,
9+
fetchPostV2AdminImpactStories,
10+
fetchPostV2AdminImpactStoriesBulkDelete,
11+
fetchPutV2AdminImpactStoriesId,
12+
GetV2AdminImpactStoriesError,
13+
GetV2AdminImpactStoriesIdError,
14+
PostV2AdminImpactStoriesBulkDeleteError,
15+
PostV2AdminImpactStoriesError,
16+
PutV2AdminImpactStoriesIdError
17+
} from "@/generated/apiComponents";
18+
19+
import { getFormattedErrorForRA } from "../utils/error";
20+
import { apiListResponseToRAListResult, raListParamsToQueryParams } from "../utils/listing";
21+
import { handleUploads } from "../utils/upload";
22+
23+
// @ts-ignore
24+
export const impactStoriesDataProvider: DataProvider = {
25+
async getList(_, params) {
26+
try {
27+
const response = await fetchGetV2AdminImpactStories({
28+
queryParams: raListParamsToQueryParams(params, [])
29+
});
30+
return apiListResponseToRAListResult(response);
31+
} catch (err) {
32+
throw getFormattedErrorForRA(err as GetV2AdminImpactStoriesError);
33+
}
34+
},
35+
// @ts-ignore
36+
async getOne(_, params) {
37+
try {
38+
const list = await fetchGetV2AdminImpactStoriesId({
39+
pathParams: { id: params.id }
40+
});
41+
const response = { data: list };
42+
//@ts-ignore
43+
return { data: { ...response.data, id: response.data.id } };
44+
} catch (err) {
45+
throw getFormattedErrorForRA(err as GetV2AdminImpactStoriesIdError);
46+
}
47+
},
48+
//@ts-ignore
49+
async create(__, params) {
50+
const uploadKeys = ["thumbnail"];
51+
const body: any = lo.omit(params.data, uploadKeys);
52+
try {
53+
const response = await fetchPostV2AdminImpactStories({
54+
body: body
55+
});
56+
// @ts-expect-error
57+
const uuid = response.data.uuid as string;
58+
await handleUploads(params, uploadKeys, {
59+
uuid,
60+
model: "impact-story"
61+
});
62+
// @ts-expect-error
63+
return { data: { ...response.data, id: response.id } };
64+
} catch (err) {
65+
throw getFormattedErrorForRA(err as PostV2AdminImpactStoriesError);
66+
}
67+
},
68+
//@ts-ignore
69+
async update(__, params) {
70+
const uuid = params.id as string;
71+
const uploadKeys = ["thumbnail"];
72+
const body = lo.omit(params.data, uploadKeys);
73+
74+
try {
75+
await handleUploads(params, uploadKeys, {
76+
uuid,
77+
model: "impact-story"
78+
});
79+
80+
const response = await fetchPutV2AdminImpactStoriesId({
81+
body,
82+
pathParams: { id: uuid }
83+
});
84+
85+
console.log("Params", params.data);
86+
// @ts-expect-error
87+
return { data: { ...response.data, id: response.data.uuid } };
88+
} catch (err) {
89+
throw getFormattedErrorForRA(err as PutV2AdminImpactStoriesIdError);
90+
}
91+
},
92+
93+
//@ts-ignore
94+
async delete(__, params) {
95+
try {
96+
await fetchDeleteV2AdminImpactStoriesId({
97+
pathParams: { id: params.id as string }
98+
});
99+
return { data: { id: params.id } };
100+
} catch (err) {
101+
throw getFormattedErrorForRA(err as DeleteV2AdminImpactStoriesIdError);
102+
}
103+
},
104+
// @ts-ignore
105+
async deleteMany(_, params) {
106+
try {
107+
await fetchPostV2AdminImpactStoriesBulkDelete({
108+
body: { uuids: params.ids.map(String) }
109+
});
110+
return { data: params.ids };
111+
} catch (err) {
112+
throw getFormattedErrorForRA(err as PostV2AdminImpactStoriesBulkDeleteError);
113+
}
114+
}
115+
};

0 commit comments

Comments
 (0)