Frontend first draft

This commit is contained in:
Arseni
2025-11-13 15:06:15 +03:00
parent e47f343afb
commit ddb54ddfdc
504 changed files with 25498 additions and 1 deletions

View File

@@ -0,0 +1,15 @@
import 'package:json_annotation/json_annotation.dart';
part 'login.g.dart';
@JsonSerializable()
class LoginRequest {
final String login;
final String password;
const LoginRequest({required this.login, required this.password});
factory LoginRequest.fromJson(Map<String, dynamic> json) => _$LoginRequestFromJson(json);
Map<String, dynamic> toJson() => _$LoginRequestToJson(this);
}

View File

@@ -0,0 +1,29 @@
import 'dart:convert';
import 'package:logging/logging.dart';
import 'package:http/http.dart' as http;
import 'package:pshared/service/pfe/login.dart';
class PfeService {
static final _logger = Logger('service.pfe');
static Future<String> login(String email, String password) async {
_logger.fine('Logging in');
try {
final res = await http.post(
Uri.parse('http://localhost:3000/api/v1/auth/login'),
headers: {'Content-Type': 'application/json'},
body: json.encode(LoginRequest(login: email, password: password).toJson()),
);
return res.toString();
} catch (e) {
_logger.warning(e.toString());
rethrow;
}
}
}