fix(notes): guard mobile review actions
This commit is contained in:
parent
e1b9e95ec0
commit
7a8009454f
@ -1,4 +1,4 @@
|
|||||||
import { useEffect } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
import { Pressable, StyleSheet, Text, View } from 'react-native';
|
import { Pressable, StyleSheet, Text, View } from 'react-native';
|
||||||
import { useInboxStore, type ActivityItem, type ApprovalItem, type InboxState } from '../../store/inbox-store';
|
import { useInboxStore, type ActivityItem, type ApprovalItem, type InboxState } from '../../store/inbox-store';
|
||||||
import { colors } from '../../theme';
|
import { colors } from '../../theme';
|
||||||
@ -10,6 +10,7 @@ export default function InboxScreen() {
|
|||||||
const hydrate = useInboxStore((state: InboxState) => state.hydrate);
|
const hydrate = useInboxStore((state: InboxState) => state.hydrate);
|
||||||
const approve = useInboxStore((state: InboxState) => state.approve);
|
const approve = useInboxStore((state: InboxState) => state.approve);
|
||||||
const reject = useInboxStore((state: InboxState) => state.reject);
|
const reject = useInboxStore((state: InboxState) => state.reject);
|
||||||
|
const [pendingApprovalId, setPendingApprovalId] = useState<string | null>(null);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
void hydrate();
|
void hydrate();
|
||||||
@ -26,11 +27,43 @@ export default function InboxScreen() {
|
|||||||
<Text style={styles.cardBody}>{item.summary}</Text>
|
<Text style={styles.cardBody}>{item.summary}</Text>
|
||||||
<Text style={styles.status}>Status: {item.status}</Text>
|
<Text style={styles.status}>Status: {item.status}</Text>
|
||||||
<View style={styles.actionRow}>
|
<View style={styles.actionRow}>
|
||||||
<Pressable style={styles.approveButton} onPress={() => void approve(item.id)}>
|
<Pressable
|
||||||
<Text style={styles.approveText}>Approve</Text>
|
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>
|
||||||
<Pressable style={styles.rejectButton} onPress={() => void reject(item.id)}>
|
<Pressable
|
||||||
<Text style={styles.rejectText}>Reject</Text>
|
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>
|
</Pressable>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
@ -102,6 +135,9 @@ const styles = StyleSheet.create({
|
|||||||
flexDirection: 'row',
|
flexDirection: 'row',
|
||||||
gap: 10,
|
gap: 10,
|
||||||
},
|
},
|
||||||
|
buttonDisabled: {
|
||||||
|
opacity: 0.6,
|
||||||
|
},
|
||||||
approveButton: {
|
approveButton: {
|
||||||
backgroundColor: colors.accentPrimary,
|
backgroundColor: colors.accentPrimary,
|
||||||
borderRadius: 10,
|
borderRadius: 10,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user