-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add whilte labeling query (mock data)
- Loading branch information
1 parent
ad30a89
commit 0b51111
Showing
7 changed files
with
188 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using System.Collections.Generic; | ||
|
||
namespace VirtoCommerce.WhiteLabeling.Core.Models | ||
{ | ||
public class FooterLink | ||
{ | ||
public string Title { get; set; } | ||
public string Url { get; set; } | ||
public IList<FooterLink> ChildItems { get; set; } = []; | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
src/VirtoCommerce.WhiteLabeling.Core/Models/WhiteLabelingSettings.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using System.Collections.Generic; | ||
|
||
namespace VirtoCommerce.WhiteLabeling.Core.Models | ||
{ | ||
public class WhiteLabelingSettings | ||
{ | ||
public string UserId { get; set; } | ||
public string OrganizationId { get; set; } | ||
public string LogoUrl { get; set; } | ||
public string SecondaryLogoUrl { get; set; } | ||
public string FaviconUrl { get; set; } | ||
public IList<FooterLink> FooterLinks { get; set; } = []; | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
src/VirtoCommerce.WhiteLabeling.Data/Queries/GetWhiteLabelingSettingsQuery.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using System.Collections.Generic; | ||
using GraphQL; | ||
using GraphQL.Types; | ||
using VirtoCommerce.ExperienceApiModule.Core.BaseQueries; | ||
using VirtoCommerce.WhiteLabeling.Core.Models; | ||
|
||
namespace VirtoCommerce.WhiteLabeling.Data.Queries | ||
{ | ||
public class GetWhiteLabelingSettingsQuery : Query<WhiteLabelingSettings> | ||
{ | ||
public string OrganizationId { get; set; } | ||
|
||
public string UserId { get; set; } | ||
|
||
public string CultureName { get; set; } | ||
|
||
public override IEnumerable<QueryArgument> GetArguments() | ||
{ | ||
yield return Argument<StringGraphType>(nameof(OrganizationId)); | ||
yield return Argument<StringGraphType>(nameof(UserId)); | ||
yield return Argument<StringGraphType>(nameof(CultureName)); | ||
} | ||
|
||
public override void Map(IResolveFieldContext context) | ||
{ | ||
OrganizationId = context.GetArgument<string>(nameof(OrganizationId)); | ||
UserId = context.GetArgument<string>(nameof(UserId)); | ||
CultureName = context.GetArgument<string>(nameof(CultureName)); | ||
} | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
src/VirtoCommerce.WhiteLabeling.Data/Queries/GetWhiteLabelingSettingsQueryBuilder.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using MediatR; | ||
using Microsoft.AspNetCore.Authorization; | ||
using VirtoCommerce.ExperienceApiModule.Core.BaseQueries; | ||
using VirtoCommerce.WhiteLabeling.Core.Models; | ||
using VirtoCommerce.WhiteLabeling.Data.Schemas; | ||
|
||
namespace VirtoCommerce.WhiteLabeling.Data.Queries | ||
{ | ||
public class GetWhiteLabelingSettingsQueryBuilder : QueryBuilder<GetWhiteLabelingSettingsQuery, WhiteLabelingSettings, WhiteLabelingSettingsType> | ||
{ | ||
public GetWhiteLabelingSettingsQueryBuilder(IMediator mediator, IAuthorizationService authorizationService) | ||
: base(mediator, authorizationService) | ||
{ | ||
} | ||
|
||
protected override string Name => "whiteLabelingSettings"; | ||
} | ||
} |
81 changes: 81 additions & 0 deletions
81
src/VirtoCommerce.WhiteLabeling.Data/Queries/GetWhiteLabelingSettingsQueryHandler.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using VirtoCommerce.ExperienceApiModule.Core.Infrastructure; | ||
using VirtoCommerce.WhiteLabeling.Core.Models; | ||
|
||
namespace VirtoCommerce.WhiteLabeling.Data.Queries | ||
{ | ||
public class GetWhiteLabelingSettingsQueryHandler : IQueryHandler<GetWhiteLabelingSettingsQuery, WhiteLabelingSettings> | ||
{ | ||
public GetWhiteLabelingSettingsQueryHandler() | ||
{ | ||
} | ||
|
||
public Task<WhiteLabelingSettings> Handle(GetWhiteLabelingSettingsQuery request, CancellationToken cancellationToken) | ||
{ | ||
var settings = new List<WhiteLabelingSettings>() | ||
{ | ||
new WhiteLabelingSettings() | ||
{ | ||
UserId = "cfcec63a-faa5-4511-9aef-ee7672af6710", | ||
OrganizationId = "f081c52234754c9c8229aa42d6a19220", | ||
LogoUrl = "/static/images/common/logo-1.svg", | ||
SecondaryLogoUrl = "/static/images/common/logo-white-1.svg", | ||
FaviconUrl = "/static/icons/favicon-1.svg", | ||
FooterLinks = new List<FooterLink>() | ||
{ | ||
new FooterLink() | ||
{ | ||
Title = "Company Details", | ||
Url = "/company-details", | ||
ChildItems = new List<FooterLink>() | ||
{ | ||
new FooterLink() | ||
{ | ||
Title = "About Us", | ||
Url = "/about-us" | ||
}, | ||
new FooterLink() | ||
{ | ||
Title = "Investor Relations", | ||
Url = "/investor-relations" | ||
} | ||
} | ||
}, | ||
new FooterLink() | ||
{ | ||
Title = "Customer Support", | ||
Url = "/customer-support", | ||
ChildItems = new List<FooterLink>() | ||
{ | ||
new FooterLink() | ||
{ | ||
Title = "Catalog Request", | ||
Url = "/catalog-request" | ||
}, | ||
new FooterLink() | ||
{ | ||
Title = "Contact Us", | ||
Url = "/contact-us" | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
new WhiteLabelingSettings() | ||
{ | ||
UserId = "07e6a601-b90e-4dbd-a7d0-0f1f89db4f2e", | ||
OrganizationId = "", | ||
LogoUrl = "/static/images/common/logo.svg", | ||
SecondaryLogoUrl = "/static/images/common/logo-white.svg", | ||
FaviconUrl = "/static/icons/favicon.svg", | ||
} | ||
}; | ||
|
||
var result = settings.FirstOrDefault(x => x.OrganizationId == request.OrganizationId || x.UserId == request.UserId); | ||
return Task.FromResult(result); | ||
} | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
src/VirtoCommerce.WhiteLabeling.Data/Schemas/FooterLinkType.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using GraphQL.Types; | ||
using VirtoCommerce.WhiteLabeling.Core.Models; | ||
|
||
namespace VirtoCommerce.WhiteLabeling.Data.Schemas | ||
{ | ||
public class FooterLinkType : ObjectGraphType<FooterLink> | ||
{ | ||
public FooterLinkType() | ||
{ | ||
Field(x => x.Title, nullable: true).Description("Title of the footer link"); | ||
Field(x => x.Url, nullable: true).Description("URL of the footer link"); | ||
Field<ListGraphType<FooterLinkType>>("childItems", resolve: context => context.Source.ChildItems); | ||
} | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
src/VirtoCommerce.WhiteLabeling.Data/Schemas/WhiteLabelingSettingsType.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using GraphQL.Types; | ||
using VirtoCommerce.WhiteLabeling.Core.Models; | ||
|
||
namespace VirtoCommerce.WhiteLabeling.Data.Schemas | ||
{ | ||
public class WhiteLabelingSettingsType : ObjectGraphType<WhiteLabelingSettings> | ||
{ | ||
public WhiteLabelingSettingsType() | ||
{ | ||
Field(x => x.UserId, nullable: true).Description("User ID"); | ||
Field(x => x.OrganizationId, nullable: true).Description("Organization ID"); | ||
Field(x => x.LogoUrl, nullable: true).Description("Logo URL"); | ||
Field(x => x.SecondaryLogoUrl, nullable: true).Description("Logo URL for footer"); | ||
Field(x => x.FaviconUrl, nullable: true).Description("FavIcon"); | ||
Field<ListGraphType<FooterLinkType>>("footerLinks", resolve: context => context.Source.FooterLinks); | ||
} | ||
} | ||
} |