export image/ file with JSON

This commit is contained in:
Anish Roy
2023-03-10 15:46:09 +05:30
parent 4e92dd39b0
commit dd02ea1811
3 changed files with 18 additions and 1 deletions

View File

@@ -34,6 +34,7 @@ export default function Cell({
const tableCell = type ? getFieldProp("TableCell", type) : null;
const { checkAndConvert } = useConverter();
const value = checkAndConvert(value_, type);
return (
<StyledTable>
<StyledCell

View File

@@ -33,6 +33,21 @@ const selectedColumnsJsonReducer =
(doc: TableRow) =>
(accumulator: Record<string, any>, currentColumn: ColumnConfig) => {
const value = get(doc, currentColumn.key);
if (
currentColumn.type === FieldType.file ||
currentColumn.type === FieldType.image
) {
return {
...accumulator,
[currentColumn.key]: value
? value
.map((item: { downloadURL: string }) => item.downloadURL)
.join()
: "",
};
}
return {
...accumulator,
[currentColumn.key]: value,

View File

@@ -16,8 +16,9 @@ export default function useConverter() {
return doc(firebaseDb, value);
};
const imageOrFileConverter = (urls: string): RowyFile[] => {
const imageOrFileConverter = (urls: any): RowyFile[] => {
if (!urls) return [];
if (Array.isArray(urls)) return urls;
if (typeof urls === "string") {
return urls
.split(",")