Skip to content

Commit da6d2c6

Browse files
committed
feat(#3137): add image tag feature for dreps in govtool metadata
1 parent 4284399 commit da6d2c6

File tree

14 files changed

+1145
-2772
lines changed

14 files changed

+1145
-2772
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ changes.
1212

1313
### Added
1414

15+
- Add image tag for DRep in GovTool metadata [3137](https://github.com/IntersectMBO/govtool/issues/3137)
16+
1517
### Fixed
1618

1719
### Changed
@@ -20,7 +22,6 @@ changes.
2022

2123
## [v2.0.14](https://github.com/IntersectMBO/govtool/releases/tag/v2.0.14) 2025-03-05
2224

23-
2425
### Added
2526

2627
### Fixed

govtool/frontend/package-lock.json

Lines changed: 776 additions & 2464 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

govtool/frontend/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,9 @@
8888
"@typescript-eslint/parser": "^7.3.1",
8989
"@vitejs/plugin-legacy": "^6.0.0",
9090
"@vitejs/plugin-react-swc": "^3.7.2",
91-
"@vitest/browser": "^2.1.8",
92-
"@vitest/coverage-v8": "^2.1.8",
93-
"@vitest/ui": "^2.1.8",
91+
"@vitest/browser": "^3.0.7",
92+
"@vitest/coverage-v8": "^3.0.7",
93+
"@vitest/ui": "^3.0.7",
9494
"chromatic": "^11.20.0",
9595
"eslint": "^8.38.0",
9696
"eslint-config-airbnb": "^19.0.4",
@@ -108,7 +108,7 @@
108108
"typescript": "^5.0.2",
109109
"vite": "^6.0.3",
110110
"vite-plugin-compression": "^0.5.1",
111-
"vitest": "^2.1.8"
111+
"vitest": "^3.0.7"
112112
},
113113
"optionalDependencies": {
114114
"@rollup/rollup-linux-arm64-musl": "4.12.0"

govtool/frontend/src/components/molecules/DRepDataForm.tsx

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@ import DeleteOutlineIcon from "@mui/icons-material/DeleteOutline";
1212
import { Button, InfoText, Spacer, Typography } from "@atoms";
1313
import { Rules } from "@consts";
1414
import { useScreenDimension, useTranslation } from "@hooks";
15-
import { ControlledField } from "../organisms";
1615
import { DRepDataFormValues } from "@/types/dRep";
1716

17+
import { ControlledField } from "../organisms";
18+
1819
const MAX_NUMBER_OF_LINKS = 7;
1920

2021
type Props = {
@@ -100,6 +101,18 @@ export const DRepDataForm = ({ control, errors, register, watch }: Props) => {
100101
maxLength={Rules.QUALIFICATIONS.maxLength.value}
101102
/>
102103
</div>
104+
<div>
105+
<FieldDescription
106+
title={t("forms.dRepData.image")}
107+
subtitle={t("forms.dRepData.imageHelpfulText")}
108+
/>
109+
<ControlledField.Input
110+
{...{ control, errors }}
111+
data-testid="image-input"
112+
name="image"
113+
rules={Rules.IMAGE_URL}
114+
/>
115+
</div>
103116
<Box sx={{ display: "flex", flexDirection: "column", gap: 4, mt: 3 }}>
104117
<Typography
105118
variant="title2"

govtool/frontend/src/consts/dRepActions/fields.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
import i18n from "@/i18n";
2-
import { URL_REGEX, isReceivingAddress, isValidURLLength } from "@/utils";
2+
import {
3+
IMAGE_REGEX,
4+
URL_REGEX,
5+
isReceivingAddress,
6+
isValidURLLength,
7+
} from "@/utils";
38

49
export const Rules = {
510
GIVEN_NAME: {
@@ -66,4 +71,10 @@ export const Rules = {
6671
}),
6772
},
6873
},
74+
IMAGE_URL: {
75+
pattern: {
76+
value: IMAGE_REGEX,
77+
message: i18n.t("registration.fields.validations.image"),
78+
},
79+
},
6980
};

govtool/frontend/src/consts/dRepActions/jsonContext.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,14 @@ export const DREP_CONTEXT = {
3131
},
3232
paymentAddress: "CIP119:paymentAddress",
3333
givenName: "CIP119:givenName",
34-
image: "CIP119:image",
34+
image: {
35+
"@id": "CIP119:image",
36+
"@context": {
37+
ImageObject: "https://schema.org/ImageObject",
38+
contentUrl: "CIP119:contentUrl",
39+
sha256: "CIP119:sha256",
40+
},
41+
},
3542
objectives: "CIP119:objectives",
3643
motivations: "CIP119:motivations",
3744
qualifications: "CIP119:qualifications",

govtool/frontend/src/hooks/forms/useEditDRepInfoForm.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export const defaultEditDRepInfoValues: DRepDataFormValues = {
1919
objectives: "",
2020
motivations: "",
2121
qualifications: "",
22+
image: "",
2223
paymentAddress: "",
2324
linkReferences: [{ "@type": "Link", uri: "", label: "" }],
2425
identityReferences: [{ "@type": "Identity", uri: "", label: "" }],
@@ -75,7 +76,7 @@ export const useEditDRepInfoForm = (
7576
// Business Logic
7677
const generateMetadata = useCallback(async () => {
7778
const { linkReferences, identityReferences, ...rest } = getValues();
78-
const body = generateMetadataBody({
79+
const body = await generateMetadataBody({
7980
data: {
8081
...rest,
8182
references: [...(linkReferences ?? []), ...(identityReferences ?? [])],
@@ -87,6 +88,7 @@ export const useEditDRepInfoForm = (
8788
"qualifications",
8889
"paymentAddress",
8990
"doNotList",
91+
"image",
9092
],
9193
});
9294

govtool/frontend/src/hooks/forms/useRegisterAsdRepForm.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export const defaultRegisterAsDRepValues: DRepDataFormValues = {
2727
motivations: "",
2828
qualifications: "",
2929
paymentAddress: "",
30+
image: "",
3031
linkReferences: [{ "@type": "Link", uri: "", label: "" }],
3132
identityReferences: [{ "@type": "Identity", uri: "", label: "" }],
3233
storeData: false,
@@ -91,7 +92,7 @@ export const useRegisterAsdRepForm = (
9192
// Business Logic
9293
const generateMetadata = useCallback(async () => {
9394
const { linkReferences, identityReferences, ...rest } = getValues();
94-
const body = generateMetadataBody({
95+
const body = await generateMetadataBody({
9596
data: {
9697
...rest,
9798
references: [...(linkReferences ?? []), ...(identityReferences ?? [])],
@@ -103,6 +104,7 @@ export const useRegisterAsdRepForm = (
103104
"qualifications",
104105
"paymentAddress",
105106
"doNotList",
107+
"image",
106108
],
107109
});
108110

govtool/frontend/src/i18n/locales/en.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,8 @@
362362
"motivationsHelpfulText": "Why do you want to be a DRep, what personal and professional experiences do you want to share.",
363363
"qualifications": "Qualifications",
364364
"qualificationsHelpfulText": "List any qualifications that are relevant to your role as a DRep",
365+
"image": "Image",
366+
"imageHelpfulText": "A URL to an image or base64-encoded image that represents you. This could be an photo or a logo.",
365367
"paymentAddress": "Payment Address",
366368
"paymentAddressHelpfulText": "An address for DReps to receive payments. Only one address can be entered.",
367369
"doNotList": "Do Not List",
@@ -693,7 +695,8 @@
693695
"maxLength": "Max {{maxLength}} characters",
694696
"required": "This field is required",
695697
"url": "Invalid URL",
696-
"noSpaces": "No spaces allowed"
698+
"noSpaces": "No spaces allowed",
699+
"image": "Invalid image URL or properly formatted base64-encoded image"
697700
}
698701
}
699702
},

govtool/frontend/src/types/dRep.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ export type DRepDataFormValues = {
44
objectives: string;
55
motivations: string;
66
qualifications: string;
7+
image: string;
78
paymentAddress: string;
89
storeData?: boolean;
910
storingURL: string;

0 commit comments

Comments
 (0)