Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace input field with select field #889

Merged
merged 1 commit into from
Nov 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,12 @@
}

.select {
width: 100%;
width: 50%;
margin: 2rem 0;
}

.input {
margin-bottom: 2rem;
&WithMargin {
margin-bottom: 2rem;
margin-top: 2rem;
}
}
.colorHeader {
color: #6ea2bb;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import SingleSelect from "../../../../Components/SingleSelect/SingleSelect";
import { InboxOutlined } from "@ant-design/icons";
import { uploadImage } from "../../../../Services/image";
import { createAchievement } from "../../../../Services/achievement";
import { getGames } from "../../../../Services/games";

function CreateAchievement() {
const ACHIEVEMENT_TYPES = ["GAME", "META"];
Expand All @@ -28,10 +29,16 @@ function CreateAchievement() {
},
});

const onChange = (_filterKey: string, value: string[] | string) => {
const { data: games } = useQuery(["games"], () => getGames());

const onChangeType = (_filterKey: string, value: string) => {
setType(value as string);
};

const onChangeGame = (_filterKey: string, value: string) => {
setGame(value as string);
};

const uploadImageMutation = useMutation(uploadImage, {
onError: () => {
alert("We cannot upload the image");
Expand Down Expand Up @@ -93,7 +100,7 @@ function CreateAchievement() {
filterKey="type"
elements={ACHIEVEMENT_TYPES}
reset={false}
onChange={onChange}
onChange={onChangeType}
></SingleSelect>

<h4 className={styles.colorHeader}>Achievement Icon</h4>
Expand All @@ -112,12 +119,14 @@ function CreateAchievement() {
<p className="ant-upload-hint">You can only upload one image file.</p>
</Dragger>

<Input
placeholder="Game"
value={game}
className={styles.inputWithMargin}
onChange={(event) => setGame(event.target.value)}
/>
<SingleSelect
className={styles.select}
title="Game"
elements={games.map((game) => game.gameName)}
onChange={onChangeGame}
reset={false}
></SingleSelect>
<br></br>

<Button className={styles.filterButton} onClick={handleClick}>
Create Achievement
Expand Down