Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion apps/mobile/src/features/chats/KinLevelsScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { ScreenScrollView } from "../../components/ui/ScreenScrollView";
import { appAtomRegistry } from "../../state/atom-registry";
import { useAtomCommand } from "../../state/use-atom-command";
import { kinClient } from "./state/kinClient";
import { KinApprovalCard } from "./widgets/KinApprovalCard";
import { kinChatTitle, kinDirectory } from "@t3tools/client-runtime/kin/kinScreenState";
import { useKinHostAt } from "./state/useKinHost";
import {
Expand Down Expand Up @@ -170,7 +171,7 @@ function KinLevelsBody(props: {
text:
change.kind === "lower"
? `Lowered to ${change.level}.`
: `Raise to ${change.level} requested. It applies once you sign the approval.`,
: `Raise to ${change.level} requested. Approve it below with Face ID.`,
error: false,
});
};
Expand Down Expand Up @@ -272,6 +273,16 @@ function KinLevelsBody(props: {
))}
</View>
)}
{result.value.pendingRaises
.filter((raise) => raise.state === "awaiting_approval")
.map((raise) => (
<KinApprovalCard
key={raise.actionId}
environmentId={environmentId}
actionId={raise.actionId}
revision={0}
/>
))}
{view.chats.length === 0 ? null : (
<View className="gap-3">
<Text textRole="footnote" className="px-1 font-t3-medium text-foreground-secondary">
Expand Down
77 changes: 56 additions & 21 deletions apps/mobile/src/features/chats/KinWaitingScreen.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { useNavigation } from "@react-navigation/native";
import { kinApprovalActionIdOf } from "@t3tools/contracts";
import { View } from "react-native";

import { Button } from "../../components/ui/Button";
import { EmptyState } from "../../components/ui/EmptyState";
import { ListRow } from "../../components/ui/ListRow";
import { ListSection } from "../../components/ui/ListSection";
Expand All @@ -11,8 +14,9 @@ import {
kinWaitingRowView,
} from "@t3tools/client-runtime/kin/kinScreenState";
import { useKinInbox } from "./state/useKinInbox";
import { KinApprovalCard } from "./widgets/KinApprovalCard";

/** Placeholder Waiting on you until the native cards land: one row per item, oldest first. */
/** Waiting on you, oldest first: approvals as their full cards, everything else as a row. */
export function KinWaitingScreen() {
const navigation = useNavigation();
const { host, state, retry } = useKinInbox();
Expand All @@ -30,28 +34,59 @@ export function KinWaitingScreen() {
/>
);
}
const openChat = (item: (typeof view.waiting)[number]) =>
navigation.navigate("KinChat", {
environmentId: ready.environmentId,
orgId: item.orgId,
chatId: item.chatId,
});
const approvals = view.waiting.flatMap((item) => {
const actionId =
item.reason === "approval" && item.widgetId !== null
? kinApprovalActionIdOf(item.widgetId)
: null;
return actionId === null ? [] : [{ item, actionId }];
});
const rest = view.waiting.filter(
(item) => !approvals.some((approval) => approval.item.waitingId === item.waitingId),
);
return (
<ListSection>
{view.waiting.map((item) => {
const row = kinWaitingRowView(item, ready.inbox.value.chats, agentNames);
return (
<ListRow
key={item.waitingId}
icon="exclamationmark.circle"
label={`${row.label} · ${row.chatTitle}`}
description={row.text ?? `Open the chat with ${row.chatTitle}`}
detail={formatKinTime(new Date(row.createdAt))}
onPress={() =>
navigation.navigate("KinChat", {
environmentId: ready.environmentId,
orgId: item.orgId,
chatId: item.chatId,
})
}
<>
{approvals.map(({ item, actionId }) => (
<View key={item.waitingId} className="gap-1">
<KinApprovalCard
environmentId={ready.environmentId}
actionId={actionId}
revision={0}
/>
);
})}
</ListSection>
<View className="flex-row">
<Button
tone="text"
size="compact"
label="Open in chat"
onPress={() => openChat(item)}
/>
</View>
</View>
))}
{rest.length === 0 ? null : (
<ListSection>
{rest.map((item) => {
const row = kinWaitingRowView(item, ready.inbox.value.chats, agentNames);
return (
<ListRow
key={item.waitingId}
icon="exclamationmark.circle"
label={`${row.label} · ${row.chatTitle}`}
description={row.text ?? `Open the chat with ${row.chatTitle}`}
detail={formatKinTime(new Date(row.createdAt))}
onPress={() => openChat(item)}
/>
);
})}
</ListSection>
)}
</>
);
}}
</KinInboxPage>
Expand Down
Loading