Merge pull request #4 from Accords-Library/develop

Quick fix for the last commit
This commit is contained in:
DrMint 2022-03-06 01:27:17 +01:00 committed by GitHub
commit 5e18039edc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 101 deletions

View File

@ -51,7 +51,7 @@ export default function LibrarySlug(props: LibrarySlugProps): JSX.Element {
const isVariantSet = const isVariantSet =
item.metadata.length > 0 && item.metadata.length > 0 &&
item.metadata[0].__typename === "ComponentMetadataOther" && item.metadata[0].__typename === "ComponentMetadataGroup" &&
item.metadata[0].subtype.data.attributes.slug === "variant-set"; item.metadata[0].subtype.data.attributes.slug === "variant-set";
sortContent(item.contents); sortContent(item.contents);
@ -184,9 +184,7 @@ export default function LibrarySlug(props: LibrarySlugProps): JSX.Element {
<InsetBox id="details" className="grid place-items-center"> <InsetBox id="details" className="grid place-items-center">
<div className="w-[clamp(0px,100%,42rem)] grid place-items gap-8"> <div className="w-[clamp(0px,100%,42rem)] grid place-items gap-8">
<h2 className="text-2xl text-center"> <h2 className="text-2xl text-center">{langui.details}</h2>
{langui.details}
</h2>
<div className="grid grid-flow-col w-full place-content-between"> <div className="grid grid-flow-col w-full place-content-between">
{item.metadata.length > 0 ? ( {item.metadata.length > 0 ? (
<div className="grid place-items-center"> <div className="grid place-items-center">
@ -256,9 +254,7 @@ export default function LibrarySlug(props: LibrarySlugProps): JSX.Element {
{item.metadata.length > 0 ? ( {item.metadata.length > 0 ? (
<> <>
<h3 className="text-xl"> <h3 className="text-xl">{langui.type_information}</h3>
{langui.type_information}
</h3>
<div className="grid grid-cols-2 w-full place-content-between"> <div className="grid grid-cols-2 w-full place-content-between">
{item.metadata[0].__typename === "ComponentMetadataBooks" ? ( {item.metadata[0].__typename === "ComponentMetadataBooks" ? (
<> <>
@ -312,21 +308,8 @@ export default function LibrarySlug(props: LibrarySlugProps): JSX.Element {
"ComponentMetadataGame" ? ( "ComponentMetadataGame" ? (
<></> <></>
) : item.metadata[0].__typename === ) : item.metadata[0].__typename ===
"ComponentMetadataOther" ? ( "ComponentMetadataGroup" ? (
<> <></>
<div className="flex flex-row place-content-start gap-4">
<p className="font-bold">{langui.type}:</p>
<Chip>
{item.metadata[0].subtype.data.attributes.titles
.length > 0
? item.metadata[0].subtype.data.attributes.titles[0]
.title
: prettySlug(
item.metadata[0].subtype.data.attributes.slug
)}
</Chip>
</div>
</>
) : ( ) : (
"" ""
)} )}
@ -344,9 +327,7 @@ export default function LibrarySlug(props: LibrarySlugProps): JSX.Element {
className="grid place-items-center gap-8 w-full" className="grid place-items-center gap-8 w-full"
> >
<h2 className="text-2xl"> <h2 className="text-2xl">
{isVariantSet {isVariantSet ? langui.variants : langui.subitems}
? langui.variants
: langui.subitems}
</h2> </h2>
<div className="grid gap-8 items-end mobile:grid-cols-2 grid-cols-[repeat(auto-fill,minmax(15rem,1fr))] w-full"> <div className="grid gap-8 items-end mobile:grid-cols-2 grid-cols-[repeat(auto-fill,minmax(15rem,1fr))] w-full">
{item.subitems.data.map((subitem) => ( {item.subitems.data.map((subitem) => (
@ -549,7 +530,7 @@ function useTesting(props: LibrarySlugProps) {
); );
} else { } else {
if ( if (
libraryItem.metadata[0].__typename === "ComponentMetadataOther" && libraryItem.metadata[0].__typename === "ComponentMetadataGroup" &&
(libraryItem.metadata[0].subtype.data.attributes.slug === (libraryItem.metadata[0].subtype.data.attributes.slug ===
"relation-set" || "relation-set" ||
libraryItem.metadata[0].subtype.data.attributes.slug === libraryItem.metadata[0].subtype.data.attributes.slug ===
@ -599,80 +580,14 @@ function useTesting(props: LibrarySlugProps) {
} else { } else {
// This is a normal item // This is a normal item
if (libraryItem.metadata[0].__typename === "ComponentMetadataOther") { if (libraryItem.metadata[0].__typename === "ComponentMetadataGroup") {
if ( if (libraryItem.subitems.data.length === 0) {
libraryItem.metadata[0].subtype.data.attributes.slug === prettyTestError(
"audio-case" router,
) { "Group-type item should have subitems",
let hasAudioSubItem = false; ["libraryItem"],
libraryItem.subitems.data.map((subitem) => { libraryItemURL
if ( );
subitem.attributes.metadata.length > 0 &&
subitem.attributes.metadata[0].__typename ===
"ComponentMetadataAudio"
)
hasAudioSubItem = true;
});
if (!hasAudioSubItem) {
prettyTestError(
router,
"Audio-case item doesn't have an audio-typed subitem",
["libraryItem"],
libraryItemURL
);
}
} else if (
libraryItem.metadata[0].subtype.data.attributes.slug === "game-case"
) {
let hasGameSubItem = false;
libraryItem.subitems.data.map((subitem) => {
if (
subitem.attributes.metadata.length > 0 &&
subitem.attributes.metadata[0].__typename ===
"ComponentMetadataGame"
)
hasGameSubItem = true;
});
if (!hasGameSubItem) {
prettyTestError(
router,
"Game-case item doesn't have an Game-typed subitem",
["libraryItem"],
libraryItemURL
);
}
} else if (
libraryItem.metadata[0].subtype.data.attributes.slug ===
"video-case"
) {
let hasVideoSubItem = false;
libraryItem.subitems.data.map((subitem) => {
if (
subitem.attributes.metadata.length > 0 &&
subitem.attributes.metadata[0].__typename ===
"ComponentMetadataVideo"
)
hasVideoSubItem = true;
});
if (!hasVideoSubItem) {
prettyTestError(
router,
"Video-case item doesn't have an Video-typed subitem",
["libraryItem"],
libraryItemURL
);
}
} else if (
libraryItem.metadata[0].subtype.data.attributes.slug === "item-set"
) {
if (libraryItem.subitems.data.length === 0) {
prettyTestError(
router,
"Item-set item should have subitems",
["libraryItem"],
libraryItemURL
);
}
} }
} }

View File

@ -108,7 +108,7 @@ export function prettyItemSubType(metadata: {
metadata.subitems_type.data.attributes.titles.length > 0 metadata.subitems_type.data.attributes.titles.length > 0
? metadata.subitems_type.data.attributes.titles[0].title ? metadata.subitems_type.data.attributes.titles[0].title
: prettySlug(metadata.subitems_type.data.attributes.slug); : prettySlug(metadata.subitems_type.data.attributes.slug);
return `${secondPart} ${firstPart})`; return `${secondPart} ${firstPart}`;
} }
default: default:
return ""; return "";