implemented global user search integration for Talk chats with role-coded badges and direct chat creation logic
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
import '../../marianumconnect/queries/user_search/user_search_response.dart';
|
||||
|
||||
/// Demo fixtures for the Talk user search — a small mixed set of teachers and
|
||||
/// students, filtered client-side so the demo search feels responsive.
|
||||
class DemoUsers {
|
||||
const DemoUsers._();
|
||||
|
||||
static final List<McUserSearchResult> _all = [
|
||||
McUserSearchResult(
|
||||
username: 'm.muster',
|
||||
firstName: 'Maria',
|
||||
lastName: 'Mustermann',
|
||||
userType: 'TEACHER',
|
||||
),
|
||||
McUserSearchResult(
|
||||
username: 'j.beispiel',
|
||||
firstName: 'Jonas',
|
||||
lastName: 'Beispiel',
|
||||
userType: 'TEACHER',
|
||||
),
|
||||
McUserSearchResult(
|
||||
username: 'l.schueler',
|
||||
firstName: 'Lena',
|
||||
lastName: 'Schüler',
|
||||
userType: 'STUDENT',
|
||||
className: '9c',
|
||||
),
|
||||
McUserSearchResult(
|
||||
username: 'p.probe',
|
||||
firstName: 'Paul',
|
||||
lastName: 'Probe',
|
||||
userType: 'STUDENT',
|
||||
className: 'Q2',
|
||||
),
|
||||
];
|
||||
|
||||
static List<McUserSearchResult> search(String query) {
|
||||
final q = query.trim().toLowerCase();
|
||||
if (q.length < 2) return const [];
|
||||
return _all
|
||||
.where(
|
||||
(u) =>
|
||||
u.firstName.toLowerCase().contains(q) ||
|
||||
u.lastName.toLowerCase().contains(q) ||
|
||||
u.username.toLowerCase().contains(q) ||
|
||||
'${u.firstName} ${u.lastName}'.toLowerCase().contains(q),
|
||||
)
|
||||
.toList();
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'data/demo_breaker.dart';
|
||||
import 'data/demo_holidays.dart';
|
||||
import 'data/demo_timetable.dart';
|
||||
import 'data/demo_users.dart';
|
||||
|
||||
/// Single source of truth for the MarianumConnect demo responses. The demo
|
||||
/// interceptor asks this for the body of any MC request. Read endpoints reuse
|
||||
@@ -32,6 +33,10 @@ class DemoMarianumConnect {
|
||||
return DemoTimetable.holidays().result.map((e) => e.toJson()).toList();
|
||||
case 'holidays':
|
||||
return DemoHolidays.upcoming().map((e) => e.toJson()).toList();
|
||||
case 'users/search':
|
||||
return DemoUsers.search(query['q']?.toString() ?? '')
|
||||
.map((e) => e.toJson())
|
||||
.toList();
|
||||
case 'breaker':
|
||||
return DemoBreaker.none().toJson();
|
||||
case 'timetable/elements/teachers':
|
||||
|
||||
Reference in New Issue
Block a user