initial commit
This commit is contained in:
@@ -68,7 +68,7 @@ export const DeleteTodoModal = ({
|
||||
{error && <Text className="text-highRisk mt-2">{error}</Text>}
|
||||
</Dialog.Content>
|
||||
<Dialog.Actions>
|
||||
<Button className="!ml-2" onPress={handleDelete} disabled={isLoading}>
|
||||
<Button className="ml-2!" onPress={handleDelete} disabled={isLoading}>
|
||||
Delete
|
||||
</Button>
|
||||
</Dialog.Actions>
|
||||
|
||||
@@ -48,14 +48,14 @@ export const DesktopAdminTodosTable = ({
|
||||
{todos.map((todo) => (
|
||||
<DataTable.Row key={todo.id}>
|
||||
<DataTable.Cell>
|
||||
<View className="flex-row items-center flex-shrink px-1 py-1">
|
||||
<View className="flex-row items-center shrink px-1 py-1">
|
||||
<Text onPress={() => openDetails(todo)} numberOfLines={10}>
|
||||
{todo.title}
|
||||
</Text>
|
||||
</View>
|
||||
</DataTable.Cell>
|
||||
<DataTable.Cell>
|
||||
<View className="flex-row items-center flex-shrink px-1 py-1">
|
||||
<View className="flex-row items-center shrink px-1 py-1">
|
||||
<Text numberOfLines={10}>
|
||||
{todo.task && todo.task.length > 50
|
||||
? `${todo.task.slice(0, 50)}...`
|
||||
@@ -79,7 +79,7 @@ export const DesktopAdminTodosTable = ({
|
||||
</DataTable.Cell>
|
||||
<DataTable.Cell style={{ justifyContent: "center" }}>
|
||||
<Text className="px-1 py-1">{`${formatDateMDY(
|
||||
todo.createdAt
|
||||
todo.createdAt,
|
||||
)} ${formatTime(todo.createdAt)}`}</Text>
|
||||
</DataTable.Cell>
|
||||
<DataTable.Cell style={{ justifyContent: "center" }}>
|
||||
|
||||
@@ -32,7 +32,7 @@ interface TodoModalProps {
|
||||
visible: boolean;
|
||||
onClose: () => void;
|
||||
onSubmit: (
|
||||
todo: Partial<Todo> & { assigneeIds?: string[]; userId?: string }
|
||||
todo: Partial<Todo> & { assigneeIds?: string[]; userId?: string },
|
||||
) => void;
|
||||
isLoading: boolean;
|
||||
todo?: Todo | null;
|
||||
@@ -51,9 +51,11 @@ export const TodoModal = ({
|
||||
todoRef.current = todo;
|
||||
// Helpers to extract existing selections from the todo
|
||||
const existingSupervisors = (todo?.assignees ?? []).filter(
|
||||
(u) => u.role === RoleEnum.ADMIN || u.role === RoleEnum.MANAGER
|
||||
(u) => u.role === RoleEnum.ADMIN || u.role === RoleEnum.MANAGER,
|
||||
);
|
||||
const existingUser = (todo?.assignees ?? []).find(
|
||||
(u) => u.role === RoleEnum.USER,
|
||||
);
|
||||
const existingUser = (todo?.assignees ?? []).find((u) => u.role === RoleEnum.USER);
|
||||
const defaultValues: TodoFormValues = {
|
||||
id: todo?.id,
|
||||
title: todo?.title ?? "",
|
||||
@@ -126,10 +128,12 @@ export const TodoModal = ({
|
||||
sortDir: "asc" as any,
|
||||
search: adminSearchQuery.trim(),
|
||||
},
|
||||
{ skip: !visible || adminSearchQuery.trim().length < 2 }
|
||||
{ skip: !visible || adminSearchQuery.trim().length < 2 },
|
||||
);
|
||||
const adminUsers = adminUsersPage?.items ?? [];
|
||||
const preselectedSupervisorItems = existingSupervisors.map(mapUserToDropdownItem);
|
||||
const preselectedSupervisorItems = existingSupervisors.map(
|
||||
mapUserToDropdownItem,
|
||||
);
|
||||
const adminDropdownItems = uniqueById([
|
||||
...preselectedSupervisorItems,
|
||||
...adminUsers.map(mapUserToDropdownItem),
|
||||
@@ -146,10 +150,12 @@ export const TodoModal = ({
|
||||
sortDir: "asc" as any,
|
||||
search: userSearchQuery.trim(),
|
||||
},
|
||||
{ skip: !visible || userSearchQuery.trim().length < 2 }
|
||||
{ skip: !visible || userSearchQuery.trim().length < 2 },
|
||||
);
|
||||
const regularUsers = regularUsersPage?.items ?? [];
|
||||
const preselectedUserItems = existingUser ? [mapUserToDropdownItem(existingUser)] : [];
|
||||
const preselectedUserItems = existingUser
|
||||
? [mapUserToDropdownItem(existingUser)]
|
||||
: [];
|
||||
const regularUserDropdownItems = uniqueById([
|
||||
...preselectedUserItems,
|
||||
...regularUsers.map(mapUserToDropdownItem),
|
||||
@@ -173,7 +179,7 @@ export const TodoModal = ({
|
||||
if (!visible) return;
|
||||
const t = todoRef.current;
|
||||
const admins = (t?.assignees ?? []).filter(
|
||||
(u) => u.role === RoleEnum.ADMIN || u.role === RoleEnum.MANAGER
|
||||
(u) => u.role === RoleEnum.ADMIN || u.role === RoleEnum.MANAGER,
|
||||
);
|
||||
const user = (t?.assignees ?? []).find((u) => u.role === RoleEnum.USER);
|
||||
const nextDefaults: TodoFormValues = {
|
||||
@@ -452,7 +458,7 @@ export const TodoModal = ({
|
||||
<Button
|
||||
onPress={handleSubmit(submit)}
|
||||
disabled={isLoading || !isValid || !isDirty}
|
||||
className="!ml-2"
|
||||
className="ml-2!"
|
||||
>
|
||||
{mode === OperationMode.ADD ? "Add" : "Edit"}
|
||||
</Button>
|
||||
|
||||
Reference in New Issue
Block a user