@primershop/strapi-plugin-product-actions 0.0.4 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/admin/index.js +260 -7
- package/dist/admin/index.js.map +1 -1
- package/dist/admin/index.mjs +256 -3
- package/dist/admin/index.mjs.map +1 -1
- package/dist/server/index.js +1 -4
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs +1 -1
- package/dist/server/index.mjs.map +1 -1
- package/package.json +3 -2
- package/dist/admin/components/Initializer/index.js +0 -17
- package/dist/admin/components/Initializer/index.js.map +0 -1
- package/dist/admin/components/Initializer/index.mjs +0 -15
- package/dist/admin/components/Initializer/index.mjs.map +0 -1
- package/dist/admin/components/SeriesProductActions/index.js +0 -229
- package/dist/admin/components/SeriesProductActions/index.js.map +0 -1
- package/dist/admin/components/SeriesProductActions/index.mjs +0 -227
- package/dist/admin/components/SeriesProductActions/index.mjs.map +0 -1
- package/dist/admin/pluginId.js +0 -6
- package/dist/admin/pluginId.js.map +0 -1
- package/dist/admin/pluginId.mjs +0 -4
- package/dist/admin/pluginId.mjs.map +0 -1
- package/dist/admin/src/components/Initializer/index.js +0 -13
- package/dist/admin/src/components/SeriesProductActions/index.js +0 -84
- package/dist/admin/src/index.js +0 -22
- package/dist/admin/src/pluginId.js +0 -1
- package/dist/admin/src/translations/en.js +0 -21
- package/dist/admin/src/translations/index.js +0 -1
- package/dist/admin/translations/en.js +0 -25
- package/dist/admin/translations/en.js.map +0 -1
- package/dist/admin/translations/en.mjs +0 -23
- package/dist/admin/translations/en.mjs.map +0 -1
- package/dist/server/src/bootstrap.js +0 -16
- package/dist/server/src/controllers/index.js +0 -10
- package/dist/server/src/controllers/product-series.js +0 -31
- package/dist/server/src/index.js +0 -20
- package/dist/server/src/permissions.js +0 -42
- package/dist/server/src/pluginId.js +0 -4
- package/dist/server/src/register.js +0 -14
- package/dist/server/src/routes/admin.js +0 -37
- package/dist/server/src/routes/index.js +0 -9
- package/dist/server/src/services/index.js +0 -7
- package/dist/server/src/services/product-series.js +0 -116
package/dist/admin/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../../admin/src/index.ts"],"sourcesContent":["import { Initializer } from \"./components/Initializer\";\r\nimport { SeriesProductActions } from \"./components/SeriesProductActions\";\r\nimport { PLUGIN_ID } from \"./pluginId\";\r\n\r\nimport type { PanelComponent } from \"@strapi/content-manager/strapi-admin\";\r\n\r\nconst plugin = {\r\n register(app: any) {\r\n app.registerPlugin({\r\n id: PLUGIN_ID,\r\n initializer: Initializer,\r\n isReady: false,\r\n name: PLUGIN_ID,\r\n });\r\n },\r\n\r\n bootstrap(app: any) {\r\n console.log(\"🚀 ~ bootstrap ~ app:\", app);\r\n app\r\n .getPlugin(\"content-manager\")\r\n .apis.addEditViewSidePanel((panels: any): PanelComponent[] => {\r\n return [...panels, SeriesProductActions];\r\n });\r\n },\r\n};\r\n\r\nexport default plugin;\r\n"],"names":["plugin","register","app","registerPlugin","id","PLUGIN_ID","initializer","Initializer","isReady","name","bootstrap","console","log","getPlugin","apis","addEditViewSidePanel","panels","SeriesProductActions"],"mappings":";;;;AAMA,MAAMA,MAAAA,GAAS;AACbC,IAAAA,QAAAA,CAAAA,CAASC,GAAQ,EAAA;AACfA,QAAAA,GAAAA,CAAIC,cAAc,CAAC;YACjBC,EAAAA,EAAIC,SAAAA;YACJC,WAAAA,EAAaC,WAAAA;YACbC,OAAAA,EAAS,KAAA;YACTC,IAAAA,EAAMJ;AACR,SAAA,CAAA;AACF,IAAA,CAAA;AAEAK,IAAAA,SAAAA,CAAAA,CAAUR,GAAQ,EAAA;QAChBS,OAAAA,CAAQC,GAAG,CAAC,uBAAA,EAAyBV,GAAAA,CAAAA;AACrCA,QAAAA,GAAAA,CACGW,SAAS,CAAC,iBAAA,CAAA,CACVC,IAAI,CAACC,oBAAoB,CAAC,CAACC,MAAAA,GAAAA;YAC1B,OAAO;AAAIA,gBAAAA,GAAAA,MAAAA;AAAQC,gBAAAA;AAAqB,aAAA;AAC1C,QAAA,CAAA,CAAA;AACJ,IAAA;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../../admin/src/pluginId.ts","../../admin/src/components/Initializer/index.tsx","../../admin/src/translations/en.ts","../../admin/src/components/SeriesProductActions/index.tsx","../../admin/src/index.ts"],"sourcesContent":["export const PLUGIN_ID = \"primershop-product-actions\";\r\n","import { useEffect, useRef } from \"react\";\r\n\r\nimport { PLUGIN_ID } from \"../../pluginId\";\r\n\r\n/**\r\n * @type {import('react').FC<{ setPlugin: (id: string) => void }>}\r\n */\r\nconst Initializer = ({ setPlugin }: { setPlugin: (id: string) => void }) => {\r\n const ref = useRef(setPlugin);\r\n\r\n useEffect(() => {\r\n ref.current(PLUGIN_ID);\r\n }, []);\r\n\r\n return null;\r\n};\r\n\r\nexport { Initializer };\r\n","const en: Record<string, string> = {\r\n \"plugin.name\": \"Product Series\",\r\n \"plugin.description\": \"Manage product series and their products\",\r\n \"product-series.actions.label\": \"Product Actions\",\r\n \"product-series.actions.createProducts\": \"Create Products\",\r\n \"product-series.actions.updateProducts\": \"Update Products\",\r\n \"product-series.actions.createDialogTitle\": \"Create Products from Series\",\r\n \"product-series.actions.updateDialogTitle\": \"Update All Products in Series\",\r\n \"product-series.actions.updateDialogDescription\":\r\n \"This will update all products in the series with the selected fields. Make sure to save the series first before updating the products.\",\r\n \"product-series.actions.productCount\": \"Number of Products\",\r\n \"product-series.actions.create\": \"Create\",\r\n \"product-series.actions.update\": \"Update\",\r\n \"product-series.actions.cancel\": \"Cancel\",\r\n \"product-series.actions.createSuccess\": \"Products created successfully\",\r\n \"product-series.actions.createError\": \"Failed to create products\",\r\n \"product-series.actions.updateSuccess\": \"Products updated successfully\",\r\n \"product-series.actions.updateError\": \"Failed to update products\",\r\n \"product-series.actions.selectFields\": \"Select fields to update\",\r\n \"product-series.actions.noDocumentId\":\r\n \"Save the series first before creating products\",\r\n};\r\n\r\nexport { en };\r\n","import React, { useState } from \"react\";\r\n\r\nimport {\r\n Box,\r\n Button,\r\n Typography,\r\n Dialog,\r\n NumberInput,\r\n Flex,\r\n MultiSelect,\r\n MultiSelectOption,\r\n} from \"@strapi/design-system\";\r\nimport {\r\n useFetchClient,\r\n unstable_useContentManagerContext as useContentManagerContext,\r\n} from \"@strapi/strapi/admin\";\r\n\r\nimport { en } from \"../../translations\";\r\n\r\nconst formatMessage = (arg: { id: string }): string => {\r\n return en[arg.id];\r\n};\r\n\r\nconst valuesToUpdate = [\r\n \"description\",\r\n \"shortDescription\",\r\n \"media\",\r\n \"coverImage\",\r\n \"seo\",\r\n \"totalCost\",\r\n \"wholesalePrice\",\r\n \"retailPrice\",\r\n \"category\",\r\n \"creator\",\r\n];\r\n\r\ninterface Document {\r\n documentId?: string;\r\n}\r\n\r\nconst SeriesProductActions = ({ document }: { document: Document }) => {\r\n const { model } = useContentManagerContext();\r\n const documentId = document?.documentId;\r\n const [productCount, setProductCount] = useState(1);\r\n const [isLoading, setIsLoading] = useState(false);\r\n const [fieldsToUpdate, setFieldsToUpdate] = useState<string[]>([]);\r\n const { post, put } = useFetchClient();\r\n\r\n if (model !== \"api::product-series.product-series\") return null;\r\n\r\n const handleCreateProducts = async () => {\r\n try {\r\n setIsLoading(true);\r\n const response = await post(\r\n `primershop-product-actions/create-products`,\r\n {\r\n count: productCount,\r\n id: documentId,\r\n }\r\n );\r\n\r\n if (!response.data) {\r\n throw new Error(\"Failed to create products\");\r\n }\r\n\r\n setProductCount(1);\r\n } catch (error) {\r\n console.error(\"Error creating products:\", error);\r\n } finally {\r\n setIsLoading(false);\r\n }\r\n };\r\n\r\n const handleUpdateProducts = async () => {\r\n try {\r\n setIsLoading(true);\r\n const response = await put(\r\n `/primershop-product-actions/update-products`,\r\n {\r\n seriesId: documentId,\r\n fieldsToUpdate,\r\n }\r\n );\r\n\r\n if (!response.data) {\r\n throw new Error(\"Failed to update products\");\r\n }\r\n } catch (error) {\r\n console.error(\"Error updating products:\", error);\r\n } finally {\r\n setIsLoading(false);\r\n }\r\n };\r\n return {\r\n title: \"Series Product Actions\",\r\n content: (\r\n <Box>\r\n <Box>\r\n <Typography variant=\"delta\" fontWeight=\"bold\">\r\n {formatMessage({ id: \"product-series.actions.label\" })}\r\n </Typography>\r\n <Flex wrap={\"wrap\"}>\r\n {!documentId && (\r\n <Typography\r\n display={\"block\"}\r\n marginTop={2}\r\n marginBottom={2}\r\n width=\"100%\"\r\n color=\"red\"\r\n >\r\n {formatMessage({ id: \"product-series.actions.noDocumentId\" })}\r\n </Typography>\r\n )}\r\n\r\n <Dialog.Root>\r\n <Dialog.Trigger>\r\n <Button variant=\"secondary\" disabled={isLoading || !documentId}>\r\n {formatMessage({\r\n id: \"product-series.actions.createProducts\",\r\n })}\r\n </Button>\r\n </Dialog.Trigger>\r\n <Dialog.Content>\r\n <Dialog.Body>\r\n <Box>\r\n <Typography>\r\n {formatMessage({\r\n id: \"product-series.actions.createDialogTitle\",\r\n })}\r\n </Typography>\r\n <NumberInput\r\n value={productCount}\r\n onValueChange={(value) => setProductCount(value || 1)}\r\n min={1}\r\n max={100}\r\n ></NumberInput>\r\n </Box>\r\n </Dialog.Body>\r\n <Dialog.Footer>\r\n <Dialog.Cancel>\r\n <Button fullWidth variant=\"tertiary\">\r\n Cancel\r\n </Button>\r\n </Dialog.Cancel>\r\n <Dialog.Action>\r\n <Button\r\n onClick={handleCreateProducts}\r\n variant=\"default\"\r\n loading={isLoading}\r\n >\r\n {formatMessage({ id: \"product-series.actions.create\" })}\r\n </Button>\r\n </Dialog.Action>\r\n </Dialog.Footer>\r\n </Dialog.Content>\r\n </Dialog.Root>\r\n\r\n {/* Update Products Dialog */}\r\n <Dialog.Root>\r\n <Dialog.Trigger>\r\n <Button\r\n marginLeft={2}\r\n variant=\"secondary\"\r\n disabled={isLoading || !documentId}\r\n >\r\n {formatMessage({\r\n id: \"product-series.actions.updateProducts\",\r\n })}\r\n </Button>\r\n </Dialog.Trigger>\r\n <Dialog.Content>\r\n <Dialog.Body\r\n display={\"flex\"}\r\n direction={\"column\"}\r\n gap={2}\r\n justifyContent={\"center\"}\r\n alignItems={\"center\"}\r\n width={\"100%\"}\r\n >\r\n <Typography variant=\"delta\" fontWeight=\"bold\">\r\n {formatMessage({\r\n id: \"product-series.actions.updateDialogTitle\",\r\n })}\r\n </Typography>\r\n <Typography>\r\n {formatMessage({\r\n id: \"product-series.actions.updateDialogDescription\",\r\n })}\r\n </Typography>\r\n <MultiSelect\r\n withTags={true}\r\n value={fieldsToUpdate}\r\n onClear={() => setFieldsToUpdate([])}\r\n onChange={(value: string[]) => setFieldsToUpdate(value)}\r\n required={true}\r\n placeholder={formatMessage({\r\n id: \"product-series.actions.selectFields\",\r\n })}\r\n >\r\n {valuesToUpdate.map((field) => (\r\n <MultiSelectOption key={field} value={field}>\r\n {field}\r\n </MultiSelectOption>\r\n ))}\r\n </MultiSelect>\r\n </Dialog.Body>\r\n <Dialog.Footer>\r\n <Dialog.Cancel>\r\n <Button fullWidth variant=\"tertiary\">\r\n Cancel\r\n </Button>\r\n </Dialog.Cancel>\r\n <Dialog.Action>\r\n <Button\r\n onClick={handleUpdateProducts}\r\n variant=\"default\"\r\n loading={isLoading}\r\n >\r\n {formatMessage({ id: \"product-series.actions.update\" })}\r\n </Button>\r\n </Dialog.Action>\r\n </Dialog.Footer>\r\n </Dialog.Content>\r\n </Dialog.Root>\r\n </Flex>\r\n </Box>\r\n </Box>\r\n ),\r\n };\r\n};\r\n\r\nexport { SeriesProductActions };\r\n","import { Initializer } from \"./components/Initializer\";\r\nimport { SeriesProductActions } from \"./components/SeriesProductActions\";\r\nimport { PLUGIN_ID } from \"./pluginId\";\r\n\r\nimport type { PanelComponent } from \"@strapi/content-manager/strapi-admin\";\r\n\r\nconst plugin = {\r\n register(app: any) {\r\n app.registerPlugin({\r\n id: PLUGIN_ID,\r\n initializer: Initializer,\r\n isReady: false,\r\n name: PLUGIN_ID,\r\n });\r\n },\r\n\r\n bootstrap(app: any) {\r\n console.log(\"🚀 ~ bootstrap ~ app:\", app);\r\n app\r\n .getPlugin(\"content-manager\")\r\n .apis.addEditViewSidePanel((panels: any): PanelComponent[] => {\r\n return [...panels, SeriesProductActions];\r\n });\r\n },\r\n};\r\n\r\nexport default plugin;\r\n"],"names":["PLUGIN_ID","Initializer","setPlugin","ref","useRef","useEffect","current","en","formatMessage","arg","id","valuesToUpdate","SeriesProductActions","document","model","useContentManagerContext","documentId","productCount","setProductCount","useState","isLoading","setIsLoading","fieldsToUpdate","setFieldsToUpdate","post","put","useFetchClient","handleCreateProducts","response","count","data","Error","error","console","handleUpdateProducts","seriesId","title","content","_jsx","Box","_jsxs","Typography","variant","fontWeight","Flex","wrap","display","marginTop","marginBottom","width","color","Dialog","Root","Trigger","Button","disabled","Content","Body","NumberInput","value","onValueChange","min","max","Footer","Cancel","fullWidth","Action","onClick","loading","marginLeft","direction","gap","justifyContent","alignItems","MultiSelect","withTags","onClear","onChange","required","placeholder","map","field","MultiSelectOption","plugin","register","app","registerPlugin","initializer","isReady","name","bootstrap","log","getPlugin","apis","addEditViewSidePanel","panels"],"mappings":";;;;;AAAO,MAAMA,YAAY,4BAAA;;ACIzB;;AAEC,IACD,MAAMC,WAAAA,GAAc,CAAC,EAAEC,SAAS,EAAuC,GAAA;AACrE,IAAA,MAAMC,MAAMC,MAAAA,CAAOF,SAAAA,CAAAA;IAEnBG,SAAAA,CAAU,IAAA;AACRF,QAAAA,GAAAA,CAAIG,OAAO,CAACN,SAAAA,CAAAA;AACd,IAAA,CAAA,EAAG,EAAE,CAAA;IAEL,OAAO,IAAA;AACT,CAAA;;ACfA,MAAMO,EAAAA,GAA6B;IACjC,aAAA,EAAe,gBAAA;IACf,oBAAA,EAAsB,0CAAA;IACtB,8BAAA,EAAgC,iBAAA;IAChC,uCAAA,EAAyC,iBAAA;IACzC,uCAAA,EAAyC,iBAAA;IACzC,0CAAA,EAA4C,6BAAA;IAC5C,0CAAA,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YACTC,IAAAA,EAAMzF;AACR,SAAA,CAAA;AACF,IAAA,CAAA;AAEA0F,IAAAA,SAAAA,CAAAA,CAAUL,GAAQ,EAAA;QAChBpD,OAAAA,CAAQ0D,GAAG,CAAC,uBAAA,EAAyBN,GAAAA,CAAAA;AACrCA,QAAAA,GAAAA,CACGO,SAAS,CAAC,iBAAA,CAAA,CACVC,IAAI,CAACC,oBAAoB,CAAC,CAACC,MAAAA,GAAAA;YAC1B,OAAO;AAAIA,gBAAAA,GAAAA,MAAAA;AAAQnF,gBAAAA;AAAqB,aAAA;AAC1C,QAAA,CAAA,CAAA;AACJ,IAAA;AACF;;;;"}
|
package/dist/server/index.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
3
|
var index$2 = require('./controllers/index.js');
|
|
6
4
|
var index$1 = require('./routes/index.js');
|
|
7
5
|
var index = require('./services/index.js');
|
|
@@ -19,6 +17,5 @@ const plugin = ()=>{
|
|
|
19
17
|
};
|
|
20
18
|
};
|
|
21
19
|
|
|
22
|
-
exports
|
|
23
|
-
exports.plugin = plugin;
|
|
20
|
+
module.exports = plugin;
|
|
24
21
|
//# sourceMappingURL=index.js.map
|
package/dist/server/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../server/src/index.ts"],"sourcesContent":["import { controllers } from \"./controllers\";\r\nimport { routes } from \"./routes\";\r\nimport { services } from \"./services\";\r\nimport { register } from \"./register\";\r\nimport { bootstrap } from \"./bootstrap\";\r\n\r\
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../server/src/index.ts"],"sourcesContent":["import { controllers } from \"./controllers\";\r\nimport { routes } from \"./routes\";\r\nimport { services } from \"./services\";\r\nimport { register } from \"./register\";\r\nimport { bootstrap } from \"./bootstrap\";\r\n\r\nconst plugin = () => {\r\n return {\r\n register,\r\n\r\n controllers,\r\n routes,\r\n services,\r\n middlewares: {},\r\n bootstrap,\r\n };\r\n};\r\n\r\nexport default plugin;\r\n"],"names":["plugin","register","controllers","routes","services","middlewares","bootstrap"],"mappings":";;;;;;;;AAMA,MAAMA,MAAAA,GAAS,IAAA;IACb,OAAO;AACLC,kBAAAA,iBAAAA;AAEAC,qBAAAA,mBAAAA;AACAC,gBAAAA,cAAAA;AACAC,kBAAAA,cAAAA;AACAC,QAAAA,WAAAA,EAAa,EAAC;AACdC,mBAAAA;AACF,KAAA;AACF;;;;"}
|
package/dist/server/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../../server/src/index.ts"],"sourcesContent":["import { controllers } from \"./controllers\";\r\nimport { routes } from \"./routes\";\r\nimport { services } from \"./services\";\r\nimport { register } from \"./register\";\r\nimport { bootstrap } from \"./bootstrap\";\r\n\r\
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../../server/src/index.ts"],"sourcesContent":["import { controllers } from \"./controllers\";\r\nimport { routes } from \"./routes\";\r\nimport { services } from \"./services\";\r\nimport { register } from \"./register\";\r\nimport { bootstrap } from \"./bootstrap\";\r\n\r\nconst plugin = () => {\r\n return {\r\n register,\r\n\r\n controllers,\r\n routes,\r\n services,\r\n middlewares: {},\r\n bootstrap,\r\n };\r\n};\r\n\r\nexport default plugin;\r\n"],"names":["plugin","register","controllers","routes","services","middlewares","bootstrap"],"mappings":";;;;;;AAMA,MAAMA,MAAAA,GAAS,IAAA;IACb,OAAO;AACLC,QAAAA,QAAAA;AAEAC,QAAAA,WAAAA;AACAC,QAAAA,MAAAA;AACAC,QAAAA,QAAAA;AACAC,QAAAA,WAAAA,EAAa,EAAC;AACdC,QAAAA;AACF,KAAA;AACF;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@primershop/strapi-plugin-product-actions",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.7",
|
|
4
4
|
"description": "Enables product actions for Strapi",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./strapi-admin": {
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"dist/"
|
|
20
20
|
],
|
|
21
21
|
"scripts": {
|
|
22
|
-
"build": "npm-run-all clean --parallel build:code
|
|
22
|
+
"build": "npm-run-all clean --parallel build:code",
|
|
23
23
|
"build:code": "rollup -c",
|
|
24
24
|
"build:types": "run-p build:types:server build:types:admin",
|
|
25
25
|
"build:types:server": "tsc -p server/tsconfig.build.json ",
|
|
@@ -35,6 +35,7 @@
|
|
|
35
35
|
"keywords": [
|
|
36
36
|
"strapi",
|
|
37
37
|
"plugin",
|
|
38
|
+
"strapi-plugin",
|
|
38
39
|
"product",
|
|
39
40
|
"actions"
|
|
40
41
|
],
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var react = require('react');
|
|
4
|
-
var pluginId = require('../../pluginId.js');
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* @type {import('react').FC<{ setPlugin: (id: string) => void }>}
|
|
8
|
-
*/ const Initializer = ({ setPlugin })=>{
|
|
9
|
-
const ref = react.useRef(setPlugin);
|
|
10
|
-
react.useEffect(()=>{
|
|
11
|
-
ref.current(pluginId.PLUGIN_ID);
|
|
12
|
-
}, []);
|
|
13
|
-
return null;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
exports.Initializer = Initializer;
|
|
17
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../admin/src/components/Initializer/index.tsx"],"sourcesContent":["import { useEffect, useRef } from \"react\";\r\n\r\nimport { PLUGIN_ID } from \"../../pluginId\";\r\n\r\n/**\r\n * @type {import('react').FC<{ setPlugin: (id: string) => void }>}\r\n */\r\nconst Initializer = ({ setPlugin }: { setPlugin: (id: string) => void }) => {\r\n const ref = useRef(setPlugin);\r\n\r\n useEffect(() => {\r\n ref.current(PLUGIN_ID);\r\n }, []);\r\n\r\n return null;\r\n};\r\n\r\nexport { Initializer };\r\n"],"names":["Initializer","setPlugin","ref","useRef","useEffect","current","PLUGIN_ID"],"mappings":";;;;;AAIA;;AAEC,IACD,MAAMA,WAAAA,GAAc,CAAC,EAAEC,SAAS,EAAuC,GAAA;AACrE,IAAA,MAAMC,MAAMC,YAAAA,CAAOF,SAAAA,CAAAA;IAEnBG,eAAAA,CAAU,IAAA;AACRF,QAAAA,GAAAA,CAAIG,OAAO,CAACC,kBAAAA,CAAAA;AACd,IAAA,CAAA,EAAG,EAAE,CAAA;IAEL,OAAO,IAAA;AACT;;;;"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { useRef, useEffect } from 'react';
|
|
2
|
-
import { PLUGIN_ID } from '../../pluginId.mjs';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* @type {import('react').FC<{ setPlugin: (id: string) => void }>}
|
|
6
|
-
*/ const Initializer = ({ setPlugin })=>{
|
|
7
|
-
const ref = useRef(setPlugin);
|
|
8
|
-
useEffect(()=>{
|
|
9
|
-
ref.current(PLUGIN_ID);
|
|
10
|
-
}, []);
|
|
11
|
-
return null;
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
export { Initializer };
|
|
15
|
-
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../../../../admin/src/components/Initializer/index.tsx"],"sourcesContent":["import { useEffect, useRef } from \"react\";\r\n\r\nimport { PLUGIN_ID } from \"../../pluginId\";\r\n\r\n/**\r\n * @type {import('react').FC<{ setPlugin: (id: string) => void }>}\r\n */\r\nconst Initializer = ({ setPlugin }: { setPlugin: (id: string) => void }) => {\r\n const ref = useRef(setPlugin);\r\n\r\n useEffect(() => {\r\n ref.current(PLUGIN_ID);\r\n }, []);\r\n\r\n return null;\r\n};\r\n\r\nexport { Initializer };\r\n"],"names":["Initializer","setPlugin","ref","useRef","useEffect","current","PLUGIN_ID"],"mappings":";;;AAIA;;AAEC,IACD,MAAMA,WAAAA,GAAc,CAAC,EAAEC,SAAS,EAAuC,GAAA;AACrE,IAAA,MAAMC,MAAMC,MAAAA,CAAOF,SAAAA,CAAAA;IAEnBG,SAAAA,CAAU,IAAA;AACRF,QAAAA,GAAAA,CAAIG,OAAO,CAACC,SAAAA,CAAAA;AACd,IAAA,CAAA,EAAG,EAAE,CAAA;IAEL,OAAO,IAAA;AACT;;;;"}
|
|
@@ -1,229 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
-
var react = require('react');
|
|
5
|
-
var designSystem = require('@strapi/design-system');
|
|
6
|
-
var admin = require('@strapi/strapi/admin');
|
|
7
|
-
var en = require('../../translations/en.js');
|
|
8
|
-
|
|
9
|
-
const formatMessage = (arg)=>{
|
|
10
|
-
return en.en[arg.id];
|
|
11
|
-
};
|
|
12
|
-
const valuesToUpdate = [
|
|
13
|
-
"description",
|
|
14
|
-
"shortDescription",
|
|
15
|
-
"media",
|
|
16
|
-
"coverImage",
|
|
17
|
-
"seo",
|
|
18
|
-
"totalCost",
|
|
19
|
-
"wholesalePrice",
|
|
20
|
-
"retailPrice",
|
|
21
|
-
"category",
|
|
22
|
-
"creator"
|
|
23
|
-
];
|
|
24
|
-
const SeriesProductActions = ({ document })=>{
|
|
25
|
-
const { model } = admin.unstable_useContentManagerContext();
|
|
26
|
-
const documentId = document?.documentId;
|
|
27
|
-
const [productCount, setProductCount] = react.useState(1);
|
|
28
|
-
const [isLoading, setIsLoading] = react.useState(false);
|
|
29
|
-
const [fieldsToUpdate, setFieldsToUpdate] = react.useState([]);
|
|
30
|
-
const { post, put } = admin.useFetchClient();
|
|
31
|
-
if (model !== "api::product-series.product-series") return null;
|
|
32
|
-
const handleCreateProducts = async ()=>{
|
|
33
|
-
try {
|
|
34
|
-
setIsLoading(true);
|
|
35
|
-
const response = await post(`primershop-product-actions/create-products`, {
|
|
36
|
-
count: productCount,
|
|
37
|
-
id: documentId
|
|
38
|
-
});
|
|
39
|
-
if (!response.data) {
|
|
40
|
-
throw new Error("Failed to create products");
|
|
41
|
-
}
|
|
42
|
-
setProductCount(1);
|
|
43
|
-
} catch (error) {
|
|
44
|
-
console.error("Error creating products:", error);
|
|
45
|
-
} finally{
|
|
46
|
-
setIsLoading(false);
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
const handleUpdateProducts = async ()=>{
|
|
50
|
-
try {
|
|
51
|
-
setIsLoading(true);
|
|
52
|
-
const response = await put(`/primershop-product-actions/update-products`, {
|
|
53
|
-
seriesId: documentId,
|
|
54
|
-
fieldsToUpdate
|
|
55
|
-
});
|
|
56
|
-
if (!response.data) {
|
|
57
|
-
throw new Error("Failed to update products");
|
|
58
|
-
}
|
|
59
|
-
} catch (error) {
|
|
60
|
-
console.error("Error updating products:", error);
|
|
61
|
-
} finally{
|
|
62
|
-
setIsLoading(false);
|
|
63
|
-
}
|
|
64
|
-
};
|
|
65
|
-
return {
|
|
66
|
-
title: "Series Product Actions",
|
|
67
|
-
content: /*#__PURE__*/ jsxRuntime.jsx(designSystem.Box, {
|
|
68
|
-
children: /*#__PURE__*/ jsxRuntime.jsxs(designSystem.Box, {
|
|
69
|
-
children: [
|
|
70
|
-
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Typography, {
|
|
71
|
-
variant: "delta",
|
|
72
|
-
fontWeight: "bold",
|
|
73
|
-
children: formatMessage({
|
|
74
|
-
id: "product-series.actions.label"
|
|
75
|
-
})
|
|
76
|
-
}),
|
|
77
|
-
/*#__PURE__*/ jsxRuntime.jsxs(designSystem.Flex, {
|
|
78
|
-
wrap: "wrap",
|
|
79
|
-
children: [
|
|
80
|
-
!documentId && /*#__PURE__*/ jsxRuntime.jsx(designSystem.Typography, {
|
|
81
|
-
display: "block",
|
|
82
|
-
marginTop: 2,
|
|
83
|
-
marginBottom: 2,
|
|
84
|
-
width: "100%",
|
|
85
|
-
color: "red",
|
|
86
|
-
children: formatMessage({
|
|
87
|
-
id: "product-series.actions.noDocumentId"
|
|
88
|
-
})
|
|
89
|
-
}),
|
|
90
|
-
/*#__PURE__*/ jsxRuntime.jsxs(designSystem.Dialog.Root, {
|
|
91
|
-
children: [
|
|
92
|
-
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Dialog.Trigger, {
|
|
93
|
-
children: /*#__PURE__*/ jsxRuntime.jsx(designSystem.Button, {
|
|
94
|
-
variant: "secondary",
|
|
95
|
-
disabled: isLoading || !documentId,
|
|
96
|
-
children: formatMessage({
|
|
97
|
-
id: "product-series.actions.createProducts"
|
|
98
|
-
})
|
|
99
|
-
})
|
|
100
|
-
}),
|
|
101
|
-
/*#__PURE__*/ jsxRuntime.jsxs(designSystem.Dialog.Content, {
|
|
102
|
-
children: [
|
|
103
|
-
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Dialog.Body, {
|
|
104
|
-
children: /*#__PURE__*/ jsxRuntime.jsxs(designSystem.Box, {
|
|
105
|
-
children: [
|
|
106
|
-
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Typography, {
|
|
107
|
-
children: formatMessage({
|
|
108
|
-
id: "product-series.actions.createDialogTitle"
|
|
109
|
-
})
|
|
110
|
-
}),
|
|
111
|
-
/*#__PURE__*/ jsxRuntime.jsx(designSystem.NumberInput, {
|
|
112
|
-
value: productCount,
|
|
113
|
-
onValueChange: (value)=>setProductCount(value || 1),
|
|
114
|
-
min: 1,
|
|
115
|
-
max: 100
|
|
116
|
-
})
|
|
117
|
-
]
|
|
118
|
-
})
|
|
119
|
-
}),
|
|
120
|
-
/*#__PURE__*/ jsxRuntime.jsxs(designSystem.Dialog.Footer, {
|
|
121
|
-
children: [
|
|
122
|
-
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Dialog.Cancel, {
|
|
123
|
-
children: /*#__PURE__*/ jsxRuntime.jsx(designSystem.Button, {
|
|
124
|
-
fullWidth: true,
|
|
125
|
-
variant: "tertiary",
|
|
126
|
-
children: "Cancel"
|
|
127
|
-
})
|
|
128
|
-
}),
|
|
129
|
-
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Dialog.Action, {
|
|
130
|
-
children: /*#__PURE__*/ jsxRuntime.jsx(designSystem.Button, {
|
|
131
|
-
onClick: handleCreateProducts,
|
|
132
|
-
variant: "default",
|
|
133
|
-
loading: isLoading,
|
|
134
|
-
children: formatMessage({
|
|
135
|
-
id: "product-series.actions.create"
|
|
136
|
-
})
|
|
137
|
-
})
|
|
138
|
-
})
|
|
139
|
-
]
|
|
140
|
-
})
|
|
141
|
-
]
|
|
142
|
-
})
|
|
143
|
-
]
|
|
144
|
-
}),
|
|
145
|
-
/*#__PURE__*/ jsxRuntime.jsxs(designSystem.Dialog.Root, {
|
|
146
|
-
children: [
|
|
147
|
-
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Dialog.Trigger, {
|
|
148
|
-
children: /*#__PURE__*/ jsxRuntime.jsx(designSystem.Button, {
|
|
149
|
-
marginLeft: 2,
|
|
150
|
-
variant: "secondary",
|
|
151
|
-
disabled: isLoading || !documentId,
|
|
152
|
-
children: formatMessage({
|
|
153
|
-
id: "product-series.actions.updateProducts"
|
|
154
|
-
})
|
|
155
|
-
})
|
|
156
|
-
}),
|
|
157
|
-
/*#__PURE__*/ jsxRuntime.jsxs(designSystem.Dialog.Content, {
|
|
158
|
-
children: [
|
|
159
|
-
/*#__PURE__*/ jsxRuntime.jsxs(designSystem.Dialog.Body, {
|
|
160
|
-
display: "flex",
|
|
161
|
-
direction: "column",
|
|
162
|
-
gap: 2,
|
|
163
|
-
justifyContent: "center",
|
|
164
|
-
alignItems: "center",
|
|
165
|
-
width: "100%",
|
|
166
|
-
children: [
|
|
167
|
-
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Typography, {
|
|
168
|
-
variant: "delta",
|
|
169
|
-
fontWeight: "bold",
|
|
170
|
-
children: formatMessage({
|
|
171
|
-
id: "product-series.actions.updateDialogTitle"
|
|
172
|
-
})
|
|
173
|
-
}),
|
|
174
|
-
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Typography, {
|
|
175
|
-
children: formatMessage({
|
|
176
|
-
id: "product-series.actions.updateDialogDescription"
|
|
177
|
-
})
|
|
178
|
-
}),
|
|
179
|
-
/*#__PURE__*/ jsxRuntime.jsx(designSystem.MultiSelect, {
|
|
180
|
-
withTags: true,
|
|
181
|
-
value: fieldsToUpdate,
|
|
182
|
-
onClear: ()=>setFieldsToUpdate([]),
|
|
183
|
-
onChange: (value)=>setFieldsToUpdate(value),
|
|
184
|
-
required: true,
|
|
185
|
-
placeholder: formatMessage({
|
|
186
|
-
id: "product-series.actions.selectFields"
|
|
187
|
-
}),
|
|
188
|
-
children: valuesToUpdate.map((field)=>/*#__PURE__*/ jsxRuntime.jsx(designSystem.MultiSelectOption, {
|
|
189
|
-
value: field,
|
|
190
|
-
children: field
|
|
191
|
-
}, field))
|
|
192
|
-
})
|
|
193
|
-
]
|
|
194
|
-
}),
|
|
195
|
-
/*#__PURE__*/ jsxRuntime.jsxs(designSystem.Dialog.Footer, {
|
|
196
|
-
children: [
|
|
197
|
-
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Dialog.Cancel, {
|
|
198
|
-
children: /*#__PURE__*/ jsxRuntime.jsx(designSystem.Button, {
|
|
199
|
-
fullWidth: true,
|
|
200
|
-
variant: "tertiary",
|
|
201
|
-
children: "Cancel"
|
|
202
|
-
})
|
|
203
|
-
}),
|
|
204
|
-
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Dialog.Action, {
|
|
205
|
-
children: /*#__PURE__*/ jsxRuntime.jsx(designSystem.Button, {
|
|
206
|
-
onClick: handleUpdateProducts,
|
|
207
|
-
variant: "default",
|
|
208
|
-
loading: isLoading,
|
|
209
|
-
children: formatMessage({
|
|
210
|
-
id: "product-series.actions.update"
|
|
211
|
-
})
|
|
212
|
-
})
|
|
213
|
-
})
|
|
214
|
-
]
|
|
215
|
-
})
|
|
216
|
-
]
|
|
217
|
-
})
|
|
218
|
-
]
|
|
219
|
-
})
|
|
220
|
-
]
|
|
221
|
-
})
|
|
222
|
-
]
|
|
223
|
-
})
|
|
224
|
-
})
|
|
225
|
-
};
|
|
226
|
-
};
|
|
227
|
-
|
|
228
|
-
exports.SeriesProductActions = SeriesProductActions;
|
|
229
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../admin/src/components/SeriesProductActions/index.tsx"],"sourcesContent":["import React, { useState } from \"react\";\r\n\r\nimport {\r\n Box,\r\n Button,\r\n Typography,\r\n Dialog,\r\n NumberInput,\r\n Flex,\r\n MultiSelect,\r\n MultiSelectOption,\r\n} from \"@strapi/design-system\";\r\nimport {\r\n useFetchClient,\r\n unstable_useContentManagerContext as useContentManagerContext,\r\n} from \"@strapi/strapi/admin\";\r\n\r\nimport { en } from \"../../translations\";\r\n\r\nconst formatMessage = (arg: { id: string }): string => {\r\n return en[arg.id];\r\n};\r\n\r\nconst valuesToUpdate = [\r\n \"description\",\r\n \"shortDescription\",\r\n \"media\",\r\n \"coverImage\",\r\n \"seo\",\r\n \"totalCost\",\r\n \"wholesalePrice\",\r\n \"retailPrice\",\r\n \"category\",\r\n \"creator\",\r\n];\r\n\r\ninterface Document {\r\n documentId?: string;\r\n}\r\n\r\nconst SeriesProductActions = ({ document }: { document: Document }) => {\r\n const { model } = useContentManagerContext();\r\n const documentId = document?.documentId;\r\n const [productCount, setProductCount] = useState(1);\r\n const [isLoading, setIsLoading] = useState(false);\r\n const [fieldsToUpdate, setFieldsToUpdate] = useState<string[]>([]);\r\n const { post, put } = useFetchClient();\r\n\r\n if (model !== \"api::product-series.product-series\") return null;\r\n\r\n const handleCreateProducts = async () => {\r\n try {\r\n setIsLoading(true);\r\n const response = await post(\r\n `primershop-product-actions/create-products`,\r\n {\r\n count: productCount,\r\n id: documentId,\r\n }\r\n );\r\n\r\n if (!response.data) {\r\n throw new Error(\"Failed to create products\");\r\n }\r\n\r\n setProductCount(1);\r\n } catch (error) {\r\n console.error(\"Error creating products:\", error);\r\n } finally {\r\n setIsLoading(false);\r\n }\r\n };\r\n\r\n const handleUpdateProducts = async () => {\r\n try {\r\n setIsLoading(true);\r\n const response = await put(\r\n `/primershop-product-actions/update-products`,\r\n {\r\n seriesId: documentId,\r\n fieldsToUpdate,\r\n }\r\n );\r\n\r\n if (!response.data) {\r\n throw new Error(\"Failed to update products\");\r\n }\r\n } catch (error) {\r\n console.error(\"Error updating products:\", error);\r\n } finally {\r\n setIsLoading(false);\r\n }\r\n };\r\n return {\r\n title: \"Series Product Actions\",\r\n content: (\r\n <Box>\r\n <Box>\r\n <Typography variant=\"delta\" fontWeight=\"bold\">\r\n {formatMessage({ id: \"product-series.actions.label\" })}\r\n </Typography>\r\n <Flex wrap={\"wrap\"}>\r\n {!documentId && (\r\n <Typography\r\n display={\"block\"}\r\n marginTop={2}\r\n marginBottom={2}\r\n width=\"100%\"\r\n color=\"red\"\r\n >\r\n {formatMessage({ id: \"product-series.actions.noDocumentId\" })}\r\n </Typography>\r\n )}\r\n\r\n <Dialog.Root>\r\n <Dialog.Trigger>\r\n <Button variant=\"secondary\" disabled={isLoading || !documentId}>\r\n {formatMessage({\r\n id: \"product-series.actions.createProducts\",\r\n })}\r\n </Button>\r\n </Dialog.Trigger>\r\n <Dialog.Content>\r\n <Dialog.Body>\r\n <Box>\r\n <Typography>\r\n {formatMessage({\r\n id: \"product-series.actions.createDialogTitle\",\r\n })}\r\n </Typography>\r\n <NumberInput\r\n value={productCount}\r\n onValueChange={(value) => setProductCount(value || 1)}\r\n min={1}\r\n max={100}\r\n ></NumberInput>\r\n </Box>\r\n </Dialog.Body>\r\n <Dialog.Footer>\r\n <Dialog.Cancel>\r\n <Button fullWidth variant=\"tertiary\">\r\n Cancel\r\n </Button>\r\n </Dialog.Cancel>\r\n <Dialog.Action>\r\n <Button\r\n onClick={handleCreateProducts}\r\n variant=\"default\"\r\n loading={isLoading}\r\n >\r\n {formatMessage({ id: \"product-series.actions.create\" })}\r\n </Button>\r\n </Dialog.Action>\r\n </Dialog.Footer>\r\n </Dialog.Content>\r\n </Dialog.Root>\r\n\r\n {/* Update Products Dialog */}\r\n <Dialog.Root>\r\n <Dialog.Trigger>\r\n <Button\r\n marginLeft={2}\r\n variant=\"secondary\"\r\n disabled={isLoading || !documentId}\r\n >\r\n {formatMessage({\r\n id: \"product-series.actions.updateProducts\",\r\n })}\r\n </Button>\r\n </Dialog.Trigger>\r\n <Dialog.Content>\r\n <Dialog.Body\r\n display={\"flex\"}\r\n direction={\"column\"}\r\n gap={2}\r\n justifyContent={\"center\"}\r\n alignItems={\"center\"}\r\n width={\"100%\"}\r\n >\r\n <Typography variant=\"delta\" fontWeight=\"bold\">\r\n {formatMessage({\r\n id: \"product-series.actions.updateDialogTitle\",\r\n })}\r\n </Typography>\r\n <Typography>\r\n {formatMessage({\r\n id: \"product-series.actions.updateDialogDescription\",\r\n })}\r\n </Typography>\r\n <MultiSelect\r\n withTags={true}\r\n value={fieldsToUpdate}\r\n onClear={() => setFieldsToUpdate([])}\r\n onChange={(value: string[]) => setFieldsToUpdate(value)}\r\n required={true}\r\n placeholder={formatMessage({\r\n id: \"product-series.actions.selectFields\",\r\n })}\r\n >\r\n {valuesToUpdate.map((field) => (\r\n <MultiSelectOption key={field} value={field}>\r\n {field}\r\n </MultiSelectOption>\r\n ))}\r\n </MultiSelect>\r\n </Dialog.Body>\r\n <Dialog.Footer>\r\n <Dialog.Cancel>\r\n <Button fullWidth variant=\"tertiary\">\r\n Cancel\r\n </Button>\r\n </Dialog.Cancel>\r\n <Dialog.Action>\r\n <Button\r\n onClick={handleUpdateProducts}\r\n variant=\"default\"\r\n loading={isLoading}\r\n >\r\n {formatMessage({ id: \"product-series.actions.update\" })}\r\n </Button>\r\n </Dialog.Action>\r\n </Dialog.Footer>\r\n </Dialog.Content>\r\n </Dialog.Root>\r\n </Flex>\r\n </Box>\r\n </Box>\r\n ),\r\n };\r\n};\r\n\r\nexport { SeriesProductActions };\r\n"],"names":["formatMessage","arg","en","id","valuesToUpdate","SeriesProductActions","document","model","useContentManagerContext","documentId","productCount","setProductCount","useState","isLoading","setIsLoading","fieldsToUpdate","setFieldsToUpdate","post","put","useFetchClient","handleCreateProducts","response","count","data","Error","error","console","handleUpdateProducts","seriesId","title","content","_jsx","Box","_jsxs","Typography","variant","fontWeight","Flex","wrap","display","marginTop","marginBottom","width","color","Dialog","Root","Trigger","Button","disabled","Content","Body","NumberInput","value","onValueChange","min","max","Footer","Cancel","fullWidth","Action","onClick","loading","marginLeft","direction","gap","justifyContent","alignItems","MultiSelect","withTags","onClear","onChange","required","placeholder","map","field","MultiSelectOption"],"mappings":";;;;;;;;AAmBA,MAAMA,gBAAgB,CAACC,GAAAA,GAAAA;AACrB,IAAA,OAAOC,KAAE,CAACD,GAAAA,CAAIE,EAAE,CAAC;AACnB,CAAA;AAEA,MAAMC,cAAAA,GAAiB;AACrB,IAAA,aAAA;AACA,IAAA,kBAAA;AACA,IAAA,OAAA;AACA,IAAA,YAAA;AACA,IAAA,KAAA;AACA,IAAA,WAAA;AACA,IAAA,gBAAA;AACA,IAAA,aAAA;AACA,IAAA,UAAA;AACA,IAAA;AACD,CAAA;AAMD,MAAMC,oBAAAA,GAAuB,CAAC,EAAEC,QAAQ,EAA0B,GAAA;IAChE,MAAM,EAAEC,KAAK,EAAE,GAAGC,uCAAAA,EAAAA;AAClB,IAAA,MAAMC,aAAaH,QAAAA,EAAUG,UAAAA;AAC7B,IAAA,MAAM,CAACC,YAAAA,EAAcC,eAAAA,CAAgB,GAAGC,cAAAA,CAAS,CAAA,CAAA;AACjD,IAAA,MAAM,CAACC,SAAAA,EAAWC,YAAAA,CAAa,GAAGF,cAAAA,CAAS,KAAA,CAAA;AAC3C,IAAA,MAAM,CAACG,cAAAA,EAAgBC,iBAAAA,CAAkB,GAAGJ,e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