Skip to content

Commit

Permalink
Implemented illustrators, pokemon and trainer collections
Browse files Browse the repository at this point in the history
  • Loading branch information
Dimbreath committed Oct 3, 2024
1 parent 05fdc70 commit e52a829
Show file tree
Hide file tree
Showing 9 changed files with 395 additions and 1 deletion.
39 changes: 39 additions & 0 deletions app/_custom/collections/illustrators.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import type { CollectionConfig } from "payload/types";

import { isStaff } from "../../db/collections/users/users.access";

export const Illustrators: CollectionConfig = {
slug: "illustrators",
labels: { singular: "illustrator", plural: "illustrators" },
admin: {
group: "Custom",
useAsTitle: "name",
},
access: {
create: isStaff,
read: () => true,
update: isStaff,
delete: isStaff,
},
fields: [
{
name: "id",
type: "text",
},
{
name: "name",
type: "text",
},
{
name: "cards",
type: "relationship",
relationTo: ["pokemon-cards", "trainer-cards"],
hasMany: true,
},
{
name: "checksum",
type: "text",
required: true,
},
],
};
20 changes: 19 additions & 1 deletion app/_custom/collections/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,19 @@
export const CustomCollections = [];
import { Illustrators } from "./illustrators";
import { PokemonAbilities } from "./pokemon-abilities";
import { PokemonAttacks } from "./pokemon-attacks";
import { PokemonCards } from "./pokemon-cards";
import { PokemonTypes } from "./pokemon-types";
import { Rarities } from "./rarities";
import { TrainerCardTypes } from "./trainer-card-types";
import { TrainerCards } from "./trainer-cards";

export const CustomCollections = [
Illustrators,
PokemonAbilities,
PokemonAttacks,
PokemonCards,
PokemonTypes,
Rarities,
TrainerCards,
TrainerCardTypes
]
37 changes: 37 additions & 0 deletions app/_custom/collections/pokemon-abilities.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import type { CollectionConfig } from "payload/types";

import { isStaff } from "../../db/collections/users/users.access";

export const PokemonAbilities: CollectionConfig = {
slug: "pokemon-abilities",
labels: { singular: "pokemon-ability", plural: "pokemon-abilities" },
admin: {
group: "Custom",
useAsTitle: "name",
},
access: {
create: isStaff,
read: () => true,
update: isStaff,
delete: isStaff,
},
fields: [
{
name: "id",
type: "text",
},
{
name: "name",
type: "text",
},
{
name: "desc",
type: "text",
},
{
name: "checksum",
type: "text",
required: true,
},
],
};
60 changes: 60 additions & 0 deletions app/_custom/collections/pokemon-attacks.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import type { CollectionConfig } from "payload/types";

import { isStaff } from "../../db/collections/users/users.access";

export const PokemonAttacks: CollectionConfig = {
slug: "pokemon-attacks",
labels: { singular: "pokemon-attack", plural: "pokemon-attacks" },
admin: {
group: "Custom",
useAsTitle: "name",
},
access: {
create: isStaff,
read: () => true,
update: isStaff,
delete: isStaff,
},
fields: [
{
name: "id",
type: "text",
},
{
name: "name",
type: "text",
},
{
name: "desc",
type: "text",
},
{
name: "is_damaging",
type: "checkbox",
},
{
name: "damage",
type: "number",
},
{
name: "cost",
type: "array",
fields: [
{
name: "type",
type: "relationship",
relationTo: "pokemon-types",
},
{
name: "amount",
type: "number",
},
],
},
{
name: "checksum",
type: "text",
required: true,
},
],
};
84 changes: 84 additions & 0 deletions app/_custom/collections/pokemon-cards.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
import type { CollectionConfig } from "payload/types";

import { isStaff } from "../../db/collections/users/users.access";

export const PokemonCards: CollectionConfig = {
slug: "pokemon-cards",
labels: { singular: "pokemon-card", plural: "pokemon-cards" },
admin: {
group: "Custom",
useAsTitle: "name",
},
access: {
create: isStaff,
read: () => true,
update: isStaff,
delete: isStaff,
},
fields: [
{
name: "id",
type: "text",
},
{
name: "slug",
type: "text",
},
{
name: "name",
type: "text",
},
{
name: "desc",
type: "text"
},
{
name: "rarity",
type: "relationship",
relationTo: "rarities",
},
{
name: "hp",
type: "number",
},
{
name: "type",
relationTo: "pokemon-types",
type: "relationship",
},
{
name: "weakness_type",
relationTo: "pokemon-types",
type: "relationship",
},
{
name: "retreat_cost",
type: "number",
},
{
name: "is_ex",
type: "checkbox",
},
{
name: "attacks",
type: "relationship",
relationTo: "pokemon-attacks",
},
{
name: "abilities",
type: "relationship",
relationTo: "pokemon-abilities",
},
{
name: "illustrators",
type: "relationship",
relationTo: "illustrators",
hasMany: true,
},
{
name: "checksum",
type: "text",
required: true,
},
],
};
33 changes: 33 additions & 0 deletions app/_custom/collections/pokemon-types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import type { CollectionConfig } from "payload/types";

import { isStaff } from "../../db/collections/users/users.access";

export const PokemonTypes: CollectionConfig = {
slug: "pokemon-types",
labels: { singular: "pokemon-type", plural: "pokemon-types" },
admin: {
group: "Custom",
useAsTitle: "name",
},
access: {
create: isStaff,
read: () => true,
update: isStaff,
delete: isStaff,
},
fields: [
{
name: "id",
type: "text",
},
{
name: "name",
type: "text",
},
{
name: "checksum",
type: "text",
required: true,
},
],
};
33 changes: 33 additions & 0 deletions app/_custom/collections/rarities.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import type { CollectionConfig } from "payload/types";

import { isStaff } from "../../db/collections/users/users.access";

export const Rarities: CollectionConfig = {
slug: "rarities",
labels: { singular: "rarity", plural: "rarities" },
admin: {
group: "Custom",
useAsTitle: "name",
},
access: {
create: isStaff,
read: () => true,
update: isStaff,
delete: isStaff,
},
fields: [
{
name: "id",
type: "text",
},
{
name: "name",
type: "text",
},
{
name: "checksum",
type: "text",
required: true,
},
],
};
33 changes: 33 additions & 0 deletions app/_custom/collections/trainer-card-types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import type { CollectionConfig } from "payload/types";

import { isStaff } from "../../db/collections/users/users.access";

export const TrainerCardTypes: CollectionConfig = {
slug: "trainer-card-types",
labels: { singular: "trainer-card-type", plural: "trainer-card-types" },
admin: {
group: "Custom",
useAsTitle: "name",
},
access: {
create: isStaff,
read: () => true,
update: isStaff,
delete: isStaff,
},
fields: [
{
name: "id",
type: "text",
},
{
name: "name",
type: "text",
},
{
name: "checksum",
type: "text",
required: true,
},
],
};
Loading

0 comments on commit e52a829

Please sign in to comment.