Some fixes

This commit is contained in:
DrMint 2024-06-01 16:04:01 +02:00
parent fdf6655183
commit 92266834f4
3 changed files with 15 additions and 13 deletions

View File

@ -75,7 +75,6 @@ export const convertFolderToEndpointFolder = ({
];
case Collections.Pages:
return [{ relationTo: Collections.Pages, value: convertPageToEndpointPage(value) }];
// TODO: handle media type files
case Collections.Images:
if (!isImage(value)) return [];
return [{ relationTo: Collections.Images, value: convertImageToEndpointImage(value) }];

View File

@ -3,6 +3,7 @@ import { ArrayField } from "payload/types";
import { Collections } from "../../constants";
import { Credits } from "../../types/collections";
import { hasDuplicates, isDefined, isPayloadType, isUndefined } from "../../utils/asserts";
import { rowField } from "../rowField/rowField";
type Props = Omit<ArrayField, "type" | "fields">;
@ -31,6 +32,7 @@ export const creditsField = ({ validate, admin, ...props }: Props): ArrayField =
return true;
},
fields: [
rowField([
{ name: "role", type: "relationship", relationTo: Collections.CreditsRole, required: true },
{
name: "recorders",
@ -39,5 +41,6 @@ export const creditsField = ({ validate, admin, ...props }: Props): ArrayField =
required: true,
hasMany: true,
},
]),
],
});

View File

@ -232,7 +232,7 @@ const convertAttributeToEndpointAttribute = (
const { slug, icon, translations } = name;
return {
slug,
icon: icon ?? "material-symbols:category-outline",
icon: icon ?? "material-symbols:category",
translations: translations.map(({ language, name }) => ({
language: isPayloadType(language) ? language.id : language,
name,
@ -249,7 +249,7 @@ const convertAttributeToEndpointAttribute = (
const { slug, icon, translations } = name;
return {
slug,
icon: icon ?? "material-symbols:category-outline",
icon: icon ?? "material-symbols:category",
translations: translations.map(({ language, name }) => ({
language: isPayloadType(language) ? language.id : language,
name,
@ -268,7 +268,7 @@ const convertAttributeToEndpointAttribute = (
return {
slug,
icon: icon ?? "material-symbols:category-outline",
icon: icon ?? "material-symbols:category",
translations: translations.map(({ language, name }) => ({
language: isPayloadType(language) ? language.id : language,
name,
@ -286,7 +286,6 @@ export const convertSizesToPayloadImages = (
sizes: (Nullable<PayloadImage> | undefined)[],
targetSizes: number[]
): PayloadImage[] => {
if (!sizes) return [];
const processedSizes = sizes.filter(isPayloadImage);
const images: PayloadImage[] = [];
@ -308,6 +307,7 @@ export const convertSizesToPayloadImages = (
images.push(smallestImage);
}
return images;
};