last update
This commit is contained in:
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using YandexQuest.Models;
|
||||
using Zenject;
|
||||
|
||||
@@ -10,15 +11,33 @@ public class AdminPanel : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private TMP_Text _city;
|
||||
[SerializeField] private TMP_InputField _key;
|
||||
[Space]
|
||||
[SerializeField] private UIMenu _tagsDescMenu;
|
||||
[SerializeField] private UIMenu _winnersTableMenu;
|
||||
|
||||
[Inject] private readonly NetworkService _networkService;
|
||||
[Inject] private readonly ClientDataService _clientDataService;
|
||||
|
||||
private UIMenu _menu;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
_menu = GetComponent<UIMenu>();
|
||||
}
|
||||
|
||||
public void ShowTagsDescription()
|
||||
{
|
||||
_menu.SetNextMenu(_tagsDescMenu);
|
||||
_menu.ShowNextMenu();
|
||||
}
|
||||
|
||||
public async void Initialize(Cities city)
|
||||
{
|
||||
_city.text = _clientDataService.citiesTranslation[city];
|
||||
var result = await _networkService.GetAsync<int>($"auth/secretcode/{(int)city}");
|
||||
_key.text = result.responseData.ToString();
|
||||
|
||||
_clientDataService.city = (int)city;
|
||||
}
|
||||
|
||||
public void CopyToClipboard() => GUIUtility.systemCopyBuffer = _key.text;
|
||||
|
||||
@@ -26,7 +26,7 @@ public class Authorization : MonoBehaviour
|
||||
_menu = GetComponent<UIMenu>();
|
||||
_adminPanel = _adminMenu.GetComponent<AdminPanel>();
|
||||
|
||||
if(_clientDataService.data != null)
|
||||
if (_clientDataService.data != null)
|
||||
{
|
||||
Debug.LogWarning($"данные клианта {_clientDataService.data.id} загружены: город - {(Cities)_clientDataService.data.city}, найдено тэгов - {_clientDataService.data.games.Count}");
|
||||
// UniTask.Void(async ()=>
|
||||
@@ -52,7 +52,7 @@ public class Authorization : MonoBehaviour
|
||||
|
||||
_codeInputField.onValueChanged.AddListener(stringValue =>
|
||||
{
|
||||
if(stringValue.Length != 6)
|
||||
if (stringValue.Length != 6)
|
||||
{
|
||||
_codeAcceptButton.interactable = false;
|
||||
}
|
||||
@@ -72,9 +72,8 @@ public class Authorization : MonoBehaviour
|
||||
{
|
||||
CityUniqueCode cityUniqueCode = null;
|
||||
var resultAdmin = await _networkService.GetAsync<CityUniqueCode>($"auth/admin/{inputFieldText}");
|
||||
cityUniqueCode = resultAdmin.responseData;
|
||||
|
||||
if(resultAdmin.responseCode == 0)
|
||||
if (resultAdmin.responseCode == 0)
|
||||
{
|
||||
var message = "Нет соединения с сервером";
|
||||
Debug.LogError(message);
|
||||
@@ -85,18 +84,18 @@ public class Authorization : MonoBehaviour
|
||||
Debug.LogWarning("такого админа нет в базе. ищем город...");
|
||||
var result = await _networkService.GetAsync<Client>($"auth/{inputFieldText}");
|
||||
|
||||
if(result.responseCode == 404)
|
||||
if (result.responseCode == 404)
|
||||
{
|
||||
Debug.LogError(result.responseText);
|
||||
_inputField.ShowErrorAsync(result.responseText).Forget();
|
||||
}
|
||||
else if(result.responseCode == 0)
|
||||
else if (result.responseCode == 0)
|
||||
{
|
||||
var message = "Нет соединения с сервером";
|
||||
Debug.LogError(message);
|
||||
_inputField.ShowErrorAsync(message).Forget();
|
||||
}
|
||||
else if(result.responseCode == 200)
|
||||
else if (result.responseCode == 200)
|
||||
{
|
||||
_clientDataService.data = result.responseData;
|
||||
Debug.Log(result.responseData.city.ToString());
|
||||
@@ -104,9 +103,12 @@ public class Authorization : MonoBehaviour
|
||||
_menu.ShowNextMenu();
|
||||
}
|
||||
}
|
||||
else if(resultAdmin.responseCode == 200)
|
||||
else if (resultAdmin.responseCode == 200)
|
||||
{
|
||||
cityUniqueCode = resultAdmin.responseData;
|
||||
|
||||
_adminPanel.Initialize(resultAdmin.responseData.cityEnum);
|
||||
_clientDataService.city = (int)resultAdmin.responseData.cityEnum;
|
||||
|
||||
_menu.SetNextMenu(_adminMenu);
|
||||
_menu.ShowNextMenu();
|
||||
|
||||
Reference in New Issue
Block a user