{
"data": {
"near": {
"widget": {
"Posts.Menu": {
"": "const { accountId, blockHeight, parentFunctions, item } = props;\nconst contentType = props.contentType || \"post\";\nconst contentPath = props.contentPath || \"/post/main\";\nconst capitalizedContentType = contentType.charAt(0).toUpperCase() + contentType.slice(1);\n\nconst confirmationMessages = {\n savingData: {\n header: \"Saving Data\",\n detail: \"Storing your action.\",\n },\n hideItem: {\n header: capitalizedContentType + \" Hidden\",\n detail: `This ${contentType} will no longer be shown to you.`,\n },\n hideAccount: {\n header: \"Account Muted\",\n detail: `All content from this account will be no longer be shown to you.`,\n },\n reportItem: {\n header: capitalizedContentType + \" Reported for Moderation\",\n detail: \"The item will no longer be shown to you and will be reviewed. Thanks for helping our Content Moderators.\",\n },\n reportAccount: {\n header: \"Account Reported for Moderation\",\n detail:\n \"All content from this account will no longer be shown to you and will be reviewed. Thanks for helping our Content Moderators.\",\n },\n};\n\nconst moderate = (account, block, messageKey, action) => {\n const modifiedContentPath = contentPath.replace(/\\//g, \".\");\n\n const dataValue = block\n ? {\n [modifiedContentPath]: {\n [block]: action,\n },\n }\n : action;\n\n const data = {\n moderate: {\n [account]: dataValue,\n },\n };\n\n if (action !== \"hide\") {\n const indexValue = block\n ? {\n path: `${account}${contentPath}`,\n blockHeight: block,\n label: action,\n }\n : {\n path: account,\n label: action,\n };\n\n data.index = {\n moderation: JSON.stringify({\n key: \"reported\",\n value: indexValue,\n }),\n };\n }\n\n if (parentFunctions.optimisticallyHideItem) {\n parentFunctions.optimisticallyHideItem(confirmationMessages[\"savingData\"]);\n }\n Social.set(data, {\n onCommit: () => {\n parentFunctions.resolveHideItem(confirmationMessages[messageKey]);\n },\n onCancel: () => {\n parentFunctions.cancelHideItem();\n },\n });\n};\n\nconst buildMenu = (accountId, blockHeight) => {\n const hideSubmenu = [\n {\n name: \"Mute \" + accountId,\n iconLeft: \"ph-bold ph-ear-slash\",\n onSelect: () => moderate(accountId, null, \"hideAccount\", \"hide\"),\n },\n ];\n\n const reportSubmenu = [\n {\n name: \"Report \" + accountId,\n iconLeft: \"ph-bold ph-warning-octagon\",\n onSelect: () => showReportModal(\"Account\"),\n },\n ];\n\n if (blockHeight) {\n hideSubmenu.unshift({\n name: \"Hide this \" + capitalizedContentType,\n iconLeft: \"ph-bold ph-eye-slash\",\n onSelect: () => moderate(accountId, blockHeight, \"hideItem\", \"hide\"),\n });\n reportSubmenu.unshift({\n name: \"Report this \" + capitalizedContentType,\n iconLeft: \"ph-bold ph-warning-octagon\",\n onSelect: () => showReportModal(capitalizedContentType),\n });\n }\n const menu = [\n {\n name: \"Hide\",\n iconLeft: \"ph-bold ph-eye-slash\",\n disabled: !context.accountId || context.accountId === accountId,\n subMenuProps: {\n items: hideSubmenu,\n },\n },\n {\n name: (\n <>\n <i className=\"ph-bold ph-warning-octagon\" style={{ color: \"#D95C4A\" }} />\n <span style={{ color: \"#D95C4A\" }}>Report</span>\n </>\n ),\n disabled: !context.accountId || context.accountId === accountId,\n subMenuProps: {\n items: reportSubmenu,\n },\n },\n // {\n // name: \"Edit\",\n // iconLeft: \"ph-bold ph-pencil me-1\",\n // onSelect: parentFunctions.toggleEdit,\n // },\n ];\n\n return menu;\n};\n\n// when set, value is the type of content to moderate (Account, Post or Comment)\nconst [showModal, setShowModal] = useState(null);\nconst showReportModal = (type) => {\n setShowModal(type);\n};\nconst closeModal = () => {\n setShowModal(false);\n};\nconst submitClick = (type, event, reason) => {\n if (type === \"Account\") {\n moderate(accountId, null, \"reportAccount\", reason);\n } else {\n moderate(accountId, blockHeight, \"reportItem\", reason);\n }\n};\n\nreturn (\n <>\n <Widget\n src=\"near/widget/DIG.DropdownMenu\"\n props={{\n trigger: <i className=\"ph-bold ph-dots-three\" />,\n items: buildMenu(accountId, blockHeight),\n }}\n />\n <Widget\n src=\"near/widget/Moderation.ReasonDialog\"\n props={{\n closeModal,\n open: showModal,\n submitClick: submitClick.bind(null, showModal),\n type: showModal,\n }}\n />\n </>\n);\n"
}
}
}
}
}