Skip to content

Commit 3f4baa3

Browse files
committed
Padma backend plugin major update
1 parent 35e6b8e commit 3f4baa3

File tree

8 files changed

+98
-40
lines changed

8 files changed

+98
-40
lines changed

apps/backend/config/plugins.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
export default ({ env }) => ({
22
"padma-backend": {
33
enabled: true,
4-
// resolve: "./src/plugins/padma-backend",
4+
resolve: "./src/plugins/padma-backend",
55
},
66
upload: {
77
config: {

apps/backend/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
"strapi": "strapi"
1313
},
1414
"dependencies": {
15-
"@padmadev/padma-backend": "^0.0.6-alpha.2",
1615
"@strapi/plugin-users-permissions": "5.4.0",
1716
"@strapi/provider-upload-cloudinary": "^5.4.1",
1817
"@strapi/strapi": "^5.4.0",
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
"use strict";
2+
3+
export default () => async (ctx, next) => {
4+
await next();
5+
6+
if (
7+
ctx.request.url === "/api/auth/local/register" &&
8+
ctx.response.status === 200
9+
) {
10+
// Now we can apply our logic, but we have to retrieve the user
11+
12+
const userArray = await strapi.entityService.findMany(
13+
"plugin::users-permissions.user",
14+
{
15+
filters: { email: ctx.request?.body?.email },
16+
}
17+
);
18+
19+
const user = userArray[0];
20+
21+
const roles = await strapi.entityService.findMany(
22+
"plugin::users-permissions.role",
23+
{
24+
filters: { type: "candidate" },
25+
}
26+
);
27+
28+
// Check if the role has been found
29+
if (!roles || roles?.length === 0) {
30+
// Error handling
31+
}
32+
const authorRole = roles[0];
33+
34+
// ?? Update the user role
35+
await strapi.entityService.update(
36+
"plugin::users-permissions.user",
37+
user.id,
38+
{
39+
data: {
40+
role: ctx?.request?.body?.role || authorRole?.id,
41+
confirmed: ctx?.request?.body.confirmed || false,
42+
},
43+
}
44+
);
45+
}
46+
};

apps/backend/src/plugins/padma-backend/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "@padmadev/padma-backend",
33
"description": "Padma Backend",
44
"license": "MIT",
5-
"version": "0.0.6-alpha.3",
5+
"version": "0.0.7",
66
"keywords": [
77
"strapi",
88
"strapi-plugin",

apps/backend/src/plugins/padma-backend/server/src/content-types/category/schema.json

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,24 @@
1818
"attributes": {
1919
"title": {
2020
"type": "string",
21+
"required": true,
22+
"default": "Category",
2123
"pluginOptions": {
2224
"i18n": {
2325
"localized": true
2426
}
2527
}
2628
},
29+
"slug": {
30+
"pluginOptions": {
31+
"i18n": {
32+
"localized": true
33+
}
34+
},
35+
"type": "uid",
36+
"targetField": "title",
37+
"required": true
38+
},
2739
"image": {
2840
"type": "media",
2941
"multiple": false,
@@ -41,7 +53,8 @@
4153
"localized": true
4254
}
4355
},
44-
"type": "text"
56+
"type": "text",
57+
"default": "Description here"
4558
},
4659
"link": {
4760
"type": "component",
@@ -53,14 +66,6 @@
5366
},
5467
"component": "config.link"
5568
},
56-
"slug": {
57-
"pluginOptions": {
58-
"i18n": {
59-
"localized": true
60-
}
61-
},
62-
"type": "uid"
63-
},
6469
"seo": {
6570
"type": "component",
6671
"repeatable": false,

apps/backend/src/plugins/padma-backend/server/src/content-types/post-setting/schema.json

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"description": ""
99
},
1010
"options": {
11-
"draftAndPublish": false
11+
"draftAndPublish": true
1212
},
1313
"pluginOptions": {
1414
"i18n": {
@@ -22,7 +22,8 @@
2222
"localized": true
2323
}
2424
},
25-
"type": "string"
25+
"type": "string",
26+
"default": "Post Details"
2627
},
2728
"sidebar": {
2829
"pluginOptions": {
@@ -31,7 +32,8 @@
3132
}
3233
},
3334
"type": "enumeration",
34-
"enum": ["Left Sidebar", "Right Sidebar", "Both Sidebar", "No Sidebar"]
35+
"enum": ["Left Sidebar", "Right Sidebar", "Both Sidebar", "No Sidebar"],
36+
"default": "Right Sidebar"
3537
},
3638
"blocks": {
3739
"pluginOptions": {
@@ -40,7 +42,7 @@
4042
}
4143
},
4244
"type": "dynamiczone",
43-
"components": ["shared.spacing"]
45+
"components": ["shared.spacing", "single-type.blog-details"]
4446
},
4547
"leftSidebar": {
4648
"pluginOptions": {

apps/backend/src/plugins/padma-backend/server/src/content-types/post/schema.json

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,21 @@
1010
"options": {
1111
"draftAndPublish": true
1212
},
13-
"pluginOptions": {},
13+
"pluginOptions": {
14+
"i18n": {
15+
"localized": true
16+
}
17+
},
1418
"attributes": {
1519
"title": {
16-
"type": "string"
20+
"type": "string",
21+
"required": true,
22+
"default": "Post"
1723
},
1824
"slug": {
19-
"type": "uid"
25+
"type": "uid",
26+
"targetField": "title",
27+
"required": true
2028
},
2129
"featuredImage": {
2230
"type": "media",
@@ -30,23 +38,18 @@
3038
"required": false,
3139
"allowedTypes": ["images", "files", "videos", "audios"]
3240
},
41+
"user": {
42+
"type": "relation",
43+
"relation": "oneToOne",
44+
"target": "plugin::users-permissions.user"
45+
},
3346
"excerpt": {
3447
"type": "text"
3548
},
36-
"seo": {
37-
"type": "component",
38-
"repeatable": false,
39-
"component": "shared.seo"
40-
},
4149
"description": {
4250
"type": "blocks",
4351
"required": true
4452
},
45-
"user": {
46-
"type": "relation",
47-
"relation": "oneToOne",
48-
"target": "plugin::users-permissions.user"
49-
},
5053
"short_description": {
5154
"type": "text",
5255
"required": true
@@ -56,6 +59,11 @@
5659
"relation": "manyToMany",
5760
"target": "plugin::padma-backend.category",
5861
"mappedBy": "posts"
62+
},
63+
"seo": {
64+
"type": "component",
65+
"repeatable": false,
66+
"component": "shared.seo"
5967
}
6068
}
6169
}

apps/backend/types/generated/contentTypes.d.ts

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -836,9 +836,15 @@ export interface PluginPadmaBackendPrivateLayout
836836
createdAt: Schema.Attribute.DateTime;
837837
createdBy: Schema.Attribute.Relation<'oneToOne', 'admin::user'> &
838838
Schema.Attribute.Private;
839-
header: Schema.Attribute.DynamicZone<
840-
['header.top-bar', 'header.main-menu', 'header.header-bottom']
839+
footer: Schema.Attribute.DynamicZone<
840+
['widget.menu-widget', 'widget.copyright-bar', 'widget.contact-widget']
841841
> &
842+
Schema.Attribute.SetPluginOptions<{
843+
i18n: {
844+
localized: true;
845+
};
846+
}>;
847+
header: Schema.Attribute.DynamicZone<['header.private-header']> &
842848
Schema.Attribute.Required &
843849
Schema.Attribute.SetPluginOptions<{
844850
i18n: {
@@ -854,14 +860,6 @@ export interface PluginPadmaBackendPrivateLayout
854860
updatedAt: Schema.Attribute.DateTime;
855861
updatedBy: Schema.Attribute.Relation<'oneToOne', 'admin::user'> &
856862
Schema.Attribute.Private;
857-
widget: Schema.Attribute.DynamicZone<
858-
['widget.menu-widget', 'widget.copyright-bar', 'widget.contact-widget']
859-
> &
860-
Schema.Attribute.SetPluginOptions<{
861-
i18n: {
862-
localized: true;
863-
};
864-
}>;
865863
};
866864
}
867865

@@ -1015,7 +1013,7 @@ export interface PluginPadmaBackendPublicPage
10151013
[
10161014
'block.banner',
10171015
'block.content-box',
1018-
'block.blog-card',
1016+
'block.blog-filter',
10191017
'block.breadcrumbs',
10201018
'shared.empty',
10211019
'block.category-card',

0 commit comments

Comments
 (0)