-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0b0afcb
commit 4dc32ad
Showing
5 changed files
with
120 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import { | ||
Button, | ||
Flex, | ||
Input, | ||
Textarea | ||
} from "@chakra-ui/react"; | ||
import { useState } from "react"; | ||
import createThing from "../services/createThing"; | ||
|
||
const CreatorForm = ({ setIsLoading, handleError, handleSuccess }) => { | ||
// UPDATE STATE TO HANDLE YOUR TYPE | ||
const [title, setTitle] = useState(""); | ||
const [description, setDescription] = useState(""); | ||
|
||
// UPDATE HANDLE METHODS TO MATCH YOUR STATE | ||
const handleTitleChange = (event) => { | ||
setTitle(event.target.value); | ||
}; | ||
|
||
const handleDescriptionChange = (event) => { | ||
setDescription(event.target.value); | ||
}; | ||
|
||
const handleSubmit = async () => { | ||
setIsLoading(true); | ||
// UPDATE OBJECT TO MATCH YOUR TYPE | ||
const response = await createThing({ | ||
title, | ||
description, | ||
}); | ||
if (response.error) { | ||
handleError(response.error); | ||
} else { | ||
handleSuccess(); | ||
setTitle(""); | ||
setDescription(""); | ||
} | ||
setIsLoading(false); | ||
}; | ||
|
||
return ( | ||
<Flex flexDirection="column" alignItems="left" mt={2}> | ||
{/* ADD YOUR INPUTS HERE */} | ||
<Input | ||
placeholder="Title" | ||
value={title} | ||
onChange={handleTitleChange} | ||
mb={2} | ||
/> | ||
<Textarea | ||
placeholder="Description" | ||
value={description} | ||
onChange={handleDescriptionChange} | ||
mb={4} | ||
/> | ||
<Button | ||
onClick={handleSubmit} | ||
isDisabled={title.length < 1 || description.length < 1} | ||
> | ||
Submit | ||
</Button> | ||
</Flex> | ||
); | ||
}; | ||
|
||
export default CreatorForm; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters