auto-component 0.0.30 → 0.0.32

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.
Files changed (2) hide show
  1. package/package.json +2 -5
  2. package/src/index.jsx +17 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "auto-component",
3
- "version": "0.0.30",
3
+ "version": "0.0.32",
4
4
  "main": "src/index.jsx",
5
5
  "peerDependencies": {
6
6
  "react": "^18.2.0",
@@ -8,8 +8,5 @@
8
8
  },
9
9
  "files": [
10
10
  "src"
11
- ],
12
- "dependencies": {
13
- "js-beautify": "^1.14.11"
14
- }
11
+ ]
15
12
  }
package/src/index.jsx CHANGED
@@ -14,8 +14,9 @@ const AutoComponent = ({ exclusions }) => {
14
14
 
15
15
  const [ responseData, setResponseData ] = useState(null)
16
16
  const [ requestData, setRequestData ] = useState(null)
17
-
17
+
18
18
  const [ activeTab, setActiveTab ] = useState('request')
19
+ const [ history, setHistory ] = useState(["No History"])
19
20
 
20
21
  //**-------------------------**/
21
22
  // ** HTML/CSS Formatting ** //
@@ -125,6 +126,7 @@ const AutoComponent = ({ exclusions }) => {
125
126
  const resData = await sendRequest();
126
127
 
127
128
  if (resData) {
129
+ setHistory(resData.history)
128
130
  // setResponseData(formatHtml(resData.response.content));
129
131
  setResponseData(resData.response.content);
130
132
  setActiveTab('response');
@@ -162,6 +164,7 @@ const AutoComponent = ({ exclusions }) => {
162
164
  setRequest('')
163
165
  setResponseData('')
164
166
  randomUser()
167
+ setHistory([])
165
168
  }
166
169
 
167
170
  const handleRequestTab = () => {
@@ -180,12 +183,23 @@ const AutoComponent = ({ exclusions }) => {
180
183
  // ** Rendering ** //
181
184
  //**-------------**/
182
185
 
186
+ const getLog = () => {
187
+ return (
188
+ history.map((entry, index) => (
189
+
190
+ index !== 0 && entry.content.split('HTML Context:')[0] + (entry.content.includes("User Request") ? '\n' : '\n\n\n')
191
+ )
192
+ ))
193
+ }
194
+
183
195
  const requestHTML = currentHtml ? (
184
196
  `Review the details below for accuracy and privacy concerns.
185
197
  If the contents of an element should be excluded, add the 'exclude' class to the element.
186
198
  Click Generate to send the request and receive the auto component AI generated code.
187
199
 
188
- User Request:\n `
200
+ User ID:\n `
201
+ + user
202
+ + "\n\nUser Request:\n"
189
203
  + currentRequest
190
204
  + "\n\nUser HTML:\n"
191
205
  + currentHtml
@@ -215,7 +229,7 @@ User Request:\n `
215
229
  </div>
216
230
  </div>
217
231
  <pre>
218
- {activeTab === 'request' ? requestHTML : responseHtml}
232
+ {activeTab === 'request' ? getLog() : responseHtml}
219
233
  </pre>
220
234
  </div>
221
235
  <div className="copy-btn" onClick={copyToClipboard} style={activeTab !== 'response' ? { display: 'none' } : null}>