Skip to content

Commit

Permalink
feat: use payload REST API to import coupons
Browse files Browse the repository at this point in the history
  • Loading branch information
ClementNumericite committed Jan 26, 2024
1 parent c1f6c23 commit a9f41a7
Show file tree
Hide file tree
Showing 6 changed files with 1,465 additions and 293 deletions.
97 changes: 48 additions & 49 deletions webapp/src/payload/collections/Coupon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,56 +3,55 @@ import type { Props } from "payload/components/views/List";
import { type CollectionConfig } from "payload/types";

const ImportCoupons = dynamic<Props>(
() => import("../components/ImportCoupons"),
{
ssr: false,
}
() => import("../components/ImportCoupons"),
{
ssr: false,
}
);

export const Coupons: CollectionConfig = {
slug: "coupons",
labels: {
singular: "Bon de réduction",
plural: "Bons de réduction",
},
fields: [
{
name: "code",
type: "text",
label: "Code",
required: true,
unique: true,
},
{
name: "status",
type: "select",
label: "Statut",
options: [
{ label: "Disponible", value: "available" },
{ label: "Archivé", value: "archived" },
],
defaultValue: "available",
required: true,
},
{
name: "user",
type: "relationship",
label: "Utilisateur",
relationTo: "users",
hasMany: false,
},
{
name: "offer",
type: "relationship",
label: "Offre",
relationTo: "offers",
hasMany: false,
required: true,
},
],
admin: {
components: {
BeforeListTable: [ImportCoupons],
},
},
slug: "coupons",
labels: {
singular: "Bon de réduction",
plural: "Bons de réduction",
},
fields: [
{
name: "code",
type: "text",
label: "Code",
required: true
},
{
name: "status",
type: "select",
label: "Statut",
options: [
{ label: "Disponible", value: "available" },
{ label: "Archivé", value: "archived" },
],
defaultValue: "available",
required: true,
},
{
name: "user",
type: "relationship",
label: "Utilisateur",
relationTo: "users",
hasMany: false,
},
{
name: "offer",
type: "relationship",
label: "Offre",
relationTo: "offers",
hasMany: false,
required: true,
},
],
admin: {
components: {
BeforeListTable: [ImportCoupons],
},
},
};
Loading

0 comments on commit a9f41a7

Please sign in to comment.