Skip to content

Commit

Permalink
made reviw changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Ashwini1997727 committed Jun 7, 2022
1 parent 6678fa9 commit 6ebd2f3
Show file tree
Hide file tree
Showing 17 changed files with 1 addition and 1,477 deletions.
27 changes: 1 addition & 26 deletions audience-app/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,37 +1,12 @@
import React from "react";
import { HashRouter, Route, Routes, Navigate } from "react-router-dom";
import ConfigScreen from "./Config";
import RTE from "./RTE";

/** HomeRedirectHandler - component to nandle redirect based on the window location pathname,
as react Router does not identifies pathname if the app is rendered in an iframe.
*/
const HomeRedirectHandler = function () {
if (window?.location?.pathname !== "/") {
return <Navigate to={{ pathname: window.location.pathname }} />;
}
return null;
};

/* App - The main app component that should be rendered */
const App: React.FC = function () {
// console.log("APP RENDERED")
return (
<div>
<ConfigScreen />
{/* <HashRouter>
<Routes>
<Route path="/" element={<HomeRedirectHandler />} />
<Route path="/rte" element={<RTE />} />
<Route path="/config" element={<ConfigScreen />} />
</Routes>
</HashRouter> */}
</div>
);
};

export default App;


// contentstack web : url: http//localhost:3000
//when http://localhost:3000/rte -> fetch(`url/fetch`) -> js code -> state ->
export default App;
54 changes: 0 additions & 54 deletions audience-app/src/Config/index.tsx
Original file line number Diff line number Diff line change
@@ -1,32 +1,20 @@
/* Import React modules */
import React, { useState, useEffect } from "react";
/* Import other node modules */
import {
Field,
FieldLabel,
TextInput,
} from "@contentstack/venus-components";
// For all the available venus components, please refer below doc
// https://venus-storybook.contentstack.com/?path=/docs/components-textinput--default
import ContentstackAppSdk from "@contentstack/app-sdk";
/* Import our modules */
import localeTexts from "../common/locale/en-us";
import utils from "../common/utils";
import { TypeAppSdkConfigState } from "../common/types";
// import { getDataFromAPI } from '../../services'; //If no services are required, this can be removed\
/* Import node module CSS */
import "@contentstack/venus-components/build/main.css";
/* Import our CSS */
//@ts-ignore
import styles from "./style.module.css";

const ConfigScreen: React.FC = function () {
const [state, setState] = useState<TypeAppSdkConfigState>({
installationData: {
configuration: {
/* Add all your config fields here */
/* The key defined here should match with the name attribute
given in the DOM that is being returned at last in this component */
content_type: "",
field: "",
group_title: ""
Expand All @@ -41,7 +29,6 @@ const ConfigScreen: React.FC = function () {
ContentstackAppSdk.init().then(async (appSdk) => {
const sdkConfigData = appSdk?.location?.AppConfigWidget;
if (sdkConfigData) {
console.log("sdkConfigData: ",sdkConfigData)
const installationDataFromSDK =
//@ts-ignore
await sdkConfigData.installation.getInstallationData();
Expand All @@ -58,14 +45,9 @@ const ConfigScreen: React.FC = function () {
});
}
});
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

/** updateConfig - Function where you should update the state variable
* Call this function whenever any field value is changed in the DOM
* */
const updateConfig = async (e: any) => {
// eslint-disable-next-line prefer-const
let { name: fieldName, value: fieldValue } = e.target;
const updatedConfig = state?.installationData?.configuration || {};
updatedConfig[fieldName] = fieldValue;
Expand All @@ -84,49 +66,28 @@ const ConfigScreen: React.FC = function () {
return true;
};

/* If need to get any data from API then use,
getDataFromAPI({queryParams, headers, method, body}) function.
Refer services/index.ts for more details and update the API
call there as per requirement. */

return (
<div className={styles['layout-container']}>
<div className="page-wrapper">
{/* <Form className="config-wrapper"> */}
<Field>
<FieldLabel required htmlFor="content_typeId">
{" "}
{/* Change the label caption as per your requirement */}
{localeTexts.configFields.field1.label}
</FieldLabel>
{/* Change the help caption as per your requirement */}
{/* <Help text={localeTexts.configFields.field1.help} /> */}
<TextInput
id="content_typeId"
required
value={state.installationData.configuration.content_type}
placeholder={localeTexts.configFields.field1.placeholder}
/* The name attribute given here should match with the
state variable definition. Please check the comments above
at the state variable definition. */
name="content_type"
onChange={updateConfig}
/>
{/* <InstructionText>
{localeTexts.configFields.field1.instruction}
</InstructionText> */}
</Field>

{/* <Line type="solid" /> */}

<Field>
<FieldLabel required htmlFor="fieldId">
{" "}
{/* Change the label caption as per your requirement */}
{localeTexts.configFields.field2.label}
</FieldLabel>
{/* Change the help caption as per your requirement */}
{/* <Help text={localeTexts.configFields.field2.help} /> */}
<TextInput
required
id="fieldId"
Expand All @@ -135,36 +96,21 @@ const ConfigScreen: React.FC = function () {
name="field"
onChange={updateConfig}
/>
{/* <InstructionText>
{localeTexts.configFields.field2.instruction}
</InstructionText> */}
</Field>
<Field>
<FieldLabel required htmlFor="group_titleId">
{" "}
{/* Change the label caption as per your requirement */}
{localeTexts.configFields.field3.label}
</FieldLabel>
{/* Change the help caption as per your requirement */}
{/* <Help text={localeTexts.configFields.field1.help} /> */}
<TextInput
id="group_titleId"
required
value={state.installationData.configuration.group_title}
placeholder={localeTexts.configFields.field3.placeholder}
/* The name attribute given here should match with the
state variable definition. Please check the comments above
at the state variable definition. */
name="group_title"
onChange={updateConfig}
/>
{/* <InstructionText>
{localeTexts.configFields.field1.instruction}
</InstructionText> */}
</Field>

{/* <Line type="solid" /> */}
{/* </Form> */}
</div>
</div>
);
Expand Down
1 change: 0 additions & 1 deletion audience-app/src/RTE/assets/edit-2.svg

This file was deleted.

1 change: 0 additions & 1 deletion audience-app/src/RTE/assets/info.svg

This file was deleted.

74 changes: 0 additions & 74 deletions audience-app/src/RTE/audiencePlugin/AudienceComponent.tsx

This file was deleted.

Loading

0 comments on commit 6ebd2f3

Please sign in to comment.