Skip to content

Commit

Permalink
feat(ospm): updated callback overlay
Browse files Browse the repository at this point in the history
  • Loading branch information
lavanya-bmw committed Aug 29, 2024
1 parent b4936ca commit 1c420eb
Showing 1 changed file with 11 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ const OnboardingServiceProvider = () => {
useUpdateRegistartionStatusCallbackMutation()
const [formData, setFormData] = useState<IHashMap<string>>({})
const [showError, setShowError] = useState(false)
const [idpUpdateData, setIdpUpdateData] = useState<
const [callbackData, setCallbackData] = useState<
RegistartionStatusCallbackType | undefined
>(undefined)

Expand Down Expand Up @@ -105,12 +105,11 @@ const OnboardingServiceProvider = () => {
const isWellknownMetadata = (expr: string) =>
isURL(expr) && expr.endsWith('.well-known/openid-configuration')

const doUpdateIDP = async () => {
if (!(data && idpUpdateData)) return
console.log('idpUpdateData', idpUpdateData)
const updateCallbackIDP = async () => {
if (!(data && callbackData)) return
setLoading(true)
try {
await updateRegistartionStatusCallback(idpUpdateData).unwrap()
await updateRegistartionStatusCallback(callbackData).unwrap()
success(t('content.onboardingServiceProvider.success'))
setOverlayOpen(false)
} catch (err) {
Expand All @@ -119,13 +118,13 @@ const OnboardingServiceProvider = () => {
setLoading(false)
}

const checkData = (key: string, value: string | undefined): boolean => {
const checkValidData = (key: string, value: string | undefined): boolean => {
const current: IHashMap<string> = { ...formData }
current[key] = value as OIDCSignatureAlgorithm
setFormData(current)
const formValid =
current.callbackUrl && current.clientId && current.clientSecret
setIdpUpdateData(
setCallbackData(
formValid
? {
callbackUrl: current.callbackUrl,
Expand Down Expand Up @@ -179,7 +178,7 @@ const OnboardingServiceProvider = () => {
validate={(expr) => isWellknownMetadata(expr)}
hint={t('content.onboardingServiceProvider.callbackUrl.hint')}
debounceTime={0}
onValid={checkData}
onValid={checkValidData}
/>
</div>
<div style={{ margin: '12px 0' }}>
Expand All @@ -189,7 +188,7 @@ const OnboardingServiceProvider = () => {
value={data?.clientId}
hint={t('content.onboardingServiceProvider.clientId.hint')}
validate={isIDPClientID}
onValid={checkData}
onValid={checkValidData}
/>
</div>
<div style={{ margin: '12px 0 30px' }}>
Expand All @@ -204,7 +203,7 @@ const OnboardingServiceProvider = () => {
)}
type={InputType.password}
validate={isIDPClientSecret}
onValid={checkData}
onValid={checkValidData}
/>
</div>
{showError && (
Expand Down Expand Up @@ -257,8 +256,8 @@ const OnboardingServiceProvider = () => {
) : (
<Button
variant="contained"
onClick={doUpdateIDP}
disabled={!idpUpdateData}
onClick={updateCallbackIDP}
disabled={!callbackData}
>
{t('global.actions.confirm')}
</Button>
Expand Down

0 comments on commit 1c420eb

Please sign in to comment.