mirror of
https://github.com/Shchoholiev/shopping-assistant-web-client.git
synced 2025-04-04 16:49:36 +00:00
fix bags
This commit is contained in:
parent
8b544ca009
commit
7b7c707cca
@ -35,55 +35,54 @@ public partial class Chat : ComponentBase
|
||||
|
||||
private async Task LoadMessages()
|
||||
{
|
||||
string wishlistId = chatId;
|
||||
|
||||
Suggestion.Add("123");
|
||||
Suggestion.Add("456");
|
||||
Suggestion.Add("145623");
|
||||
|
||||
var request = new GraphQLRequest
|
||||
{
|
||||
Query = @"query PersonalWishlist( $wishlistId: String!) {
|
||||
personalWishlist(wishlistId: $wishlistId) {
|
||||
name
|
||||
}
|
||||
}",
|
||||
|
||||
Variables = new
|
||||
try{
|
||||
string wishlistId = chatId;
|
||||
|
||||
var request = new GraphQLRequest
|
||||
{
|
||||
wishlistId,
|
||||
}
|
||||
};
|
||||
|
||||
var response = await _apiClient.QueryAsync(request);
|
||||
var responseData = response.Data;
|
||||
name = responseData.personalWishlist.name;
|
||||
|
||||
|
||||
isLoading = true;
|
||||
int pageNumber = 1;
|
||||
request = new GraphQLRequest
|
||||
{
|
||||
Query = @"query MessagesPageFromPersonalWishlist($wishlistId: String!, $pageNumber: Int!, $pageSize: Int!) {
|
||||
messagesPageFromPersonalWishlist( wishlistId: $wishlistId, pageNumber: $pageNumber, pageSize: $pageSize)
|
||||
{
|
||||
items {
|
||||
id
|
||||
text
|
||||
role
|
||||
createdById
|
||||
}
|
||||
Query = @"query PersonalWishlist( $wishlistId: String!) {
|
||||
personalWishlist(wishlistId: $wishlistId) {
|
||||
name
|
||||
}
|
||||
}",
|
||||
|
||||
Variables = new
|
||||
Variables = new
|
||||
{
|
||||
wishlistId,
|
||||
}
|
||||
};
|
||||
|
||||
var response = await _apiClient.QueryAsync(request);
|
||||
var responseData = response.Data;
|
||||
name = responseData.personalWishlist.name;
|
||||
|
||||
|
||||
isLoading = true;
|
||||
int pageNumber = 1;
|
||||
request = new GraphQLRequest
|
||||
{
|
||||
wishlistId,
|
||||
pageNumber,
|
||||
pageSize = 200
|
||||
}
|
||||
};
|
||||
try{
|
||||
Query = @"query MessagesPageFromPersonalWishlist($wishlistId: String!, $pageNumber: Int!, $pageSize: Int!) {
|
||||
messagesPageFromPersonalWishlist( wishlistId: $wishlistId, pageNumber: $pageNumber, pageSize: $pageSize)
|
||||
{
|
||||
items {
|
||||
id
|
||||
text
|
||||
role
|
||||
createdById
|
||||
}
|
||||
}
|
||||
}",
|
||||
|
||||
Variables = new
|
||||
{
|
||||
wishlistId,
|
||||
pageNumber,
|
||||
pageSize = 200
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
response = await _apiClient.QueryAsync(request);
|
||||
responseData = response.Data;
|
||||
var jsonCategoriesResponse = JsonConvert.SerializeObject(responseData.messagesPageFromPersonalWishlist.items);
|
||||
@ -91,8 +90,8 @@ public partial class Chat : ComponentBase
|
||||
Messages.Reverse();
|
||||
isLoading = false;
|
||||
|
||||
}catch{
|
||||
|
||||
}catch(Exception ex){
|
||||
Console.WriteLine($"Error : {ex.Message}");
|
||||
}
|
||||
|
||||
/*
|
||||
@ -154,6 +153,7 @@ public partial class Chat : ComponentBase
|
||||
}
|
||||
private async Task AddNewMessage()
|
||||
{
|
||||
try{
|
||||
messageCreateDto = new MessageCreateDto { Text = inputValue };;
|
||||
Message = new Messages();
|
||||
Message.Text = inputValue;
|
||||
@ -161,6 +161,7 @@ public partial class Chat : ComponentBase
|
||||
Message.Id = "";
|
||||
Message.CreatedById = "";
|
||||
inputValue = "";
|
||||
Suggestion = new List<String>();
|
||||
Messages.Add(Message);
|
||||
StateHasChanged();
|
||||
|
||||
@ -215,6 +216,11 @@ public partial class Chat : ComponentBase
|
||||
|
||||
}
|
||||
|
||||
}catch(Exception ex){
|
||||
Console.WriteLine($"Error : {ex.Message}");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -11,8 +11,9 @@
|
||||
</a>
|
||||
</div>
|
||||
|
||||
@if(isLoading == false){
|
||||
|
||||
<div class="new_chat">
|
||||
<div class="new_chat">
|
||||
<div class="chat_message">
|
||||
<div class="title_one_frame">New chat</div>
|
||||
<div class="title_two_frame">What you're looking for</div>
|
||||
@ -58,6 +59,17 @@
|
||||
|
||||
</div>
|
||||
|
||||
}else{
|
||||
|
||||
<div class="new_chat">
|
||||
|
||||
<img class="loading" src="/images/loading.svg" alt="Loading chat">
|
||||
|
||||
</div>
|
||||
|
||||
}
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<script>
|
||||
|
@ -26,7 +26,7 @@ namespace ShoppingAssistantWebClient.Web.Pages
|
||||
private CancellationTokenSource cancelTokenSource;
|
||||
|
||||
private string inputValue = "";
|
||||
public bool isLoading = true;
|
||||
public bool isLoading;
|
||||
|
||||
|
||||
private async Task CreateNewChat() {
|
||||
@ -39,6 +39,7 @@ namespace ShoppingAssistantWebClient.Web.Pages
|
||||
}
|
||||
|
||||
isLoading = true;
|
||||
StateHasChanged();
|
||||
messageCreateDto = new MessageCreateDto { Text = inputValue };
|
||||
var type = selectedChoice;
|
||||
var firstMessageText = $"What are you looking for?";
|
||||
@ -62,7 +63,6 @@ namespace ShoppingAssistantWebClient.Web.Pages
|
||||
var responseData = response.Data;
|
||||
var chatId = responseData?.startPersonalWishlist?.id;
|
||||
string wishlistId1 = chatId;
|
||||
await UpdateSideMenu(wishlistId1);
|
||||
|
||||
var text = inputValue;
|
||||
/*
|
||||
@ -120,6 +120,10 @@ namespace ShoppingAssistantWebClient.Web.Pages
|
||||
|
||||
response = await _apiClient.QueryAsync(request);
|
||||
|
||||
isLoading = false;
|
||||
StateHasChanged();
|
||||
|
||||
await UpdateSideMenu(wishlistId1);
|
||||
var url = $"/chat/{chatId}";
|
||||
Navigation.NavigateTo(url);
|
||||
|
||||
|
@ -17,7 +17,16 @@
|
||||
cursor: pointer;
|
||||
visibility: hidden;
|
||||
}
|
||||
|
||||
.loading {
|
||||
margin: 0 auto;
|
||||
margin-top: 25%;
|
||||
height: 10em;
|
||||
width: 10em;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
text-align: center;
|
||||
}
|
||||
.button_open_menu span {
|
||||
width: 20px;
|
||||
height: 1.5px;
|
||||
|
@ -27,53 +27,65 @@ namespace ShoppingAssistantWebClient.Web.Shared
|
||||
}
|
||||
public async Task LoadMenus(int pageNumber, int pageSize )
|
||||
{
|
||||
isLoading = true;
|
||||
var request = new GraphQLRequest
|
||||
{
|
||||
Query = @"query PersonalWishlistsPage( $pageNumber: Int!, $pageSize: Int!) {
|
||||
personalWishlistsPage(pageNumber: $pageNumber, pageSize: $pageSize) {
|
||||
items {
|
||||
id
|
||||
name
|
||||
}
|
||||
}
|
||||
}",
|
||||
|
||||
Variables = new
|
||||
try{
|
||||
isLoading = true;
|
||||
var request = new GraphQLRequest
|
||||
{
|
||||
pageNumber,
|
||||
pageSize,
|
||||
}
|
||||
};
|
||||
Query = @"query PersonalWishlistsPage( $pageNumber: Int!, $pageSize: Int!) {
|
||||
personalWishlistsPage(pageNumber: $pageNumber, pageSize: $pageSize) {
|
||||
items {
|
||||
id
|
||||
name
|
||||
}
|
||||
}
|
||||
}",
|
||||
|
||||
var response = await _apiClient.QueryAsync(request);
|
||||
var responseData = response.Data;
|
||||
var jsonCategoriesResponse = JsonConvert.SerializeObject(responseData.personalWishlistsPage.items);
|
||||
this.Wishlists.AddRange(JsonConvert.DeserializeObject<List<Wishlist>>(jsonCategoriesResponse));
|
||||
Wishlists.Reverse();
|
||||
isLoading = false;
|
||||
StateHasChanged();
|
||||
Variables = new
|
||||
{
|
||||
pageNumber,
|
||||
pageSize,
|
||||
}
|
||||
};
|
||||
|
||||
var response = await _apiClient.QueryAsync(request);
|
||||
var responseData = response.Data;
|
||||
var jsonCategoriesResponse = JsonConvert.SerializeObject(responseData.personalWishlistsPage.items);
|
||||
this.Wishlists = JsonConvert.DeserializeObject<List<Wishlist>>(jsonCategoriesResponse);
|
||||
Wishlists.Reverse();
|
||||
isLoading = false;
|
||||
StateHasChanged();
|
||||
|
||||
}catch(Exception ex){
|
||||
Console.WriteLine($"Error : {ex.Message}");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected async Task DeleteWish(string wishlistId)
|
||||
{
|
||||
var request = new GraphQLRequest
|
||||
{
|
||||
Query = @"mutation DeletePersonalWishlist($wishlistId: String!) {
|
||||
deletePersonalWishlist(wishlistId: $wishlistId) {
|
||||
id
|
||||
}
|
||||
}
|
||||
",
|
||||
|
||||
Variables = new
|
||||
try{
|
||||
var request = new GraphQLRequest
|
||||
{
|
||||
wishlistId
|
||||
}
|
||||
};
|
||||
Query = @"mutation DeletePersonalWishlist($wishlistId: String!) {
|
||||
deletePersonalWishlist(wishlistId: $wishlistId) {
|
||||
id
|
||||
}
|
||||
}
|
||||
",
|
||||
|
||||
var response = await _apiClient.QueryAsync(request);
|
||||
await LoadMenus(currentPage, pageSize);
|
||||
Variables = new
|
||||
{
|
||||
wishlistId
|
||||
}
|
||||
};
|
||||
|
||||
var response = await _apiClient.QueryAsync(request);
|
||||
await LoadMenus(currentPage, pageSize);
|
||||
|
||||
}catch(Exception ex){
|
||||
Console.WriteLine($"Error : {ex.Message}");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
42
ShoppingAssistantWebClient.Web/wwwroot/images/loading.svg
Normal file
42
ShoppingAssistantWebClient.Web/wwwroot/images/loading.svg
Normal file
@ -0,0 +1,42 @@
|
||||
<?xml version="1.0" standalone="no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN"
|
||||
"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
|
||||
<svg version="1.0" xmlns="http://www.w3.org/2000/svg"
|
||||
width="602.000000pt" height="597.000000pt" viewBox="0 0 602.000000 597.000000"
|
||||
preserveAspectRatio="xMidYMid meet">
|
||||
|
||||
<g transform="translate(0.000000,597.000000) scale(0.100000,-0.100000)"
|
||||
fill="#000000" stroke="none">
|
||||
<path d="M2819 5887 c-104 -30 -199 -113 -247 -215 -22 -48 -27 -71 -27 -142
|
||||
0 -105 28 -173 105 -254 74 -79 150 -111 260 -111 72 0 94 4 145 28 79 37 156
|
||||
114 192 191 24 52 28 74 28 146 0 71 -4 94 -27 142 -77 166 -267 261 -429 215z"/>
|
||||
<path d="M4083 5579 c-203 -64 -333 -300 -279 -509 40 -155 147 -257 308 -295
|
||||
252 -59 480 80 521 318 28 163 -56 334 -213 435 -110 71 -221 88 -337 51z"/>
|
||||
<path d="M1493 5496 c-116 -38 -189 -113 -225 -229 -24 -80 -21 -174 7 -245
|
||||
21 -51 88 -112 164 -149 81 -38 211 -44 296 -13 81 30 165 114 190 191 56 164
|
||||
-20 351 -172 425 -67 33 -191 43 -260 20z"/>
|
||||
<path d="M5061 4675 c-366 -103 -489 -487 -241 -758 86 -94 189 -148 315 -166
|
||||
202 -29 380 72 473 266 36 76 37 81 37 188 0 131 -20 191 -94 288 -115 150
|
||||
-326 228 -490 182z"/>
|
||||
<path d="M532 4508 c-51 -17 -124 -89 -157 -155 -26 -50 -30 -69 -30 -138 0
|
||||
-71 4 -89 33 -147 37 -75 73 -110 151 -146 46 -21 63 -24 130 -20 90 6 152 32
|
||||
212 90 62 60 83 116 84 218 0 73 -4 92 -27 136 -32 61 -94 119 -157 147 -54
|
||||
24 -187 32 -239 15z"/>
|
||||
<path d="M5440 3389 c-145 -25 -278 -125 -344 -261 -94 -190 -59 -406 89 -554
|
||||
194 -195 490 -191 683 10 66 68 105 136 127 223 83 319 -222 639 -555 582z"/>
|
||||
<path d="M218 3187 c-132 -37 -217 -162 -206 -301 13 -163 137 -267 303 -254
|
||||
103 9 187 64 229 151 55 112 41 216 -40 306 -81 90 -185 126 -286 98z"/>
|
||||
<path d="M5085 2120 c-164 -34 -301 -145 -383 -311 -103 -208 -72 -411 85
|
||||
-568 101 -101 244 -161 383 -161 228 0 444 155 516 370 27 82 25 225 -4 312
|
||||
-87 253 -347 409 -597 358z"/>
|
||||
<path d="M539 1877 c-72 -20 -129 -75 -166 -157 -19 -43 -22 -168 -5 -227 15
|
||||
-50 82 -122 143 -155 58 -30 186 -33 239 -4 63 33 115 83 145 137 26 47 30 64
|
||||
30 134 0 63 -5 89 -23 122 -30 57 -86 111 -139 135 -56 25 -164 32 -224 15z"/>
|
||||
<path d="M1509 870 c-20 -11 -49 -34 -64 -52 -36 -42 -85 -146 -85 -178 0 -78
|
||||
56 -161 134 -203 63 -33 166 -31 228 5 98 58 144 191 100 290 -25 58 -87 127
|
||||
-129 145 -47 19 -141 16 -184 -7z"/>
|
||||
<path d="M2822 537 c-49 -15 -127 -90 -147 -139 -56 -139 19 -302 159 -343 62
|
||||
-19 90 -19 152 0 140 41 214 197 161 337 -22 57 -100 132 -153 147 -48 13
|
||||
-128 13 -172 -2z"/>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 2.4 KiB |
Loading…
Reference in New Issue
Block a user