Skip to content

Commit

Permalink
fix(*): update form components
Browse files Browse the repository at this point in the history
  • Loading branch information
HoseaCodes committed Feb 21, 2024
1 parent fac63d6 commit 2f78de0
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 3 deletions.
72 changes: 72 additions & 0 deletions src/Components/Form/ProfileForm.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import React, { useState } from "react";
import { Form, Button } from "react-bootstrap";

const ProfileForm = ({ onSubmit }) => {
const [name, setName] = useState("");
const [age, setAge] = useState("");
const [occupation, setOccupation] = useState("");
const [bio, setBio] = useState("");

const handleSubmit = e => {
e.preventDefault();
const profileData = {
name,
age,
occupation,
bio
};
// Pass the profile data to the parent component
onSubmit(profileData);
};

return (
<Form onSubmit={handleSubmit}>
<Form.Group controlId="formName">
<Form.Label>Name</Form.Label>
<Form.Control
type="text"
placeholder="Enter your name"
value={name}
onChange={e => setName(e.target.value)}
/>
</Form.Group>

<Form.Group controlId="formAge">
<Form.Label>Age</Form.Label>
<Form.Control
type="number"
placeholder="Enter your age"
value={age}
onChange={e => setAge(e.target.value)}
/>
</Form.Group>

<Form.Group controlId="formOccupation">
<Form.Label>Occupation</Form.Label>
<Form.Control
type="text"
placeholder="Enter your occupation"
value={occupation}
onChange={e => setOccupation(e.target.value)}
/>
</Form.Group>

<Form.Group controlId="formBio">
<Form.Label>Bio</Form.Label>
<Form.Control
as="textarea"
rows={3}
placeholder="Enter a short bio"
value={bio}
onChange={e => setBio(e.target.value)}
/>
</Form.Group>

<Button variant="primary" type="submit">
Save Profile
</Button>
</Form>
);
};

export default ProfileForm;
File renamed without changes.
11 changes: 8 additions & 3 deletions src/Components/OpenAI/AITemplate.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,14 @@ function AITemplate({ showAITemplate, setShowAITemplate }) {
const openai = new OpenAIApi(configuration);

const doStuff = async () => {
let object = { ...option, prompt: input };
const response = await openai.createCompletion(object);
setResult(response.data.choices[0].text);
try {
let object = { ...option, prompt: input };
const response = await openai.createCompletion(object);
setResult(response.data.choices[0].text);
} catch (error) {
console.log(error);
alert("Error in AI", error);
}
};

const handleChangeInputOPENPAI = e => {
Expand Down

0 comments on commit 2f78de0

Please sign in to comment.