chore: add and run prettier
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { useState, useEffect, ChangeEvent } from "react";
|
||||
import { useState, useEffect, ChangeEvent } from "react"
|
||||
import {
|
||||
ModalFooter,
|
||||
ModalBody,
|
||||
@@ -8,59 +8,59 @@ import {
|
||||
Field as FieldComponent,
|
||||
FieldLabel,
|
||||
TextInput,
|
||||
} from "@contentstack/venus-components";
|
||||
} from "@contentstack/venus-components"
|
||||
|
||||
import type { InsertResponse } from "~/types/imagevault";
|
||||
import type { InsertResponse } from "~/types/imagevault"
|
||||
|
||||
type ImageEditModalProps = {
|
||||
fieldData: InsertResponse;
|
||||
setData: (data: InsertResponse) => void;
|
||||
closeModal: () => void;
|
||||
};
|
||||
fieldData: InsertResponse
|
||||
setData: (data: InsertResponse) => void
|
||||
closeModal: () => void
|
||||
}
|
||||
|
||||
export default function ImageEditModal({
|
||||
fieldData,
|
||||
closeModal,
|
||||
setData,
|
||||
}: ImageEditModalProps) {
|
||||
const [altText, setAltText] = useState("");
|
||||
const [caption, setCaption] = useState("");
|
||||
const [altText, setAltText] = useState("")
|
||||
const [caption, setCaption] = useState("")
|
||||
|
||||
const assetUrl = fieldData.MediaConversions[0].Url;
|
||||
const assetUrl = fieldData.MediaConversions[0].Url
|
||||
|
||||
useEffect(() => {
|
||||
if (fieldData.Metadata && fieldData.Metadata.length) {
|
||||
const altText = fieldData.Metadata.find((meta) =>
|
||||
meta.Name.includes("AltText_")
|
||||
)?.Value;
|
||||
)?.Value
|
||||
|
||||
const caption = fieldData.Metadata.find((meta) =>
|
||||
meta.Name.includes("Title_")
|
||||
)?.Value;
|
||||
)?.Value
|
||||
|
||||
setAltText(altText ?? "");
|
||||
setCaption(caption ?? "");
|
||||
setAltText(altText ?? "")
|
||||
setCaption(caption ?? "")
|
||||
}
|
||||
}, [fieldData.Metadata]);
|
||||
}, [fieldData.Metadata])
|
||||
|
||||
function handleSave() {
|
||||
const metaData = fieldData.Metadata ?? [];
|
||||
const metaData = fieldData.Metadata ?? []
|
||||
|
||||
const newMetadata = metaData.map((meta) => {
|
||||
if (meta.Name.includes("AltText_")) {
|
||||
return { ...meta, Value: altText };
|
||||
return { ...meta, Value: altText }
|
||||
}
|
||||
if (meta.Name.includes("Title_")) {
|
||||
return { ...meta, Value: caption };
|
||||
return { ...meta, Value: caption }
|
||||
}
|
||||
return meta;
|
||||
});
|
||||
return meta
|
||||
})
|
||||
|
||||
setData({
|
||||
...fieldData,
|
||||
Metadata: newMetadata,
|
||||
});
|
||||
closeModal();
|
||||
})
|
||||
closeModal()
|
||||
}
|
||||
|
||||
return (
|
||||
@@ -120,5 +120,5 @@ export default function ImageEditModal({
|
||||
</ButtonGroup>
|
||||
</ModalFooter>
|
||||
</>
|
||||
);
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user