Skip to content

Commit 40757da

Browse files
Update flow
1 parent 7a30fa1 commit 40757da

File tree

9 files changed

+167
-68
lines changed

9 files changed

+167
-68
lines changed

DocuSign.Workspaces/DocuSign.Workspaces/ClientApp/src/assets/scss/components/_forms.scss

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,20 @@ input[type='radio'] {
215215
}
216216
.warning-text_margin {
217217
margin-left: 24px;
218+
display: flex;
219+
flex-direction: column;
220+
gap: 6px;
221+
}
222+
.warning-text-line {
223+
display: inline-flex;
224+
gap: 6px;
225+
flex-wrap: wrap;
226+
}
227+
.warning-text-detail {
228+
font-family: 'Inter', sans-serif;
229+
font-size: 14px;
230+
font-weight: 400;
231+
color: #13131b;
218232
}
219233
.shield-icon {
220234
width: 32px;

DocuSign.Workspaces/DocuSign.Workspaces/ClientApp/src/components/SomethingWentWrong.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { useTranslation } from 'react-i18next';
22
import { ReactComponent as ShieldIcon } from '../assets/icons/shield-cross.svg';
33

4-
export const SomethingWentWrong = ({ tryAgain }) => {
4+
export const SomethingWentWrong = ({ tryAgain, message }) => {
55
const { t } = useTranslation();
66

77
return (
@@ -10,13 +10,16 @@ export const SomethingWentWrong = ({ tryAgain }) => {
1010
<div className="warning-text">
1111
<ShieldIcon className="shield-icon" />
1212
<span className="warning-text_margin">
13-
{t('SomethingWent')}
14-
<span
15-
style={{ color: 'inherit', textDecoration: 'underline', cursor: 'pointer' }}
16-
onClick={tryAgain}
17-
>
18-
{t('TryAgain')}
13+
<span className="warning-text-line">
14+
{t('SomethingWent')}
15+
<span
16+
style={{ color: 'inherit', textDecoration: 'underline', cursor: 'pointer' }}
17+
onClick={tryAgain}
18+
>
19+
{t('TryAgain')}
20+
</span>
1921
</span>
22+
{message ? <span className="warning-text-detail">{message}</span> : null}
2023
</span>
2124
</div>
2225
</div>

DocuSign.Workspaces/DocuSign.Workspaces/ClientApp/src/pages/UseCaseTwo/index.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,13 +112,14 @@ export const UseCaseTwoPage = () => {
112112
body: JSON.stringify(payload),
113113
});
114114
if (!res.ok) {
115-
throw new Error(`${t('Common.ServerError')}${res.status}`);
115+
const message = await res.text();
116+
throw new Error(message || `${t('Common.ServerError')}${res.status}`);
116117
}
117118

118119
const data = await res.json();
119120
setListFiles(data);
120121
} catch (error) {
121-
setErrorOnboarding(t('Common.Error'));
122+
setErrorOnboarding(error.message || t('Common.Error'));
122123
} finally {
123124
setRequesting(false);
124125
}
@@ -177,6 +178,7 @@ export const UseCaseTwoPage = () => {
177178
{currentStep === 1 &&
178179
(errorOnboarding ? (
179180
<SomethingWentWrong
181+
message={errorOnboarding}
180182
tryAgain={() => {
181183
setCurrentStep(0);
182184
scrollToTop();

DocuSign.Workspaces/DocuSign.Workspaces/Controllers/Admin/AdminController.cs

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ public IActionResult ObtainConsent([FromBody] RequestAccountAuthorizeModel model
4848

4949
return model.ConsentType switch
5050
{
51-
ConsentType.Admin => Ok(new ResponseAccountAuthorizeModel(_authenticationService.CreateAdminConsentUrl(model.BasePath, $"api/consentcallback"))),
52-
ConsentType.Individual => Ok(new ResponseAccountAuthorizeModel(_authenticationService.CreateUserConsentUrl(model.BasePath, $"api/consentcallback"))),
51+
ConsentType.Admin => Ok(new ResponseAccountAuthorizeModel(_authenticationService.CreateAdminConsentUrl(model.BasePath, "api/consentcallback"))),
52+
ConsentType.Individual => Ok(new ResponseAccountAuthorizeModel(_authenticationService.CreateUserConsentUrl(model.BasePath, "api/consentcallback"))),
5353
_ => BadRequest("Unknown consent type")
5454
};
5555
}
@@ -71,17 +71,19 @@ public IActionResult ConsentCallback(string code)
7171
var settings = _settingsRepository.Get();
7272
settings.IsConsentGranted = true;
7373
settings.UserId = _authenticationService.PrePopulateUserId(settings.BasePath, code);
74+
settings.AuthCode = code;
7475
_settingsRepository.Save(settings);
7576
return LocalRedirect("/");
7677
}
7778

7879
[HttpGet]
7980
[Route("/api/accounts")]
80-
public IActionResult GetAccounts(string basePath, string userId)
81+
public async Task<IActionResult> GetAccounts(string basePath, string userId)
8182
{
8283
try
8384
{
84-
var result = _authenticationService.GetAccounts(basePath, userId);
85+
var result = await _authenticationService.GetAccountsAsync(
86+
basePath, userId);
8587
return Ok(result);
8688
}
8789
catch (ApplicationApiException ex)
@@ -97,8 +99,7 @@ public async Task<IActionResult> Connect([FromBody] RequestAccountConnectModel m
9799
var connectionSettings = CreateConnectionSettings(model);
98100
try
99101
{
100-
var principal =
101-
_authenticationService.AuthenticateFromJwt(connectionSettings);
102+
var principal = await _authenticationService.AuthenticateFromJwtAsync(connectionSettings);
102103

103104
await HttpContext.SignInAsync(
104105
CookieAuthenticationDefaults.AuthenticationScheme,
@@ -110,7 +111,6 @@ await HttpContext.SignInAsync(
110111
settings.UserId = model.UserId;
111112
settings.AccountId = model.AccountId;
112113
settings.BaseUri = model.BaseUri;
113-
settings.TemplatesDataSource = GetTemplatesDataSource(connectionSettings.AccountId);
114114
settings.Template = TemplateNames.DefaultTemplateId;
115115
settings.SignatureTypesDataSource = GetSignatureTypesDataSource(connectionSettings.AccountId);
116116
settings.SignatureType = SignatureInfo.DefaultProviderName;
@@ -258,20 +258,5 @@ private IEnumerable<DataSourceItem> GetSignatureTypesDataSource(string accountId
258258
result.AddRange(signatureProviders.SignatureProviders.Select(p => new DataSourceItem(p.SignatureProviderName, p.SignatureProviderDisplayName)));
259259
return result;
260260
}
261-
262-
private IEnumerable<DataSourceItem> GetTemplatesDataSource(string accountId)
263-
{
264-
var userTemplates = _docuSignApiProvider.TemplatesApi.ListTemplates(accountId);
265-
var result = new List<DataSourceItem>
266-
{
267-
new()
268-
{
269-
Key = TemplateNames.DefaultTemplateId,
270-
Value = TemplateNames.DefaultTemplateName
271-
}
272-
};
273-
result.AddRange(userTemplates.EnvelopeTemplates.Select(t => new DataSourceItem(t.TemplateId, t.Name)));
274-
return result;
275-
}
276261
}
277262
}

DocuSign.Workspaces/DocuSign.Workspaces/Controllers/CarePlans/CarePlansController.cs

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
using System;
22
using System.Collections.Generic;
33
using System.Threading.Tasks;
4+
using DocuSign.eSign.Client;
45
using DocuSign.Workspaces.Domain.CarePlans;
56
using DocuSign.Workspaces.Domain.CarePlans.Model;
7+
using DocuSign.Workspaces.Infrastructure.Exceptions;
68
using Microsoft.AspNetCore.Mvc;
79

810
namespace DocuSign.Workspaces.Controllers.CarePlans;
@@ -19,9 +21,28 @@ public async Task<List<PhysicianModel>> GetPhysicians()
1921

2022
[HttpPost]
2123
[Route("/api/care-plans/submit-physician")]
22-
public async Task<List<CareDocumentsModel>> SubmitToPhysician([FromBody] SubmitToPhysiciansModel model)
24+
public async Task<IActionResult> SubmitToPhysician([FromBody] SubmitToPhysiciansModel model)
2325
{
24-
var documents = await carePlansService.SubmitToPhysician(model);
25-
return documents;
26+
try
27+
{
28+
var documents = await carePlansService.SubmitToPhysician(model);
29+
return Ok(documents);
30+
}
31+
catch (ApplicationApiException ex)
32+
{
33+
var message = ex.Details?.ErrorDescription ?? ex.Details?.Error ?? ex.Message;
34+
return BadRequest(message);
35+
}
36+
catch (Docusign.IAM.SDK.Models.Errors.APIException ex)
37+
{
38+
return StatusCode(500, ex.StatusCode == 429 ?
39+
"The request limit for adding users to a workspace (4 per day) has been reached." :
40+
ex.Message);
41+
}
42+
catch (Exception ex)
43+
{
44+
var tp = ex.GetType().ToString();
45+
return StatusCode(500, ex.Message);
46+
}
2647
}
2748
}

DocuSign.Workspaces/DocuSign.Workspaces/Domain/Admin/Models/Settings.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ public Settings()
1616

1717
public AuthenticationType AuthenticationType { get; set; }
1818
public string BasePath { get; set; }
19+
public string AuthCode { get; set; }
1920
public string BaseUri { get; set; }
2021
public string AccountId { get; set; }
2122
public string UserId { get; set; }
Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,23 @@
11
using System.Collections.Generic;
22
using System.Security.Claims;
3+
using System.Threading.Tasks;
34
using DocuSign.Workspaces.Controllers.Admin.Models;
45
using DocuSign.Workspaces.Domain.Admin.Models;
56

67
namespace DocuSign.Workspaces.Domain.Admin.Services.Interfaces
78
{
89
public interface IAuthenticationService
910
{
10-
ClaimsPrincipal AuthenticateFromJwt(AccountConnectionSettings connectionSettings);
11+
Task<ClaimsPrincipal> AuthenticateFromJwtAsync(AccountConnectionSettings accountConnectionSettings);
12+
1113
string CreateAdminConsentUrl(string baseUrl, string redirectUrl);
14+
1215
string CreateUserConsentUrl(string baseUrl, string redirectUrl);
16+
1317
void AuthenticateForProfileManagement(string login, string password);
18+
1419
string PrePopulateUserId(string basePath, string code);
15-
List<ResponseGetAccountsModel> GetAccounts(string basePath, string userId);
20+
21+
Task<List<ResponseGetAccountsModel>> GetAccountsAsync(string basePath, string userId);
1622
}
17-
}
23+
}

DocuSign.Workspaces/DocuSign.Workspaces/Domain/CarePlans/CarePlansService.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,15 @@ public async Task<List<CareDocumentsModel>> SubmitToPhysician(SubmitToPhysicians
7878
FirstName = model.Physician.Name,
7979
LastName = ""
8080
};
81-
await docuSignApiProvider.WorkspaceUsers.AddWorkspaceUserAsync(accountRepository.AccountId, model.Physician.WorkspaceId, userForCreate);
81+
try
82+
{
83+
await docuSignApiProvider.WorkspaceUsers.AddWorkspaceUserAsync(accountRepository.AccountId, model.Physician.WorkspaceId, userForCreate);
84+
}
85+
catch (Exception e)
86+
{
87+
Console.WriteLine(e);
88+
throw;
89+
}
8290

8391
foreach (var document in model.Documents)
8492
{

0 commit comments

Comments
 (0)