Updated input validation
This commit is contained in:
@@ -17,7 +17,7 @@ export default function RaidGroupCreateAndSearch({
|
||||
|
||||
return (
|
||||
<div
|
||||
className="flex flex-row justify-between items-center w-full"
|
||||
className="flex flex-row justify-between items-center w-full mb-8"
|
||||
>
|
||||
<div
|
||||
className="flex flex-row items-center justify-start w-full"
|
||||
@@ -29,7 +29,6 @@ export default function RaidGroupCreateAndSearch({
|
||||
className="flex flex-row items-center justify-center w-full"
|
||||
>
|
||||
<PrimaryButton
|
||||
className="mb-8"
|
||||
onClick={() => setDisplayRaidGroupModal(true)}
|
||||
>
|
||||
Create Raid Group
|
||||
|
||||
@@ -2,7 +2,7 @@ import { ButtonProps } from "@/components/button/Button";
|
||||
import Table from "@/components/table/Table";
|
||||
import { RaidGroup } from "@/interface/RaidGroup";
|
||||
import { useAuth } from "@/providers/AuthProvider";
|
||||
import { containsRaidGroupPermission, containsRaidGroupRequest, isRaidGroupAdmin } from "@/util/PermissionUtil";
|
||||
import { containsRaidGroupRequest, isRaidGroupAdmin, isRaidGroupMember } from "@/util/PermissionUtil";
|
||||
import { useState } from "react";
|
||||
import { Link } from "react-router";
|
||||
import RaidGroupRequestModal from "../raidGroupRequest/modal/RaidGroupRequestModal";
|
||||
@@ -90,7 +90,7 @@ export default function RaidGroupsList({
|
||||
setSelectedRaidGroup(raidGroup);
|
||||
setDisplayDeleteRaidGroupModal(true);
|
||||
}}
|
||||
hasRaidGroupPermissions={containsRaidGroupPermission(raidGroup.raidGroupId ?? "", raidGroupPermissions, accountPermissions)}
|
||||
hasRaidGroupPermissions={isRaidGroupMember(raidGroup.raidGroupId ?? "", raidGroupPermissions, accountPermissions)}
|
||||
hasRaidGroupRequest={containsRaidGroupRequest(raidGroup.raidGroupId ?? "", raidGroupRequests)}
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -31,6 +31,7 @@ export default function RaidGroupModal({
|
||||
useEffect(() => {
|
||||
setRaidGroupName(raidGroup?.raidGroupName ?? "");
|
||||
setRaidGroupIcon(raidGroup?.raidGroupIcon ?? "");
|
||||
setGame(undefined);
|
||||
setIconFile(null);
|
||||
}, [ display, raidGroup, setRaidGroupName, setRaidGroupIcon ]);
|
||||
|
||||
@@ -69,10 +70,30 @@ export default function RaidGroupModal({
|
||||
|
||||
|
||||
const updateRaidGroup = () => {
|
||||
if(!raidGroup?.raidGroupId || raidGroup.raidGroupId.trim().length <= 0){
|
||||
addErrorMessage("Raid group ID not found");
|
||||
return;
|
||||
}
|
||||
else if(!raidGroupName || raidGroupName.trim().length <= 0){
|
||||
addErrorMessage("Raid group name is required");
|
||||
return;
|
||||
}
|
||||
else if(!game){
|
||||
addErrorMessage("Game is required");
|
||||
return;
|
||||
}
|
||||
updateRaidGroupMutate.mutate({raidGroup: {raidGroupId: raidGroup?.raidGroupId, raidGroupName, gameId: game?.gameId, raidGroupIcon} as RaidGroup, iconFile});
|
||||
}
|
||||
|
||||
const createRaidGroup = () => {
|
||||
if(!raidGroupName || raidGroupName.trim().length <= 0){
|
||||
addErrorMessage("Raid group name is required");
|
||||
return;
|
||||
}
|
||||
else if(!game){
|
||||
addErrorMessage("Game is required");
|
||||
return;
|
||||
}
|
||||
createRaidGroupMutate.mutate({raidGroupName: raidGroupName ?? "", gameId: game?.gameId ?? "", iconFile});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user