fix(notes): guard mobile review actions

This commit is contained in:
saravanakumardb1 2026-03-10 16:59:40 -07:00
parent e1b9e95ec0
commit 7a8009454f

View File

@ -1,4 +1,4 @@
import { useEffect } from 'react';
import { useEffect, useState } from 'react';
import { Pressable, StyleSheet, Text, View } from 'react-native';
import { useInboxStore, type ActivityItem, type ApprovalItem, type InboxState } from '../../store/inbox-store';
import { colors } from '../../theme';
@ -10,6 +10,7 @@ export default function InboxScreen() {
const hydrate = useInboxStore((state: InboxState) => state.hydrate);
const approve = useInboxStore((state: InboxState) => state.approve);
const reject = useInboxStore((state: InboxState) => state.reject);
const [pendingApprovalId, setPendingApprovalId] = useState<string | null>(null);
useEffect(() => {
void hydrate();
@ -26,11 +27,43 @@ export default function InboxScreen() {
<Text style={styles.cardBody}>{item.summary}</Text>
<Text style={styles.status}>Status: {item.status}</Text>
<View style={styles.actionRow}>
<Pressable style={styles.approveButton} onPress={() => void approve(item.id)}>
<Text style={styles.approveText}>Approve</Text>
<Pressable
style={[
styles.approveButton,
pendingApprovalId === item.id || item.status !== 'pending' ? styles.buttonDisabled : null,
]}
disabled={pendingApprovalId === item.id || item.status !== 'pending'}
onPress={async () => {
setPendingApprovalId(item.id);
try {
await approve(item.id);
} finally {
setPendingApprovalId(null);
}
}}
>
<Text style={styles.approveText}>
{pendingApprovalId === item.id ? 'Approving…' : 'Approve'}
</Text>
</Pressable>
<Pressable style={styles.rejectButton} onPress={() => void reject(item.id)}>
<Text style={styles.rejectText}>Reject</Text>
<Pressable
style={[
styles.rejectButton,
pendingApprovalId === item.id || item.status !== 'pending' ? styles.buttonDisabled : null,
]}
disabled={pendingApprovalId === item.id || item.status !== 'pending'}
onPress={async () => {
setPendingApprovalId(item.id);
try {
await reject(item.id);
} finally {
setPendingApprovalId(null);
}
}}
>
<Text style={styles.rejectText}>
{pendingApprovalId === item.id ? 'Rejecting…' : 'Reject'}
</Text>
</Pressable>
</View>
</View>
@ -102,6 +135,9 @@ const styles = StyleSheet.create({
flexDirection: 'row',
gap: 10,
},
buttonDisabled: {
opacity: 0.6,
},
approveButton: {
backgroundColor: colors.accentPrimary,
borderRadius: 10,