Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(app-release): add privacy policy validation #132

Merged
Merged
Show file tree
Hide file tree
Changes from 3 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
- New Header and Filter UI
- App Release Process
- App lead image load issue fix
- Validation added for privacy policy
- Service Marketplace
- Subscription Button cross service highlighted
- BugFix
Expand Down
3 changes: 2 additions & 1 deletion src/assets/locales/de/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -966,7 +966,8 @@
"pleaseEnterValidContact": "Please enter a valid Provider Phone Contact in the format +xx (xxx) xxxxxxxxxx; +xx xxxxxxxxxx and +xxxxxxxxxxxx",
"privacyInformation": "Privacy Information",
"privacyInformationDescription": "The privacy information is used to display data types the app may collect on the app detail page. You may select several options OR select “none”.",
"privacyInfoError": "Error - values couldn't get fetched. Please try it later again"
"privacyInfoError": "Error - values couldn't get fetched. Please try it later again or contact your administrator.",
"privacyInformationMandatory": "Privacy Information is mandatory"
},
"contractAndConsent": {
"headerTitle": "Consent & Contract",
Expand Down
3 changes: 2 additions & 1 deletion src/assets/locales/en/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -928,7 +928,8 @@
"pleaseEnterValidContact": "Please enter a valid Provider Phone Contact in the format +xx (xxx) xxxxxxxxxx; +xx xxxxxxxxxx and +xxxxxxxxxxxx",
"privacyInformation": "Privacy Information",
"privacyInformationDescription": "The privacy information is used to display data types the app may collect on the app detail page. You may select several options OR select “none”.",
"privacyInfoError": "Error - values couldn't get fetched. Please try it later again"
"privacyInfoError": "Error - values couldn't get fetched. Please try it later again or contact your administrator.",
"privacyInformationMandatory": "Privacy Information is mandatory"
},
"contractAndConsent": {
"headerTitle": "Consent & Contract",
Expand Down
54 changes: 35 additions & 19 deletions src/components/shared/basic/ReleaseProcess/AppPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ export default function AppPage() {

const [deleteAppReleaseDocument, deleteResponse] =
useDeleteAppReleaseDocumentMutation()
const [privacyError, setPrivacyError] = useState<boolean>(false)

useEffect(() => {
deleteResponse.isSuccess && setDeleteSuccess(true)
}, [deleteResponse])
Expand Down Expand Up @@ -336,6 +338,7 @@ export default function AppPage() {
}

const onAppPageSubmit = async (data: FormDataType, buttonLabel: string) => {
if (selectedPrivacyPolicies.length === 0) setPrivacyError(true)
const validateFields = await trigger([
'longDescriptionEN',
'longDescriptionDE',
Expand All @@ -347,8 +350,9 @@ export default function AppPage() {
'providerContactEmail',
'providerPhoneContact',
])
if (validateFields) {
if (validateFields && selectedPrivacyPolicies.length > 0) {
setLoading(true)
setPrivacyError(false)
void handleSave(data, buttonLabel)
}
}
Expand Down Expand Up @@ -379,7 +383,7 @@ export default function AppPage() {
useCaseIds: statusData.useCase?.map((item: UseCaseType) => item.id),
supportedLanguageCodes: statusData.supportedLanguageCodes,
price: statusData.price,
privacyPolicies: selectedPrivacyPolicies || [],
privacyPolicies: selectedPrivacyPolicies,
providerUri: data.providerHomePage || '',
contactEmail: data.providerContactEmail || '',
contactNumber: data.providerPhoneContact || '',
Expand All @@ -400,30 +404,37 @@ export default function AppPage() {
dispatch(decrement())
}

const selectCheckboxPrivacyPolicies = (policy: string, select: boolean) => {
if (
selectedPrivacyPolicies &&
selectedPrivacyPolicies[0] === privacyPolicyNone
) {
setSelectedPrivacyPolicies([...[], policy])
} else {
const isSelected = selectedPrivacyPolicies?.includes(policy)
if (isSelected && selectedPrivacyPolicies.length === 1)
setPrivacyError(true)
if (!isSelected && select) {
setSelectedPrivacyPolicies([...selectedPrivacyPolicies, policy])
} else if (isSelected && !select) {
const oldPrivacyPolicies = [...selectedPrivacyPolicies]
oldPrivacyPolicies.splice(oldPrivacyPolicies.indexOf(policy), 1)
setSelectedPrivacyPolicies([...oldPrivacyPolicies])
}
}
}

const selectPrivacyPolicies = (
policy: string,
select: boolean,
type: string
) => {
if (type === 'checkbox') {
if (
selectedPrivacyPolicies &&
selectedPrivacyPolicies[0] === privacyPolicyNone
) {
setSelectedPrivacyPolicies([...[], policy])
} else {
const isSelected = selectedPrivacyPolicies?.includes(policy)
if (!isSelected && select) {
setSelectedPrivacyPolicies([...selectedPrivacyPolicies, policy])
} else if (isSelected && !select) {
const oldPrivacyPolicies = [...selectedPrivacyPolicies]
oldPrivacyPolicies.splice(oldPrivacyPolicies.indexOf(policy), 1)
setSelectedPrivacyPolicies([...oldPrivacyPolicies])
}
}
selectCheckboxPrivacyPolicies(policy, select)
} else if (type === 'radio') {
setSelectedPrivacyPolicies([...[], policy])
}
if (selectedPrivacyPolicies.length === 0) setPrivacyError(false)
}

const renderDropArea = (props: DropAreaProps) => {
Expand Down Expand Up @@ -661,7 +672,7 @@ export default function AppPage() {
/>
<Divider sx={{ mb: 2, mr: -2, ml: -2 }} />
<InputLabel sx={{ mb: 3 }}>
{t('content.apprelease.appPage.privacyInformation')}
{t('content.apprelease.appPage.privacyInformation') + ' *'}
</InputLabel>
<Typography variant="body2" sx={{ marginBottom: '10px' }}>
{t('content.apprelease.appPage.privacyInformationDescription')}
Expand Down Expand Up @@ -711,6 +722,11 @@ export default function AppPage() {
</Alert>
</Box>
)}
{privacyError && (
<Typography variant="body2" className="file-error-msg">
{t('content.apprelease.appPage.privacyInformationMandatory')}
</Typography>
)}
</form>
<SnackbarNotificationWithButtons
pageNotification={appPageNotification}
Expand All @@ -731,7 +747,7 @@ export default function AppPage() {
onSaveAndProceed={handleSubmit((data) =>
onAppPageSubmit(data, ButtonLabelTypes.SAVE_AND_PROCEED)
)}
isValid={isValid}
isValid={isValid && selectedPrivacyPolicies.length > 0}
loader={loading}
helpUrl={
'/documentation/?path=docs%2F04.+App%28s%29%2F02.+App+Release+Process'
Expand Down