#include <MsgBoxConstants.au3> ; to declare the Constants of MsgBox
Local $sRegex = "(?m)(export )?const (.* \= \()(.*)(\).*\()(?'fileContent'(\n.*)+)\3\.(?'varName'[^}]*)\}(?'restOfPropLine'.*$)(?'restOfFileContent'(\n.*)+>\n\);)"
Local $sString = "export const AffiliateAccountBIFields = (props) => (" & @CRLF & _
" <SimpleShowLayout {...props} variant="one">" & @CRLF & _
" <UrlField source="bi_url" options={{ target: '_blank' }} />" & @CRLF & _
" <ProtectedBIConfigField source="bi_settings" />" & @CRLF & _
" </SimpleShowLayout>" & @CRLF & _
");" & @CRLF & _
"" & @CRLF & _
"export const AffiliateAccountGeneralFields = (props) => (" & @CRLF & _
" <SimpleShowLayout {...props}>" & @CRLF & _
" <TextField source="name" />" & @CRLF & _
" <ReferenceField" & @CRLF & _
" linkType="show"" & @CRLF & _
" label="Platform Provider"" & @CRLF & _
" addLabel" & @CRLF & _
" source="platform_provider_id"" & @CRLF & _
" reference="accounts/platform-providers"" & @CRLF & _
" allowEmpty" & @CRLF & _
" >" & @CRLF & _
" <TextField addLabel source="name" />" & @CRLF & _
" </ReferenceField>" & @CRLF & _
" <ReferenceField" & @CRLF & _
" label="Company"" & @CRLF & _
" addLabel" & @CRLF & _
" source="company_id"" & @CRLF & _
" reference="companies"" & @CRLF & _
" linkType="show"" & @CRLF & _
" >" & @CRLF & _
" <TextField addLabel source="name" />" & @CRLF & _
" </ReferenceField>" & @CRLF & _
" <AccountManagerField" & @CRLF & _
" label="Account Manager"" & @CRLF & _
" source="account_manager_id"" & @CRLF & _
" addLabel" & @CRLF & _
" />" & @CRLF & _
" <PortfolioField label="Portfolio" source="portfolio_id" addLabel />" & @CRLF & _
" <FunctionField" & @CRLF & _
" label="Status"" & @CRLF & _
" addLabel" & @CRLF & _
" source="activity_status"" & @CRLF & _
" render={(record) => {" & @CRLF & _
" if (!record.activity_status) return null;" & @CRLF & _
" const humanizedStatus = get(" & @CRLF & _
" ACTIVITY_STATUS_OPTIONS," & @CRLF & _
" `${record.activity_status}.name`" & @CRLF & _
" );" & @CRLF & _
" if (!humanizedStatus) {" & @CRLF & _
" // eslint-disable-next-line no-console" & @CRLF & _
" console.warn(`Cannot obtain humanized value for activity_status: ${record.activity_status}`);" & @CRLF & _
" }" & @CRLF & _
" return (" & @CRLF & _
" <TextField" & @CRLF & _
" source="activity_status"" & @CRLF & _
" record={{" & @CRLF & _
" ...record," & @CRLF & _
" activity_status: humanizedStatus || record.activity_status," & @CRLF & _
" }}" & @CRLF & _
" />" & @CRLF & _
" );" & @CRLF & _
" }}" & @CRLF & _
" />" & @CRLF & _
" <UrlField source="affiliate_system_link" options={{ target: '_blank' }} />" & @CRLF & _
" <CopyToClipboardField source="username">" & @CRLF & _
" <TextField source="username" />" & @CRLF & _
" </CopyToClipboardField>" & @CRLF & _
" <ProtectedField source="password" />" & @CRLF & _
" <CopyToClipboardField source="email">" & @CRLF & _
" <TextField source="email" />" & @CRLF & _
" </CopyToClipboardField>" & @CRLF & _
" <TextField source="security_question" />" & @CRLF & _
" <ProtectedField source="security_answer" />" & @CRLF & _
" <TextField source="type" />" & @CRLF & _
" <BooleanField source="tracking_enabled" />" & @CRLF & _
" <TextField source="tracking_variable_name" />" & @CRLF & _
" <TextField source="external_affiliate_id" />" & @CRLF & _
" <TextField source="revenue_posting_code" />" & @CRLF & _
" <BooleanField source="loss_carry_forward" />" & @CRLF & _
" <DateField source="updated_at" locales="en-GB" showTime />" & @CRLF & _
" <DateField source="created_at" locales="en-GB" showTime />" & @CRLF & _
" </SimpleShowLayout>" & @CRLF & _
");" & @CRLF & _
"" & @CRLF & _
"export const AffiliateAccountTabs = (props) => {" & @CRLF & _
" if (!props.record) {" & @CRLF & _
" return null;" & @CRLF & _
" }" & @CRLF & _
"" & @CRLF & _
" return (" & @CRLF & _
" <TabbedShowLayout>" & @CRLF & _
" <AffiliateAccountGeneralFields {...props} label="General" />" & @CRLF & _
" <AffiliateAccountBrands {...props} label="Brands" />" & @CRLF & _
" <AffiliateAccountDeals {...props} label="Deals" />" & @CRLF & _
" {props.hasBIPermission && (" & @CRLF & _
" <AffiliateAccountBIFields {...props} label="BI Settings" />" & @CRLF & _
" )}" & @CRLF & _
" </TabbedShowLayout>" & @CRLF & _
" );" & @CRLF & _
"};" & @CRLF & _
"AffiliateAccountTabs.propTypes = {" & @CRLF & _
" record: PropTypes.object," & @CRLF & _
" hasBIPermission: PropTypes.bool.isRequired," & @CRLF & _
"};" & @CRLF & _
"" & @CRLF & _
"export const Show = (props) => (" & @CRLF & _
" <AutoLoginStatusDialog messages={messages}>" & @CRLF & _
" <AORShow" & @CRLF & _
" {...props}" & @CRLF & _
" title={(" & @CRLF & _
" <Title" & @CRLF & _
" resource="Affiliate Account"" & @CRLF & _
" type="show"" & @CRLF & _
" buttons={[" & @CRLF & _
" <FavoriteButton" & @CRLF & _
" record={{ _id: props.match.params.id }}" & @CRLF & _
" resource={props.resource}" & @CRLF & _
" style={{ height: '25px' }}" & @CRLF & _
" />," & @CRLF & _
" ]}" & @CRLF & _
" />" & @CRLF & _
" )}" & @CRLF & _
" actions={(" & @CRLF & _
" <ActionsPanel" & @CRLF & _
" customButtons={[" & @CRLF & _
" <AutoLoginButton" & @CRLF & _
" record={{ _id: props.match.params.id }}" & @CRLF & _
" resource={props.resource}" & @CRLF & _
" resourceConfig={autoLoginConfig}" & @CRLF & _
" label="Auto Login"" & @CRLF & _
" />," & @CRLF & _
" ]}" & @CRLF & _
" />" & @CRLF & _
" )}" & @CRLF & _
" >" & @CRLF & _
" <AffiliateAccountTabs hasBIPermission={props.hasBIPermission} />" & @CRLF & _
" </AORShow>" & @CRLF & _
" <NotesView isShow match={props.match} resource={props.resource} />" & @CRLF & _
" </AutoLoginStatusDialog>" & @CRLF & _
");" & @CRLF & _
"Show.propTypes = {" & @CRLF & _
" match: PropTypes.shape({" & @CRLF & _
" params: PropTypes.shape({" & @CRLF & _
" id: PropTypes.string," & @CRLF & _
" })," & @CRLF & _
" })," & @CRLF & _
" resource: PropTypes.string," & @CRLF & _
" hasBIPermission: PropTypes.bool.isRequired," & @CRLF & _
"};" & @CRLF & _
"" & @CRLF & _
"export default connect((state) => ({" & @CRLF & _
" hasBIPermission: checkPermission(state.auth.permissions, '*', 'bi_user')," & @CRLF & _
"}))(Show);" & @CRLF & _
""
Local $sSubst = "$1const $2{ ${varName}, ...$3 }$4${fileContent}${varName}}${restOfPropLine}${restOfFileContent}"
Local $sResult = StringRegExpReplace($sString, $sRegex, $sSubst)
MsgBox($MB_SYSTEMMODAL, "Result", $sResult)
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for AutoIt, please visit: https://www.autoitscript.com/autoit3/docs/functions/StringRegExp.htm