Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cipp",
"version": "10.4.3",
"version": "10.4.4",
"author": "CIPP Contributors",
"homepage": "https://cipp.app/",
"bugs": {
Expand Down
2 changes: 1 addition & 1 deletion public/version.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"version": "10.4.3"
"version": "10.4.4"
}
2 changes: 1 addition & 1 deletion src/components/CippWizard/CippAddTenantTypeSelection.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export const CippAddTenantTypeSelection = (props) => {
},
{
value: 'IndirectReseller',
label: 'Get Indirect Reseller Invite Link',
label: 'Get Reseller Invite Link',
description:
'Generate a reseller relationship invite link to send to a customer. This does not add the tenant to CIPP, but may be used by other vendors to populate their customer list.',
icon: <LinkIcon />,
Expand Down
86 changes: 39 additions & 47 deletions src/components/CippWizard/CippIndirectResellerLink.jsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { useEffect, useMemo, useState } from 'react'
import { Alert, Autocomplete, Box, Skeleton, Stack, TextField, Typography } from '@mui/material'
import { useEffect, useMemo } from 'react'
import { Alert, Box, Skeleton, Stack, TextField, Typography } from '@mui/material'
import { ApiGetCall } from '../../api/ApiCall'
import { CippWizardStepButtons } from './CippWizardStepButtons'
import { CippCopyToClipBoard } from '../CippComponents/CippCopyToClipboard'
import CippFormComponent from '../CippComponents/CippFormComponent'
import { useWatch } from 'react-hook-form'

export const CippIndirectResellerLink = (props) => {
const { formControl, currentStep, onPreviousStep, onNextStep } = props
const [selectedProvider, setSelectedProvider] = useState(null)

const linkData = ApiGetCall({
url: '/api/ListResellerRelationshipLink',
Expand All @@ -17,27 +18,36 @@ export const CippIndirectResellerLink = (props) => {
const indirectProviders = linkData.data?.indirectProviders ?? []
const inviteUrlError = linkData.data?.inviteUrlError ?? null

const noneOption = { label: 'None (no indirect provider)', value: null }

const providerOptions = useMemo(() => {
const providers = indirectProviders.map((p) => ({
label: `${p.name} — MPN: ${p.mpnId} (${p.location})`,
value: p.id,
}))
return [noneOption, ...providers]
}, [indirectProviders])

useEffect(() => {
if (!linkData.isFetching && providerOptions.length > 0) {
const current = formControl.getValues('indirectProviderId')
if (!current) {
formControl.setValue('indirectProviderId', noneOption)
}
}
}, [linkData.isFetching, providerOptions])

const selectedProvider = useWatch({ control: formControl.control, name: 'indirectProviderId' })

const finalUrl = useMemo(() => {
if (!inviteUrl) return null
if (!selectedProvider) return inviteUrl
// Append the indirect provider ID before the # fragment
if (!selectedProvider?.value) return inviteUrl
const hashIndex = inviteUrl.indexOf('#')
const base = hashIndex !== -1 ? inviteUrl.slice(0, hashIndex) : inviteUrl
const hash = hashIndex !== -1 ? inviteUrl.slice(hashIndex) : ''
return `${base}&indirectCSPId=${selectedProvider.id}${hash}`
return `${base}&indirectCSPId=${selectedProvider.value}${hash}`
}, [inviteUrl, selectedProvider])

const providerOptions = useMemo(
() =>
indirectProviders.map((p) => ({
label: p.name,
id: p.id,
mpnId: p.mpnId,
location: p.location,
})),
[indirectProviders]
)

return (
<Stack spacing={3}>
<Box>
Expand All @@ -53,9 +63,7 @@ export const CippIndirectResellerLink = (props) => {

{linkData.isFetching && (
<Stack spacing={2}>
{/* Indirect provider dropdown skeleton */}
<Skeleton variant="rounded" height={56} />
{/* Link field skeleton */}
<Stack spacing={0.5}>
<Skeleton variant="text" width={80} />
<Skeleton variant="rounded" height={40} />
Expand All @@ -75,32 +83,17 @@ export const CippIndirectResellerLink = (props) => {

{!linkData.isFetching && !linkData.isError && inviteUrl && (
<>
{indirectProviders.length > 0 && (
<Autocomplete
options={providerOptions}
value={selectedProvider}
onChange={(_, value) => setSelectedProvider(value)}
getOptionLabel={(option) => option.label}
renderOption={(renderProps, option) => (
<li {...renderProps} key={option.id}>
<Stack>
<Typography variant="body2">{option.label}</Typography>
<Typography variant="caption" color="text.secondary">
MPN ID: {option.mpnId} · {option.location}
</Typography>
</Stack>
</li>
)}
renderInput={(params) => (
<TextField
{...params}
label="Indirect Provider (optional)"
placeholder="Select to include a direct reseller in the invite"
helperText="If you resell through an indirect provider (e.g. PAX8), select them here to include their ID in the link."
/>
)}
/>
)}
<CippFormComponent
formControl={formControl}
name="indirectProviderId"
label="Indirect Provider"
type="autoComplete"
options={providerOptions}
multiple={false}
creatable={false}
isFetching={linkData.isFetching}
helperText="Select an indirect provider to include their ID in the invite link, or leave as None."
/>

<Box>
<Typography variant="body2" sx={{ mb: 1 }}>
Expand All @@ -110,9 +103,8 @@ export const CippIndirectResellerLink = (props) => {
<TextField
fullWidth
value={finalUrl}
inputProps={{ readOnly: true }}
slotProps={{ input: { readOnly: true } }}
size="small"
sx={{ fontFamily: 'monospace' }}
/>
<CippCopyToClipBoard text={finalUrl} />
</Stack>
Expand Down
2 changes: 1 addition & 1 deletion src/data/portals.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
"target": "_blank",
"external": true,
"icon": "PrecisionManufacturing"
}
},
{
"label": "Power BI",
"name": "Power_BI_Portal",
Expand Down