-
Notifications
You must be signed in to change notification settings - Fork 2
feat: create purpose first step API thresholds (PIN-9125) #1663
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
Merged
borgesis95
merged 5 commits into
feature/PIN-8882_soglie_differenziate
from
feature/PIN-9125_create-purpose-first-step
Feb 13, 2026
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
1d6b75a
feat: create purpose first step API thresholds (PIN-9125)
l-giacomini 6fbdb38
feat: fixed open points (PIN-9125)
l-giacomini acf1969
feat: fixed translations (PIN-9125)
l-giacomini caf6547
Merge branch 'feature/PIN-8882_soglie_differenziate' into feature/PIN…
l-giacomini 1556619
feat: added missing description, externalized grey alert component (P…
l-giacomini File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| import { Alert } from '@mui/material' | ||
| import React from 'react' | ||
|
|
||
| interface GreyAlertProps { | ||
| children: React.ReactNode | ||
| } | ||
|
|
||
| export const GreyAlert: React.FC<GreyAlertProps> = ({ children }) => { | ||
| return ( | ||
| <Alert icon={false} sx={{ p: 2, borderLeftColor: 'grey.700', backgroundColor: 'grey.50' }}> | ||
| {children} | ||
| </Alert> | ||
| ) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
...nsumerPurposeEditPage/hooks/__tests__/useGetConsumerPurposeEditPageInfoAlertProps.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| import { renderHook } from '@testing-library/react' | ||
| import { useGetConsumerPurposeEditPageInfoAlertProps } from '../useGetConsumerPurposeEditPageInfoAlertProps' | ||
|
|
||
| describe('useGetConsumerPurposeInfoAlertProps', () => { | ||
| it('should return undefined if there is no exceed', () => { | ||
| const { result } = renderHook(() => useGetConsumerPurposeEditPageInfoAlertProps(1, 10, 100)) | ||
| expect(result.current).toStrictEqual(undefined) | ||
| }) | ||
| it('should return infoDailyCallsPerConsumerExceed if dailyCalls > dailyCallsPerConsumer', () => { | ||
| const { result } = renderHook(() => useGetConsumerPurposeEditPageInfoAlertProps(11, 10, 100)) | ||
| expect(result.current).toStrictEqual({ | ||
| children: 'infoDailyCallsPerConsumerExceed', | ||
| severity: 'info', | ||
| }) | ||
| }) | ||
| it('should return infoDailyCallsTotalExceed if dailyCalls > dailyCallsTotal', () => { | ||
| const { result } = renderHook(() => useGetConsumerPurposeEditPageInfoAlertProps(111, 10, 100)) | ||
| expect(result.current).toStrictEqual({ | ||
| children: 'infoDailyCallsTotalExceed', | ||
| severity: 'info', | ||
| }) | ||
| }) | ||
| }) |
27 changes: 27 additions & 0 deletions
27
src/pages/ConsumerPurposeEditPage/hooks/useGetConsumerPurposeEditPageInfoAlertProps.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| import type { AlertProps } from '@mui/material' | ||
l-giacomini marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| import { useTranslation } from 'react-i18next' | ||
| import { match } from 'ts-pattern' | ||
|
|
||
| export function useGetConsumerPurposeEditPageInfoAlertProps( | ||
| dailyCalls: number, | ||
| dailyCallsPerConsumer: number, | ||
| dailyCallsTotal: number | ||
| ): AlertProps | undefined { | ||
| const { t } = useTranslation('purpose', { keyPrefix: 'edit.loadEstimationSection.alerts' }) | ||
|
|
||
| return match({ | ||
| isDailyCallsPerConsumerExceed: dailyCalls > dailyCallsPerConsumer, | ||
| isDailyCallsTotalExceed: dailyCalls > dailyCallsTotal, | ||
| }) | ||
| .returnType<AlertProps | undefined>() | ||
| .with({ isDailyCallsTotalExceed: true }, () => ({ | ||
| severity: 'info', | ||
| children: t('infoDailyCallsTotalExceed'), | ||
| })) | ||
| .with({ isDailyCallsPerConsumerExceed: true }, () => ({ | ||
| severity: 'info', | ||
| children: t('infoDailyCallsPerConsumerExceed'), | ||
| })) | ||
| .otherwise(() => undefined) | ||
| /* @TODO - Add residual threshold cases */ | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.