Skip to content

Commit

Permalink
run linter
Browse files Browse the repository at this point in the history
  • Loading branch information
Connor Bechthold committed Jan 4, 2024
1 parent e5fe1fb commit 8bc26f9
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 22 deletions.
2 changes: 1 addition & 1 deletion frontend/src/APIClients/TagAPIClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,5 +80,5 @@ const createTag = async ({
export default {
countTags,
getTags,
createTag
createTag,
};
50 changes: 33 additions & 17 deletions frontend/src/components/forms/CreateTag.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
import React, { useState } from "react";
import { Box, Button, Divider, FormErrorMessage, FormControl, FormLabel, Input, Modal, ModalBody, ModalCloseButton, ModalContent, ModalFooter, ModalHeader, ModalOverlay } from "@chakra-ui/react";
import {
Box,
Button,
Divider,
FormErrorMessage,
FormControl,
FormLabel,
Input,
Modal,
ModalBody,
ModalCloseButton,
ModalContent,
ModalFooter,
ModalHeader,
ModalOverlay,
} from "@chakra-ui/react";
import { AddIcon } from "@chakra-ui/icons";
import { Col, Row } from "react-bootstrap";
import CreateToast from "../common/Toasts";
Expand All @@ -15,9 +30,8 @@ type Props = {
const CreateTag = ({
getTags,
setUserPageNum,
countTags
countTags,
}: Props): React.ReactElement => {

const [tagName, setTagName] = useState("");

const [isOpen, setIsOpen] = useState(false);
Expand All @@ -26,14 +40,14 @@ const CreateTag = ({
const [tagNameError, setTagNameError] = useState(false);

const handleClose = () => {
setTagName("")
setTagNameError(false)
setIsOpen(false)
setTagName("");
setTagNameError(false);
setIsOpen(false);
};

const addTag = async () => {
const res = await TagAPIClient.createTag({
name: tagName
name: tagName,
});

if (isErrorResponse(res)) {
Expand All @@ -47,7 +61,7 @@ const CreateTag = ({
} else {
newToast("Error adding tag", "Unable to add tag.", "error");
}
}
};

const handleTagNameChange = (e: React.ChangeEvent<HTMLInputElement>) => {
const inputValue = e.target.value;
Expand All @@ -59,19 +73,23 @@ const CreateTag = ({

const handleSubmit = () => {
if (tagName.length === 0) {
setTagNameError(true)
return
setTagNameError(true);
return;
}

addTag()
}
addTag();
};

return (
<>
<Button leftIcon={<AddIcon />} variant="primary" onClick={() => setIsOpen(true)}>
<Button
leftIcon={<AddIcon />}
variant="primary"
onClick={() => setIsOpen(true)}
>
Add Tag
</Button>

<Box>
<Modal isOpen={isOpen} onClose={handleClose} size="xl">
<ModalOverlay />
Expand All @@ -89,9 +107,7 @@ const CreateTag = ({
value={tagName}
onChange={handleTagNameChange}
/>
<FormErrorMessage>
Tag name is required.
</FormErrorMessage>
<FormErrorMessage>Tag name is required.</FormErrorMessage>
</FormControl>
</Col>
</Row>
Expand Down
5 changes: 1 addition & 4 deletions frontend/src/types/TagTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,4 @@ export type CountTagsResponse = {
numResults: number;
} | null;

export type CreateTagParams = Omit<
Tag,
"tagId"
>
export type CreateTagParams = Omit<Tag, "tagId">;

0 comments on commit 8bc26f9

Please sign in to comment.