fix(marks): add default signer
All checks were successful
Open PR on Staging / audit_and_check (pull_request) Successful in 33s
All checks were successful
Open PR on Staging / audit_and_check (pull_request) Successful in 33s
This commit is contained in:
parent
f8a4480994
commit
dfdcb8419d
@ -37,6 +37,8 @@ interface Props {
|
|||||||
|
|
||||||
export const DrawPDFFields = (props: Props) => {
|
export const DrawPDFFields = (props: Props) => {
|
||||||
const { selectedFiles, selectedTool, onDrawFieldsChange, users } = props
|
const { selectedFiles, selectedTool, onDrawFieldsChange, users } = props
|
||||||
|
const signers = users.filter((u) => u.role === UserRole.signer)
|
||||||
|
const defaultSignerNpub = signers.length ? hexToNpub(signers[0].pubkey) : ''
|
||||||
const { to, from } = useScale()
|
const { to, from } = useScale()
|
||||||
|
|
||||||
const [sigitFiles, setSigitFiles] = useState<SigitFile[]>([])
|
const [sigitFiles, setSigitFiles] = useState<SigitFile[]>([])
|
||||||
@ -115,7 +117,7 @@ export const DrawPDFFields = (props: Props) => {
|
|||||||
top: to(page.width, y),
|
top: to(page.width, y),
|
||||||
width: event.pointerType === 'mouse' ? 0 : DEFAULT_START_SIZE.width,
|
width: event.pointerType === 'mouse' ? 0 : DEFAULT_START_SIZE.width,
|
||||||
height: event.pointerType === 'mouse' ? 0 : DEFAULT_START_SIZE.height,
|
height: event.pointerType === 'mouse' ? 0 : DEFAULT_START_SIZE.height,
|
||||||
counterpart: '',
|
counterpart: defaultSignerNpub,
|
||||||
type: selectedTool.identifier
|
type: selectedTool.identifier
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -453,7 +455,9 @@ export const DrawPDFFields = (props: Props) => {
|
|||||||
<FormControl fullWidth size="small">
|
<FormControl fullWidth size="small">
|
||||||
<InputLabel id="counterparts">Counterpart</InputLabel>
|
<InputLabel id="counterparts">Counterpart</InputLabel>
|
||||||
<Select
|
<Select
|
||||||
value={drawnField.counterpart}
|
value={
|
||||||
|
drawnField.counterpart || defaultSignerNpub || ''
|
||||||
|
}
|
||||||
onChange={(event) => {
|
onChange={(event) => {
|
||||||
drawnField.counterpart = event.target.value
|
drawnField.counterpart = event.target.value
|
||||||
refreshPdfFiles()
|
refreshPdfFiles()
|
||||||
@ -465,52 +469,47 @@ export const DrawPDFFields = (props: Props) => {
|
|||||||
}}
|
}}
|
||||||
renderValue={(value) => renderCounterpartValue(value)}
|
renderValue={(value) => renderCounterpartValue(value)}
|
||||||
>
|
>
|
||||||
{users
|
{signers.map((signer, index) => {
|
||||||
.filter((u) => u.role === UserRole.signer)
|
const npub = hexToNpub(signer.pubkey)
|
||||||
.map((user, index) => {
|
let displayValue = truncate(npub, {
|
||||||
const npub = hexToNpub(user.pubkey)
|
length: 16
|
||||||
let displayValue = truncate(npub, {
|
})
|
||||||
length: 16
|
|
||||||
})
|
|
||||||
|
|
||||||
const metadata = props.metadata[user.pubkey]
|
const metadata = props.metadata[signer.pubkey]
|
||||||
|
|
||||||
if (metadata) {
|
if (metadata) {
|
||||||
displayValue = truncate(
|
displayValue = truncate(
|
||||||
metadata.name ||
|
metadata.name ||
|
||||||
metadata.display_name ||
|
metadata.display_name ||
|
||||||
metadata.username ||
|
metadata.username ||
|
||||||
npub,
|
npub,
|
||||||
{
|
{
|
||||||
length: 16
|
length: 16
|
||||||
}
|
}
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<MenuItem
|
|
||||||
key={index}
|
|
||||||
value={hexToNpub(user.pubkey)}
|
|
||||||
>
|
|
||||||
<ListItemIcon>
|
|
||||||
<AvatarIconButton
|
|
||||||
src={metadata?.picture}
|
|
||||||
hexKey={user.pubkey}
|
|
||||||
aria-label={`account of user ${displayValue}`}
|
|
||||||
color="inherit"
|
|
||||||
sx={{
|
|
||||||
padding: 0,
|
|
||||||
'> img': {
|
|
||||||
width: '30px',
|
|
||||||
height: '30px'
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</ListItemIcon>
|
|
||||||
<ListItemText>{displayValue}</ListItemText>
|
|
||||||
</MenuItem>
|
|
||||||
)
|
)
|
||||||
})}
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<MenuItem key={index} value={npub}>
|
||||||
|
<ListItemIcon>
|
||||||
|
<AvatarIconButton
|
||||||
|
src={metadata?.picture}
|
||||||
|
hexKey={signer.pubkey}
|
||||||
|
aria-label={`account of user ${displayValue}`}
|
||||||
|
color="inherit"
|
||||||
|
sx={{
|
||||||
|
padding: 0,
|
||||||
|
'> img': {
|
||||||
|
width: '30px',
|
||||||
|
height: '30px'
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</ListItemIcon>
|
||||||
|
<ListItemText>{displayValue}</ListItemText>
|
||||||
|
</MenuItem>
|
||||||
|
)
|
||||||
|
})}
|
||||||
</Select>
|
</Select>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
</div>
|
</div>
|
||||||
@ -524,28 +523,28 @@ export const DrawPDFFields = (props: Props) => {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const renderCounterpartValue = (value: string) => {
|
const renderCounterpartValue = (npub: string) => {
|
||||||
const user = users.find((u) => u.pubkey === npubToHex(value))
|
let displayValue = truncate(npub, {
|
||||||
if (user) {
|
length: 16
|
||||||
let displayValue = truncate(value, {
|
})
|
||||||
length: 16
|
|
||||||
})
|
|
||||||
|
|
||||||
const metadata = props.metadata[user.pubkey]
|
|
||||||
|
|
||||||
|
const signer = signers.find((u) => u.pubkey === npubToHex(npub))
|
||||||
|
if (signer) {
|
||||||
|
const metadata = props.metadata[signer.pubkey]
|
||||||
if (metadata) {
|
if (metadata) {
|
||||||
displayValue = truncate(
|
displayValue = truncate(
|
||||||
metadata.name || metadata.display_name || metadata.username || value,
|
metadata.display_name || metadata.name || npub,
|
||||||
{
|
{
|
||||||
length: 16
|
length: 16
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<AvatarIconButton
|
<AvatarIconButton
|
||||||
src={props.metadata[user.pubkey]?.picture}
|
src={props.metadata[signer.pubkey]?.picture}
|
||||||
hexKey={npubToHex(user.pubkey) || undefined}
|
hexKey={signer.pubkey || undefined}
|
||||||
sx={{
|
sx={{
|
||||||
padding: 0,
|
padding: 0,
|
||||||
marginRight: '6px',
|
marginRight: '6px',
|
||||||
@ -560,7 +559,7 @@ export const DrawPDFFields = (props: Props) => {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
return value
|
return displayValue
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parsingPdf) {
|
if (parsingPdf) {
|
||||||
|
Loading…
Reference in New Issue
Block a user