@@ -34,6 +34,7 @@ export interface Props { | |||||
} | } | ||||
const UserAllocation: React.FC<Props> = ({ users }) => { | const UserAllocation: React.FC<Props> = ({ users }) => { | ||||
console.log(users) | |||||
const { t } = useTranslation(); | const { t } = useTranslation(); | ||||
const { | const { | ||||
setValue, | setValue, | ||||
@@ -42,7 +43,7 @@ const UserAllocation: React.FC<Props> = ({ users }) => { | |||||
reset, | reset, | ||||
resetField, | resetField, | ||||
} = useFormContext<CreateGroupInputs>(); | } = useFormContext<CreateGroupInputs>(); | ||||
const initialUsers = users.map((u) => ({ ...u })).sort((a, b) => a.id - b.id).filter((u) => u.groupId !== null); | |||||
const initialUsers = users.map((u) => ({ ...u })).sort((a, b) => a.id - b.id).filter((u) => u.groupId === null); | |||||
const [filteredUsers, setFilteredUsers] = useState(initialUsers); | const [filteredUsers, setFilteredUsers] = useState(initialUsers); | ||||
const [selectedUsers, setSelectedUsers] = useState<typeof filteredUsers>( | const [selectedUsers, setSelectedUsers] = useState<typeof filteredUsers>( | ||||
() => { | () => { | ||||
@@ -96,9 +96,6 @@ const CreateStaff: React.FC<formProps> = ({ combos }) => { | |||||
if (data.phone2!.length > 0) { | if (data.phone2!.length > 0) { | ||||
formProps.setError("phone2", { message: t("Please Enter Different Phone No.."), type: "required" }) | formProps.setError("phone2", { message: t("Please Enter Different Phone No.."), type: "required" }) | ||||
} | } | ||||
console.log(data.phone1) | |||||
console.log(data.emergContactPhone) | |||||
console.log(data.phone1 === data.emergContactPhone) | |||||
formProps.setError("emergContactPhone", { message: t("Please Enter Different Phone No.."), type: "required" }) | formProps.setError("emergContactPhone", { message: t("Please Enter Different Phone No.."), type: "required" }) | ||||
} | } | ||||
if (!regex_email.test(data.email)) { | if (!regex_email.test(data.email)) { | ||||
@@ -26,6 +26,8 @@ interface Props { | |||||
const EditTeam: React.FC<Props> = async ({ staff, teamInfo }) => { | const EditTeam: React.FC<Props> = async ({ staff, teamInfo }) => { | ||||
const { team, staffIds } = teamInfo; | const { team, staffIds } = teamInfo; | ||||
console.log(team.name) | |||||
// console.log(staffIds) | |||||
const { t } = useTranslation(); | const { t } = useTranslation(); | ||||
const formProps = useForm<CreateTeamInputs>(); | const formProps = useForm<CreateTeamInputs>(); | ||||
const searchParams = useSearchParams(); | const searchParams = useSearchParams(); | ||||
@@ -137,13 +137,13 @@ const EditUserGroup: React.FC<Props> = ({ users, auths, group }) => { | |||||
{tabIndex === 1 && <AuthorityAllocation auth={auths!!}/>} | {tabIndex === 1 && <AuthorityAllocation auth={auths!!}/>} | ||||
{tabIndex === 2 && <UserAllocation users={users!!} />} | {tabIndex === 2 && <UserAllocation users={users!!} />} | ||||
<Stack direction="row" justifyContent="flex-end" gap={1}> | <Stack direction="row" justifyContent="flex-end" gap={1}> | ||||
<Button | |||||
{/* <Button | |||||
variant="text" | variant="text" | ||||
startIcon={<RestartAlt />} | startIcon={<RestartAlt />} | ||||
onClick={resetGroup} | onClick={resetGroup} | ||||
> | > | ||||
{t("Reset")} | {t("Reset")} | ||||
</Button> | |||||
</Button> */} | |||||
<Button | <Button | ||||
variant="outlined" | variant="outlined" | ||||
startIcon={<Close />} | startIcon={<Close />} | ||||
@@ -13,14 +13,14 @@ import { deleteUser } from "@/app/api/user/actions"; | |||||
import { deleteGroup } from "@/app/api/group/actions"; | import { deleteGroup } from "@/app/api/group/actions"; | ||||
interface Props { | interface Props { | ||||
users: UserGroupResult[]; | |||||
groups: UserGroupResult[]; | |||||
} | } | ||||
type SearchQuery = Partial<Omit<UserGroupResult, "id">>; | type SearchQuery = Partial<Omit<UserGroupResult, "id">>; | ||||
type SearchParamNames = keyof SearchQuery; | type SearchParamNames = keyof SearchQuery; | ||||
const UserGroupSearch: React.FC<Props> = ({ users }) => { | |||||
const UserGroupSearch: React.FC<Props> = ({ groups }) => { | |||||
const { t } = useTranslation(); | const { t } = useTranslation(); | ||||
const [filteredUser, setFilteredUser] = useState(users); | |||||
const [filteredGroups, setFilteredGroups] = useState(groups); | |||||
const router = useRouter(); | const router = useRouter(); | ||||
const searchCriteria: Criterion<SearchParamNames>[] = useMemo( | const searchCriteria: Criterion<SearchParamNames>[] = useMemo( | ||||
@@ -51,6 +51,8 @@ const UserGroupSearch: React.FC<Props> = ({ users }) => { | |||||
deleteDialog(async () => { | deleteDialog(async () => { | ||||
await deleteGroup(group.id); | await deleteGroup(group.id); | ||||
successDialog(t("Delete Success"), t); | successDialog(t("Delete Success"), t); | ||||
setFilteredGroups((prev) => prev.filter((obj) => obj.id !== group.id)); | |||||
}, t); | }, t); | ||||
}, []); | }, []); | ||||
@@ -80,8 +82,8 @@ const UserGroupSearch: React.FC<Props> = ({ users }) => { | |||||
<SearchBox | <SearchBox | ||||
criteria={searchCriteria} | criteria={searchCriteria} | ||||
onSearch={(query) => { | onSearch={(query) => { | ||||
setFilteredUser( | |||||
users.filter( | |||||
setFilteredGroups( | |||||
groups.filter( | |||||
(u) => | (u) => | ||||
u.name.toLowerCase().includes(query.name.toLowerCase()) && | u.name.toLowerCase().includes(query.name.toLowerCase()) && | ||||
u.description.toLowerCase().includes(query.description.toLowerCase()) | u.description.toLowerCase().includes(query.description.toLowerCase()) | ||||
@@ -89,7 +91,7 @@ const UserGroupSearch: React.FC<Props> = ({ users }) => { | |||||
) | ) | ||||
}} | }} | ||||
/> | /> | ||||
<SearchResults<UserGroupResult> items={filteredUser} columns={columns} /> | |||||
<SearchResults<UserGroupResult> items={filteredGroups} columns={columns} /> | |||||
</> | </> | ||||
); | ); | ||||
}; | }; | ||||
@@ -9,9 +9,8 @@ interface SubComponents { | |||||
const UserGroupSearchWrapper: React.FC & SubComponents = async () => { | const UserGroupSearchWrapper: React.FC & SubComponents = async () => { | ||||
const group = await fetchGroup() | const group = await fetchGroup() | ||||
console.log(group.records); | |||||
return <UserGroupSearch users={group.records} />; | |||||
return <UserGroupSearch groups={group.records} />; | |||||
}; | }; | ||||
UserGroupSearchWrapper.Loading = UserGroupSearchLoading; | UserGroupSearchWrapper.Loading = UserGroupSearchLoading; | ||||
@@ -0,0 +1,25 @@ | |||||
{ | |||||
"Team": "Team", | |||||
"Team Info": "Team Info", | |||||
"Staff Allocation": "Staff Allocation", | |||||
"Create Team": "Create Team", | |||||
"Edit Team": "Edit Team", | |||||
"name": "Name", | |||||
"code": "Code", | |||||
"description": "Description", | |||||
"Team Description": "Team Description", | |||||
"edit": "edit", | |||||
"teamLead": "teamLead", | |||||
"Confirm": "Confirm", | |||||
"Cancel": "Cancel", | |||||
"delete": "delete", | |||||
"add": "add", | |||||
"remove": "remove", | |||||
"Staff Pool": "Staff Pool", | |||||
"Allocated Staff": "Allocated Staff", | |||||
"Staff Id": "Staff Id", | |||||
"Staff Name": "Staff Name", | |||||
"Position": "Position", | |||||
"Search by Staff Id, Name or Position.": "Search by Staff Id, Name or Position.", | |||||
"An error has occurred. Please try again later.": "An error has occurred. Please try again later" | |||||
} |