Skip to content

Commit

Permalink
feat: add export campaign button
Browse files Browse the repository at this point in the history
  • Loading branch information
baptadn committed Jan 16, 2025
1 parent 7ad1ecd commit 50a9597
Show file tree
Hide file tree
Showing 14 changed files with 1,162 additions and 218 deletions.
84 changes: 67 additions & 17 deletions back/api/application/documentation/1.0.0/application.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@
}
},
"summary": "",
"tags": ["Application"],
"tags": [
"Application"
],
"parameters": []
}
},
Expand Down Expand Up @@ -105,7 +107,9 @@
}
},
"summary": "",
"tags": ["Application"],
"tags": [
"Application"
],
"parameters": [
{
"name": "_limit",
Expand Down Expand Up @@ -291,7 +295,9 @@
}
},
"summary": "",
"tags": ["Application"],
"tags": [
"Application"
],
"requestBody": {
"description": "",
"required": true,
Expand Down Expand Up @@ -356,7 +362,9 @@
}
},
"summary": "",
"tags": ["Application"],
"tags": [
"Application"
],
"parameters": []
}
},
Expand Down Expand Up @@ -407,7 +415,9 @@
}
},
"summary": "",
"tags": ["Application"],
"tags": [
"Application"
],
"parameters": [
{
"name": "id",
Expand Down Expand Up @@ -467,7 +477,9 @@
}
},
"summary": "",
"tags": ["Application"],
"tags": [
"Application"
],
"requestBody": {
"description": "",
"required": true,
Expand Down Expand Up @@ -539,7 +551,9 @@
}
},
"summary": "",
"tags": ["Application"],
"tags": [
"Application"
],
"parameters": [
{
"name": "id",
Expand Down Expand Up @@ -605,7 +619,9 @@
}
},
"summary": "",
"tags": ["Application"],
"tags": [
"Application"
],
"parameters": [
{
"name": "campaignId",
Expand All @@ -624,20 +640,32 @@
"components": {
"schemas": {
"Application": {
"required": ["id"],
"required": [
"id"
],
"properties": {
"id": {
"type": "string"
},
"disponibility": {
"required": ["id", "start", "end", "type", "status"],
"required": [
"id",
"start",
"end",
"type",
"status"
],
"properties": {
"id": {
"type": "string"
},
"when": {
"type": "string",
"enum": ["morning", "afternoon", "full"]
"enum": [
"morning",
"afternoon",
"full"
]
},
"start": {
"type": "string"
Expand All @@ -650,7 +678,11 @@
},
"type": {
"type": "string",
"enum": ["punctual", "day", "period"]
"enum": [
"punctual",
"day",
"period"
]
},
"status": {
"type": "string",
Expand Down Expand Up @@ -820,6 +852,9 @@
"id": {
"type": "string"
},
"button_export": {
"type": "campaign-export-link"
},
"duration": {
"type": "integer"
},
Expand Down Expand Up @@ -1023,7 +1058,10 @@
},
"type": {
"type": "string",
"enum": ["company", "place"]
"enum": [
"company",
"place"
]
},
"external_id": {
"type": "integer"
Expand Down Expand Up @@ -1176,7 +1214,11 @@
},
"danceCarpet": {
"type": "string",
"enum": ["true", "false", "possible"]
"enum": [
"true",
"false",
"possible"
]
},
"slug": {
"type": "string"
Expand Down Expand Up @@ -1215,7 +1257,11 @@
},
"status": {
"type": "string",
"enum": ["preselected", "confirmed", "validated"]
"enum": [
"preselected",
"confirmed",
"validated"
]
},
"published_at": {
"type": "string",
Expand Down Expand Up @@ -1269,7 +1315,11 @@
},
"status": {
"type": "string",
"enum": ["preselected", "confirmed", "validated"]
"enum": [
"preselected",
"confirmed",
"validated"
]
},
"published_at": {
"type": "string",
Expand All @@ -1290,4 +1340,4 @@
"name": "Application"
}
]
}
}
8 changes: 8 additions & 0 deletions back/api/campaign/config/routes.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,14 @@
"config": {
"policies": []
}
},
{
"method": "GET",
"path": "/campaigns/:id/redirect-to-export",
"handler": "campaign.redirectToExport",
"config": {
"policies": []
}
}
]
}
6 changes: 6 additions & 0 deletions back/api/campaign/controllers/campaign.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,11 @@ module.exports = {
await strapi.services.campaign.sendEspacePreselectionEmail(campaign.id)

return ctx.send({ success: true })
},
async redirectToExport(ctx) {
const campaign = await strapi.services.campaign.findOne({ id: ctx.params.id })
const all = ctx.query.all === "true"

return ctx.redirect(`${process.env.FRONT_URL}/api/pdfs/campaign/${campaign.id}${all ? "?all=true" : ""}`)
}
};
74 changes: 74 additions & 0 deletions back/api/campaign/documentation/1.0.0/campaign.json
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,74 @@
}
]
}
},
"/campaigns/{id}/redirect-to-export": {
"get": {
"deprecated": false,
"description": "",
"responses": {
"200": {
"description": "response",
"content": {
"application/json": {
"schema": {
"properties": {
"foo": {
"type": "string"
}
}
}
}
}
},
"403": {
"description": "Forbidden",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"404": {
"description": "Not found",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"default": {
"description": "unexpected error",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
}
},
"summary": "",
"tags": [
"Campaign"
],
"parameters": [
{
"name": "id",
"in": "path",
"description": "",
"deprecated": false,
"required": true,
"schema": {
"type": "string"
}
}
]
}
}
},
"components": {
Expand All @@ -598,6 +666,9 @@
"id": {
"type": "string"
},
"button_export": {
"type": "campaign-export-link"
},
"duration": {
"type": "integer"
},
Expand Down Expand Up @@ -1015,6 +1086,9 @@
"disponibilities_max"
],
"properties": {
"button_export": {
"type": "campaign-export-link"
},
"duration": {
"type": "integer"
},
Expand Down
3 changes: 3 additions & 0 deletions back/api/campaign/models/campaign.settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
"draftAndPublish": true
},
"attributes": {
"button_export": {
"type": "campaign-export-link"
},
"duration": {
"type": "integer",
"required": true,
Expand Down
3 changes: 3 additions & 0 deletions back/api/disponibility/documentation/1.0.0/disponibility.json
Original file line number Diff line number Diff line change
Expand Up @@ -1031,6 +1031,9 @@
"id": {
"type": "string"
},
"button_export": {
"type": "campaign-export-link"
},
"duration": {
"type": "integer"
},
Expand Down
Loading

0 comments on commit 50a9597

Please sign in to comment.