Skip to content

Commit

Permalink
Fix: selected role in dropdown
Browse files Browse the repository at this point in the history
  • Loading branch information
Akalanka47000 committed Sep 15, 2024
1 parent 6220cfa commit 2ce4766
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/components/users/dialog.jsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { useState } from "react";
import { useSelector } from "react-redux";
import { store } from "@/store";
import { useAddUserMutation } from "@/store/api";
Expand All @@ -21,6 +22,8 @@ const UserDialog = ({ refresh }) => {

const [addUser, { isLoading }] = useAddUserMutation();

const [role, setRole] = useState();

const handleSubmit = async (e) => {
e.preventDefault();
await addUser({
Expand All @@ -30,7 +33,7 @@ const UserDialog = ({ refresh }) => {
})
.unwrap()
.then(() => {
toast({ title: `Admin user added successfully` });
toast({ title: `User added successfully` });
close();
refresh();
});
Expand Down Expand Up @@ -58,6 +61,8 @@ const UserDialog = ({ refresh }) => {
{ key: "Admin", label: "ADMIN" },
{ key: "Spectator", label: "SPECTATOR" }
]}
value={role}
onChange={(e) => setRole(e.target.value)}
/>
<AlertDialogFooter className="mt-4">
<Button type="submit" loading={isLoading}>
Expand Down

0 comments on commit 2ce4766

Please sign in to comment.