Phase 3.3 — Session Topic Sensitivity (complete): - Backend: topic_sensitivity column + session_sensitivity_log, sensitivity service (flip with one-way-latch + audit), PATCH /api/shared/chat/sessions/:id/topic, topic carried in pairing + extension WS payloads, CC filter + sensitive stats + per-mitra sensitive columns on activity page - client_app: TopicSelectionBottomSheet before pricing, topic flows through pairing request, silent WS handler for session_topic_updated - mitra_app: SensitivityBadge + SensitivityTheme + sensitivityConfigProvider, overlay badge + yellow accent, chat screen app-bar toggle with configurable confirmation + latch, extension card shows current flag, history + transcript yellow theme - control_center: Sensitivitas Topik settings section, topic filter + column with inline audit log, sensitive stats dashboard card, mitra activity sensitive columns with QC flag Phase 3.4 — Self-Managed Auth (foundation only): - Migration: auth_sessions + otp_requests tables, social identity columns on customers, password_hash + lockout on control_center_users, OTP + CC lockout app_config keys - New services: password (bcrypt + complexity), token (JWT HS256 + refresh rotation, session_id claim pre-wires future Valkey revocation), social-identity (Google + Apple JWKS), OTP (Fazpass stub — real API TBD) - Constants: AuthProvider + OtpChannel - Middleware, auth route rewrites, WS auth update, Firebase → FCM isolation still pending (next chunk); Fazpass docs + Apple Developer setup still required before E2E testing Docs: - requirement/phase3.3.md, phase3.3-plan.md, phase3.3-testing.md - requirement/phase3.4.md, phase3.4-plan.md Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
114 lines
4.5 KiB
Dart
114 lines
4.5 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
import '../../../core/api/api_client_provider.dart';
|
|
import '../../../core/chat/widgets/sensitivity_badge.dart';
|
|
import '../../../core/chat/widgets/sensitivity_theme.dart';
|
|
import '../../../core/constants.dart';
|
|
|
|
class MitraChatTranscriptScreen extends ConsumerStatefulWidget {
|
|
final String sessionId;
|
|
|
|
const MitraChatTranscriptScreen({super.key, required this.sessionId});
|
|
|
|
@override
|
|
ConsumerState<MitraChatTranscriptScreen> createState() => _MitraChatTranscriptScreenState();
|
|
}
|
|
|
|
class _MitraChatTranscriptScreenState extends ConsumerState<MitraChatTranscriptScreen> {
|
|
List<Map<String, dynamic>> _messages = [];
|
|
List<Map<String, dynamic>> _closures = [];
|
|
TopicSensitivity _topicSensitivity = TopicSensitivity.regular;
|
|
bool _loading = true;
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
_loadTranscript();
|
|
}
|
|
|
|
Future<void> _loadTranscript() async {
|
|
try {
|
|
final api = ref.read(apiClientProvider);
|
|
final results = await Future.wait([
|
|
api.get('/api/shared/chat/${widget.sessionId}/transcript'),
|
|
api.get('/api/shared/chat/${widget.sessionId}/info'),
|
|
]);
|
|
final data = results[0]['data'] as Map<String, dynamic>;
|
|
final info = results[1]['data'] as Map<String, dynamic>?;
|
|
setState(() {
|
|
_messages = (data['messages'] as List<dynamic>).cast<Map<String, dynamic>>();
|
|
_closures = (data['closures'] as List<dynamic>).cast<Map<String, dynamic>>();
|
|
_topicSensitivity = TopicSensitivity.fromString(info?['topic_sensitivity'] as String?);
|
|
_loading = false;
|
|
});
|
|
} catch (_) {
|
|
setState(() => _loading = false);
|
|
}
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final isSensitive = _topicSensitivity == TopicSensitivity.sensitive;
|
|
return Scaffold(
|
|
backgroundColor: isSensitive ? SensitivityTheme.sensitive.bgTint : null,
|
|
appBar: AppBar(
|
|
title: Row(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
const Text('Transkrip Chat'),
|
|
if (isSensitive) ...[
|
|
const SizedBox(width: 8),
|
|
SensitivityBadge(sensitivity: _topicSensitivity, fontSize: 11),
|
|
],
|
|
],
|
|
),
|
|
),
|
|
body: _loading
|
|
? const Center(child: CircularProgressIndicator())
|
|
: ListView(
|
|
padding: const EdgeInsets.all(16),
|
|
children: [
|
|
..._messages.map((m) {
|
|
final isMe = m['sender_type'] == UserType.mitra;
|
|
final time = DateTime.parse(m['created_at'] as String).toLocal();
|
|
return Align(
|
|
alignment: isMe ? Alignment.centerRight : Alignment.centerLeft,
|
|
child: Container(
|
|
margin: const EdgeInsets.symmetric(vertical: 4),
|
|
padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 10),
|
|
constraints: BoxConstraints(maxWidth: MediaQuery.of(context).size.width * 0.75),
|
|
decoration: BoxDecoration(
|
|
color: isMe ? Colors.green.shade100 : Colors.grey.shade200,
|
|
borderRadius: BorderRadius.circular(16),
|
|
),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.end,
|
|
children: [
|
|
Text(m['content'] as String, style: const TextStyle(fontSize: 15)),
|
|
const SizedBox(height: 4),
|
|
Text(
|
|
'${time.hour.toString().padLeft(2, '0')}:${time.minute.toString().padLeft(2, '0')}',
|
|
style: const TextStyle(fontSize: 10, color: Colors.grey),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}),
|
|
if (_closures.isNotEmpty) ...[
|
|
const Divider(height: 32),
|
|
const Text('Pesan Penutup', style: TextStyle(fontWeight: FontWeight.bold, fontSize: 16)),
|
|
const SizedBox(height: 8),
|
|
..._closures.map((c) => Card(
|
|
child: ListTile(
|
|
title: Text(c['user_type'] == UserType.mitra ? 'Kamu' : 'Customer'),
|
|
subtitle: Text(c['message'] as String),
|
|
),
|
|
)),
|
|
],
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|