#600 quick search for resource calendar (#635)

Co-authored-by: lethemanh <lethemanh@lethemanhs-MacBook-Pro.local>
This commit is contained in:
lethemanh
2026-03-17 22:10:36 +07:00
committed by GitHub
parent 387e64d58c
commit 7d21eab757
9 changed files with 192 additions and 69 deletions
+10 -2
View File
@@ -25,6 +25,7 @@ import {
type SyntheticEvent,
} from "react";
import { useI18n } from "twake-i18n";
import { ResourceIcon } from "./ResourceIcon";
export interface User {
email: string;
@@ -289,14 +290,21 @@ export function PeopleSearch({
renderOption={(props, option) => {
if (selectedUsers.find((u) => u.email === option.email)) return null;
const { key, ...otherProps } = props;
const isResource = option.objectType === "resource";
return (
<ListItem key={key + option?.email} {...otherProps} disableGutters>
<ListItemAvatar>
<Avatar {...stringAvatar(option.displayName || option.email)} />
{isResource ? (
<ResourceIcon displayName={option.displayName} />
) : (
<Avatar
{...stringAvatar(option.displayName || option.email)}
/>
)}
</ListItemAvatar>
<ListItemText
primary={option.displayName}
secondary={option.email}
secondary={isResource ? "" : option.email}
slotProps={{
primary: { variant: "body2" },
secondary: { variant: "caption" },
@@ -283,7 +283,7 @@ export default function CalendarResources({
cal,
owner: user,
}))
: { cal: undefined, owner: user };
: [{ cal: undefined, owner: user }];
}
return null;
})
@@ -81,7 +81,7 @@ export function TempCalendarsInput({
return (
<PeopleSearch
objectTypes={["user"]}
objectTypes={["user", "resource"]}
selectedUsers={tempUsers}
onChange={handleUserChange}
onToggleEventPreview={handleToggleEventPreview}