feat: add customer account page with profile information and actions
- Create Account.vue page component with user profile display - Add account route to router.js - Update Navbar.vue to remove avatar button (moved to Dock) - Add avatar icon to Dock.vue for account page navigation - Implement 'Contact us' action that opens manager chat via Telegram - Implement 'Add to home screen' feature using Telegram Web App API 8.0+ - Add home screen status checking with checkHomeScreenStatus API - Display customer registration date and days with us counter - Add Russian language declension for days word (день/дня/дней) - Update TelegramCustomerHandler to return created_at in saveOrUpdate response - Add getByTelegramUserId method to TelecartCustomerService - Store customer_created_at in Pulse store during app initialization - Update App.vue to show Dock on account page - Remove unused getCurrentCustomer API endpoint and function
This commit is contained in:
@@ -49,6 +49,7 @@ class TelegramCustomerHandler
|
||||
return new JsonResponse([
|
||||
'data' => [
|
||||
'tracking_id' => Arr::get($customer, 'tracking_id'),
|
||||
'created_at' => Arr::get($customer, 'created_at'),
|
||||
],
|
||||
], Response::HTTP_OK);
|
||||
} catch (Throwable $e) {
|
||||
@@ -58,6 +59,46 @@ class TelegramCustomerHandler
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Получить данные текущего пользователя
|
||||
*
|
||||
* @param Request $request HTTP запрос
|
||||
* @return JsonResponse JSON ответ с данными пользователя
|
||||
*/
|
||||
public function getCurrent(Request $request): JsonResponse
|
||||
{
|
||||
try {
|
||||
$telegramUserData = $this->extractUserDataFromInitData($request);
|
||||
$telegramUserId = (int)Arr::get($telegramUserData, 'id');
|
||||
|
||||
if ($telegramUserId <= 0) {
|
||||
return new JsonResponse([
|
||||
'data' => null,
|
||||
], Response::HTTP_OK);
|
||||
}
|
||||
|
||||
$customer = $this->telegramCustomerService->getByTelegramUserId($telegramUserId);
|
||||
|
||||
if (!$customer) {
|
||||
return new JsonResponse([
|
||||
'data' => null,
|
||||
], Response::HTTP_OK);
|
||||
}
|
||||
|
||||
return new JsonResponse([
|
||||
'data' => [
|
||||
'created_at' => Arr::get($customer, 'created_at'),
|
||||
],
|
||||
], Response::HTTP_OK);
|
||||
} catch (Throwable $e) {
|
||||
$this->logger->error('Could not get current telegram customer data', ['exception' => $e]);
|
||||
|
||||
return new JsonResponse([
|
||||
'data' => null,
|
||||
], Response::HTTP_OK);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Извлечь данные Telegram пользователя из запроса
|
||||
*
|
||||
|
||||
@@ -111,4 +111,15 @@ class TelecartCustomerService
|
||||
{
|
||||
$this->telegramCustomer->increase($telecartCustomerId, 'orders_count');
|
||||
}
|
||||
|
||||
/**
|
||||
* Получить данные пользователя по Telegram user ID
|
||||
*
|
||||
* @param int $telegramUserId Telegram user ID
|
||||
* @return array|null Данные пользователя или null если не найдено
|
||||
*/
|
||||
public function getByTelegramUserId(int $telegramUserId): ?array
|
||||
{
|
||||
return $this->telegramCustomer->findByTelegramUserId($telegramUserId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ return [
|
||||
'product_show' => [ProductsHandler::class, 'show'],
|
||||
'products' => [ProductsHandler::class, 'index'],
|
||||
'saveTelegramCustomer' => [TelegramCustomerHandler::class, 'saveOrUpdate'],
|
||||
'getCurrentCustomer' => [TelegramCustomerHandler::class, 'getCurrent'],
|
||||
'settings' => [SettingsHandler::class, 'index'],
|
||||
'storeOrder' => [OrderHandler::class, 'store'],
|
||||
'testTgMessage' => [SettingsHandler::class, 'testTgMessage'],
|
||||
|
||||
Reference in New Issue
Block a user