Skip to content

Commit

Permalink
fix: Resetting sharing rights after a share
Browse files Browse the repository at this point in the history
  • Loading branch information
cballevre committed Apr 9, 2024
1 parent f64ee06 commit 5f3ebaa
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions packages/cozy-sharing/src/components/ShareByEmail.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,11 @@ export const ShareByEmail = ({

const [recipients, setRecipients] = useState([])
const [loading, setLoading] = useState(false)
const [selectedOption, setSelectedOption] = useState()
const [selectedOption, setSelectedOption] = useState('readWrite')
const [showRecipientsLimit, setRecipientsLimit] = useState(false)

const reset = () => {
setSelectedOption('readWrite')
setRecipients([])
setLoading(false)
}
Expand Down Expand Up @@ -102,7 +103,6 @@ export const ShareByEmail = ({
severity: 'success',
variant: 'filled'
})
reset()
} catch (err) {
let showGenericAlert = true
if (err.name === 'FetchError' && err.status === 400) {
Expand Down Expand Up @@ -137,8 +137,9 @@ export const ShareByEmail = ({
})
}

reset()
throw err
} finally {
reset()
}
}

Expand Down Expand Up @@ -180,7 +181,11 @@ export const ShareByEmail = ({
</div>
{showShareControl && (
<div className={styles['share-type-control']}>
<ShareTypeSelect options={getSharingOptions()} onChange={onChange} />
<ShareTypeSelect
value={selectedOption}
options={getSharingOptions()}
onChange={onChange}
/>
<ShareSubmit
label={t(`${documentType}.share.shareByEmail.send`)}
onSubmit={share}
Expand Down

0 comments on commit 5f3ebaa

Please sign in to comment.