forked from eatvio/eatvio_app
feat(verify): phone + email
This commit is contained in:
@@ -36,10 +36,6 @@ class ProfileCubit extends Cubit<ProfileState> {
|
||||
}
|
||||
}
|
||||
|
||||
Future<String> getPassKey(String phone) async {
|
||||
return (await profileRepository.getPassKey('+79150626151'));
|
||||
}
|
||||
|
||||
Future<void> getMyProfile({
|
||||
String period = '1',
|
||||
}) async {
|
||||
|
||||
@@ -26,6 +26,7 @@ import 'package:eatvio_app/features/profile/presentation/widgets/profile_blog_po
|
||||
import 'package:eatvio_app/features/profile/presentation/widgets/weight_chart_widget.dart';
|
||||
import 'package:eatvio_app/core/locator_service.dart';
|
||||
import 'package:eatvio_app/core/theme/theme_helper.dart';
|
||||
import 'package:eatvio_app/features/profile/repositories/profile_repository.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
@@ -54,6 +55,7 @@ class _ProfileScreenState extends State<ProfileScreen> {
|
||||
final List<String> chipsLabelList = ['Вес', 'Замеры', 'ИМТ'];
|
||||
final List<String> chipsIntervalLabelList = ['1М', '3М', '6М', '1Г', 'ВСЁ ВРЕМЯ'];
|
||||
final List<String> chipsIntervalList = ['1', '3', '6', '12', 'all'];
|
||||
final TextEditingController controller = TextEditingController();
|
||||
|
||||
List<WeightModel> weightPoints = [];
|
||||
List<CircumferenceModel> circumferencePoints = [];
|
||||
@@ -222,9 +224,14 @@ class _ProfileScreenState extends State<ProfileScreen> {
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
ElevatedButton(onPressed: () async {
|
||||
final String passKey = await profileCubit.getPassKey('+79150626151');
|
||||
GoRouter.of(context).pushNamed('verifyScreen', extra: passKey);
|
||||
}, child: Text('phone verify')),
|
||||
await sl<ProfileRepository>().sendEmailCode();
|
||||
}, child: Text('send email verify code')),
|
||||
TextFormField(
|
||||
controller: controller,
|
||||
),
|
||||
ElevatedButton(onPressed: () async {
|
||||
await sl<ProfileRepository>().tryVerifyEmailByCode(controller.text);
|
||||
}, child: Text('try verify email by code')),
|
||||
_header(state),
|
||||
if (state.profile.roles.contains('consultant'))
|
||||
Column(
|
||||
|
||||
@@ -185,4 +185,16 @@ class ProfileRepository {
|
||||
Future<String> getPassKey(String phone) async {
|
||||
return (jsonDecode((await profileService.getPassKey(json: '{"route_name": "user_detailz.change-phone-verify", "route_params": {"phone": "$phone"}}'))))['key_is']!;
|
||||
}
|
||||
|
||||
Future<String> getMyPhone() async {
|
||||
return (jsonDecode(await profileService.getMyPhone())['phone']);
|
||||
}
|
||||
|
||||
Future<void> sendEmailCode() async {
|
||||
return await profileService.sendEmailCode();
|
||||
}
|
||||
|
||||
Future<void> tryVerifyEmailByCode(String code) async {
|
||||
return await profileService.tryVerifyEmailByCode(code: "{\"code\": \"$code\"}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,4 +108,15 @@ abstract class ProfileService {
|
||||
Future<String> getPassKey({
|
||||
@Body() required String json,
|
||||
});
|
||||
|
||||
@GET('/api/profile/my_phone')
|
||||
Future<String> getMyPhone();
|
||||
|
||||
@POST('/api/profile/send_email_code')
|
||||
Future<void> sendEmailCode();
|
||||
|
||||
@POST('/api/profile/verificate_email_code')
|
||||
Future<void> tryVerifyEmailByCode({
|
||||
@Body() required String code,
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user