Skip to content

Commit

Permalink
Merge branch 'bugfixes'
Browse files Browse the repository at this point in the history
  • Loading branch information
gregory-buffard committed Dec 5, 2024
2 parents f1cfbd5 + 77f5c12 commit 708e384
Show file tree
Hide file tree
Showing 10 changed files with 146 additions and 38 deletions.
1 change: 1 addition & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ jobs:
# WEB
echo "NEXT_PUBLIC_ADMIN_BASE_URI=http://admin:3000" >> .env
echo "AUTH_TOKEN=${{secrets.AUTH_TOKEN}}" >> .env
# ADMIN
echo "PAYLOAD_DATABASE_URI=mongodb://${{secrets.MONGO_USER}}:${{secrets.MONGO_PASS}}@mongo:27017" >> .env
Expand Down
4 changes: 2 additions & 2 deletions admin/src/payload/collections/Yachts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ export const Yachts: CollectionConfig = {
},
},
},
hooks: {
/*hooks: {
afterChange: [
({ doc, req, previousDoc, operation }) =>
generateBrochureHook({ doc, req, previousDoc, operation, collection: 'yachts' }),
],
afterDelete: [({ doc, req }) => deleteBrochureHook({ doc, req })],
},
},*/
versions: false,
access: {
read: anyone,
Expand Down
13 changes: 11 additions & 2 deletions admin/src/payload/collections/shared/YachtAndCharterFields.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { Field } from 'payload/types'
import BrochureComponent from './brochureComponent'
import BulkUpload from '../../components/bulkUpload'
import { anyone } from '../../access/anyone'

export const yachtsAndCharterCommonFields = (type: 'charter' | 'yacht'): Field[] => [
{
Expand Down Expand Up @@ -385,7 +386,11 @@ export const yachtsAndCharterCommonFields = (type: 'charter' | 'yacht'): Field[]
name: 'featured',
type: 'upload',
relationTo: 'media',
required: true,
validate: (value, options) =>
options.operation === 'create' &&
value.length === 0 &&
'At least 1 gallery photo is required',
/*required: true,*/
},
{
type: 'ui',
Expand All @@ -408,7 +413,11 @@ export const yachtsAndCharterCommonFields = (type: 'charter' | 'yacht'): Field[]
name: 'image',
type: 'upload',
relationTo: 'media',
required: true,
validate: (value, options) =>
options.operation === 'create' &&
value.length === 0 &&
'At least 1 gallery photo is required',
/*required: true,*/
},
],
},
Expand Down
42 changes: 24 additions & 18 deletions admin/src/payload/generated-schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -7057,11 +7057,13 @@ enum Yacht_etiquette_Input {
input Yacht_photos__featured_operator {
equals: String
not_equals: String
exists: Boolean
}

input Yacht_photos__gallery__image_operator {
equals: String
not_equals: String
exists: Boolean
}

input Yacht_photos__gallery__id_operator {
Expand Down Expand Up @@ -9642,11 +9644,13 @@ enum Charter_etiquette_Input {
input Charter_photos__featured_operator {
equals: String
not_equals: String
exists: Boolean
}

input Charter_photos__gallery__image_operator {
equals: String
not_equals: String
exists: Boolean
}

input Charter_photos__gallery__id_operator {
Expand Down Expand Up @@ -18354,11 +18358,13 @@ enum NewConstruction_etiquette_Input {
input NewConstruction_photos__featured_operator {
equals: String
not_equals: String
exists: Boolean
}

input NewConstruction_photos__gallery__image_operator {
equals: String
not_equals: String
exists: Boolean
}

input NewConstruction_photos__gallery__id_operator {
Expand Down Expand Up @@ -33826,7 +33832,7 @@ input mutationYachtInput {
keyFeatures: [Yacht_keyFeatures_MutationInput]
customKeyFeatures: [String]
etiquette: Yacht_etiquette_MutationInput
photos: mutationYacht_PhotosInput!
photos: mutationYacht_PhotosInput
description: String
brochure: String
clicks: Float
Expand Down Expand Up @@ -33867,12 +33873,12 @@ enum Yacht_etiquette_MutationInput {
}

input mutationYacht_PhotosInput {
featured: String!
featured: String
gallery: [mutationYacht_Photos_GalleryInput]
}

input mutationYacht_Photos_GalleryInput {
image: String!
image: String
id: String
}

Expand Down Expand Up @@ -33912,7 +33918,7 @@ input mutationYachtUpdateInput {
keyFeatures: [YachtUpdate_keyFeatures_MutationInput]
customKeyFeatures: [String]
etiquette: YachtUpdate_etiquette_MutationInput
photos: mutationYachtUpdate_PhotosInput!
photos: mutationYachtUpdate_PhotosInput
description: String
brochure: String
clicks: Float
Expand Down Expand Up @@ -33953,12 +33959,12 @@ enum YachtUpdate_etiquette_MutationInput {
}

input mutationYachtUpdate_PhotosInput {
featured: String!
featured: String
gallery: [mutationYachtUpdate_Photos_GalleryInput]
}

input mutationYachtUpdate_Photos_GalleryInput {
image: String!
image: String
id: String
}

Expand Down Expand Up @@ -33998,7 +34004,7 @@ input mutationCharterInput {
keyFeatures: [Charter_keyFeatures_MutationInput]
customKeyFeatures: [String]
etiquette: Charter_etiquette_MutationInput
photos: mutationCharter_PhotosInput!
photos: mutationCharter_PhotosInput
description: String
brochure: String
clicks: Float
Expand Down Expand Up @@ -34045,12 +34051,12 @@ enum Charter_etiquette_MutationInput {
}

input mutationCharter_PhotosInput {
featured: String!
featured: String
gallery: [mutationCharter_Photos_GalleryInput]
}

input mutationCharter_Photos_GalleryInput {
image: String!
image: String
id: String
}

Expand Down Expand Up @@ -34098,7 +34104,7 @@ input mutationCharterUpdateInput {
keyFeatures: [CharterUpdate_keyFeatures_MutationInput]
customKeyFeatures: [String]
etiquette: CharterUpdate_etiquette_MutationInput
photos: mutationCharterUpdate_PhotosInput!
photos: mutationCharterUpdate_PhotosInput
description: String
brochure: String
clicks: Float
Expand Down Expand Up @@ -34145,12 +34151,12 @@ enum CharterUpdate_etiquette_MutationInput {
}

input mutationCharterUpdate_PhotosInput {
featured: String!
featured: String
gallery: [mutationCharterUpdate_Photos_GalleryInput]
}

input mutationCharterUpdate_Photos_GalleryInput {
image: String!
image: String
id: String
}

Expand Down Expand Up @@ -34427,7 +34433,7 @@ input mutationNewConstructionInput {
keyFeatures: [NewConstruction_keyFeatures_MutationInput]
customKeyFeatures: [String]
etiquette: NewConstruction_etiquette_MutationInput
photos: mutationNewConstruction_PhotosInput!
photos: mutationNewConstruction_PhotosInput
description: String
brochure: String
clicks: Float
Expand Down Expand Up @@ -34468,12 +34474,12 @@ enum NewConstruction_etiquette_MutationInput {
}

input mutationNewConstruction_PhotosInput {
featured: String!
featured: String
gallery: [mutationNewConstruction_Photos_GalleryInput]
}

input mutationNewConstruction_Photos_GalleryInput {
image: String!
image: String
id: String
}

Expand Down Expand Up @@ -34514,7 +34520,7 @@ input mutationNewConstructionUpdateInput {
keyFeatures: [NewConstructionUpdate_keyFeatures_MutationInput]
customKeyFeatures: [String]
etiquette: NewConstructionUpdate_etiquette_MutationInput
photos: mutationNewConstructionUpdate_PhotosInput!
photos: mutationNewConstructionUpdate_PhotosInput
description: String
brochure: String
clicks: Float
Expand Down Expand Up @@ -34555,12 +34561,12 @@ enum NewConstructionUpdate_etiquette_MutationInput {
}

input mutationNewConstructionUpdate_PhotosInput {
featured: String!
featured: String
gallery: [mutationNewConstructionUpdate_Photos_GalleryInput]
}

input mutationNewConstructionUpdate_Photos_GalleryInput {
image: String!
image: String
id: String
}

Expand Down
18 changes: 9 additions & 9 deletions admin/src/payload/payload-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1053,11 +1053,11 @@ export interface Yacht {
| null;
customKeyFeatures?: string[] | null;
etiquette?: ('new' | 'exclusive' | 'sold') | null;
photos: {
featured: string | Media;
photos?: {
featured?: string | Media | null;
gallery?:
| {
image: string | Media;
image?: string | Media | null;
id?: string | null;
}[]
| null;
Expand Down Expand Up @@ -1133,11 +1133,11 @@ export interface Charter {
| null;
customKeyFeatures?: string[] | null;
etiquette?: ('new' | 'exclusive' | 'sold') | null;
photos: {
featured: string | Media;
photos?: {
featured?: string | Media | null;
gallery?:
| {
image: string | Media;
image?: string | Media | null;
id?: string | null;
}[]
| null;
Expand Down Expand Up @@ -1414,11 +1414,11 @@ export interface NewConstruction {
| null;
customKeyFeatures?: string[] | null;
etiquette?: ('new' | 'exclusive' | 'sold') | null;
photos: {
featured: string | Media;
photos?: {
featured?: string | Media | null;
gallery?:
| {
image: string | Media;
image?: string | Media | null;
id?: string | null;
}[]
| null;
Expand Down
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ services:
- MAILCHIMP_SERVER=${MAILCHIMP_SERVER}
- GOOGLE_ANALYTICS_ID=${GOOGLE_ANALYTICS_ID}
- RESEND_API_KEY=${RESEND_API_KEY}
- AUTH_TOKEN=${AUTH_TOKEN}
ports:
- "3000:3000"
depends_on:
Expand Down
75 changes: 74 additions & 1 deletion web/actions/yachts.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use server";

import { getClient } from "@/apollo";
import { gql } from "@apollo/client";
import { ApolloQueryResult, gql } from "@apollo/client";
import { IFeatured, IFeatured as SFeatured } from "@/types/sale";
import IYacht, { ICharter, INewConstruction, ISale } from "@/types/yacht";
import { IDestination } from "@/types/destination";
Expand Down Expand Up @@ -1205,3 +1205,76 @@ export const brochurize = async ({

return Buffer.from(await mergedPdf.save()).toString("base64");
};

export const click = async ({
id,
type,
}: {
id: string;
type: "sales" | "charters" | "new-constructions";
}) => {
const client = getClient(),
{ data } = await client.query({
query:
type === "sales"
? gql`
query Yacht($id: String!) {
Yacht(id: $id) {
clicks
}
}
`
: type === "charters"
? gql`
query Charter($id: String!) {
Charter(id: $id) {
clicks
}
}
`
: gql`
query NewConstruction($id: String!) {
NewConstruction(id: $id) {
clicks
}
}
`,
variables: { id },
});

await client.mutate({
mutation:
type === "sales"
? gql`
mutation UpdateYacht($id: String!, $count: Float!) {
updateYacht(id: $id, data: { clicks: $count }) {
clicks
}
}
`
: type === "charters"
? gql`
mutation UpdateCharter($id: String!, $count: Float!) {
updateCharter(id: $id, data: { clicks: $count }) {
clicks
}
}
`
: gql`
mutation UpdateNewConstruction($id: String!, $count: Float!) {
updateNewConstruction(id: $id, data: { clicks: $count }) {
clicks
}
}
`,
variables: {
id,
count:
type === "sales"
? data.Yacht.clicks + 1
: type === "charters"
? data.Charter.clicks + 1
: data.NewConstruction.clicks + 1,
},
});
};
Loading

0 comments on commit 708e384

Please sign in to comment.