-
Notifications
You must be signed in to change notification settings - Fork 2
Feature/lagre siste soek #3917
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
Merged
Feature/lagre siste soek #3917
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
73130ac
Lagre soek design
betsytraran e0b25a5
Post lagret soek
betsytraran e892a24
Div tilpasninger paa lagring og visning av siste soek
betsytraran 1d6d003
Merge branch 'master' of https://github.com/navikt/testnorge into fea…
betsytraran d01d96b
Forbedret forhold mellom siste soek og form
betsytraran 5d77169
Tilpass visning av chips
betsytraran 2bf682b
Lagring av soek med adresse + div fix
betsytraran 0651a59
Handle change list
betsytraran 5f98d96
Fix lagring av skjerming
betsytraran 8f72daa
Fix toem kategori
betsytraran 6580fbc
Merge branch 'master' of https://github.com/navikt/testnorge into fea…
betsytraran 072119e
Fix
betsytraran 85f2ecc
Merge branch 'master' of https://github.com/navikt/testnorge into fea…
betsytraran 27590e8
Fix lagring og visning av miljoer
betsytraran 2d6bf82
Set isLoading paa felter i tenor-soek
betsytraran 5b3ab8b
Oppsett av siste soek i tenor-soek + div tilpasninger
betsytraran c1b98c7
Div bugfix paa TextInput DateInput Monthpicker ++
betsytraran bd79c54
Fikset merge conflicts
betsytraran 5359058
Soekefelter statsborgerskap
betsytraran 2a7e8d4
Merge branch 'master' of https://github.com/navikt/testnorge into fea…
betsytraran 08f11ef
Omskrivning av DollySoek og div opprydning
betsytraran c4c1a83
Merge branch 'master' of https://github.com/navikt/testnorge into fea…
betsytraran 63bd515
Felles handleclick paa sistesoek
betsytraran af50e33
Fix empty category tenorsoek
betsytraran 14b9536
Opprydning siste soek
betsytraran cf96758
Merge branch 'master' of https://github.com/navikt/testnorge into fea…
betsytraran c6e34b2
Fix brukernavnvelger
betsytraran 333c8e7
Deploy test #deploy-test-frontend
betsytraran 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
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
94 changes: 94 additions & 0 deletions
94
apps/dolly-frontend/src/main/js/src/components/ui/soekForm/SisteSoek.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,94 @@ | ||
import { useHentLagredeSoek } from '@/utils/hooks/useSoek' | ||
import { Chips, VStack } from '@navikt/ds-react' | ||
import * as _ from 'lodash-es' | ||
import { isDate, isSameDay, isValid } from 'date-fns' | ||
|
||
export enum soekType { | ||
dolly = 'DOLLY', | ||
tenor = 'TENOR', | ||
} | ||
|
||
const listOptions = [ | ||
'registreRequest', | ||
'miljoer', | ||
'utenlandskPersonIdentifikasjon', | ||
'roller', | ||
'inntekt.inntektstyper', | ||
'inntekt.forskuddstrekk', | ||
] | ||
|
||
export const SisteSoek = ({ type, formValues, handleChange, handleChangeList }) => { | ||
const { lagredeSoek } = useHentLagredeSoek(type) | ||
|
||
const lagredeSoekData = [] | ||
lagredeSoek?.forEach((soek) => { | ||
Object.entries(soek?.soekVerdi)?.forEach((verdi) => { | ||
if (listOptions.includes(verdi[0]) && Array.isArray(verdi[1])) { | ||
verdi[1]?.forEach((item) => { | ||
if (!lagredeSoekData?.some((i) => i.value === item.value)) { | ||
lagredeSoekData.push(item) | ||
} | ||
}) | ||
} else if (verdi[1]?.path && !lagredeSoekData?.some((item) => item.path === verdi[1]?.path)) { | ||
lagredeSoekData.push(verdi[1]) | ||
} | ||
}) | ||
}) | ||
|
||
const isSelected = (option) => { | ||
const { path, value } = option | ||
const formValue = _.get(formValues, path) | ||
if (listOptions.includes(path)) { | ||
return formValue?.includes(value) | ||
} else if ( | ||
formValue?.length > 8 && | ||
isDate(new Date(formValue)) && | ||
isValid(new Date(formValue)) | ||
) { | ||
return isSameDay(new Date(formValue), new Date(value)) | ||
} | ||
return formValue === value | ||
} | ||
|
||
const handleClick = (option) => { | ||
const formValue = _.get(formValues, option.path) | ||
if (listOptions.includes(option.path)) { | ||
const listValues = formValue || [] | ||
handleChangeList( | ||
!listValues?.includes(option.value) | ||
? [...listValues, option.value] | ||
: listValues?.filter((item) => item !== option.value), | ||
option.path, | ||
option.label, | ||
) | ||
} else if ( | ||
formValue?.length > 8 && | ||
isDate(new Date(formValue)) && | ||
isValid(new Date(formValue)) | ||
) { | ||
handleChange( | ||
!isSameDay(new Date(formValue), new Date(option.value)) ? option.value : null, | ||
option.path, | ||
option.label, | ||
) | ||
} else { | ||
handleChange(formValue !== option.value ? option.value : null, option.path, option.label) | ||
} | ||
} | ||
|
||
return ( | ||
<VStack gap="3" style={{ marginBottom: '15px' }}> | ||
<Chips> | ||
{lagredeSoekData?.slice(0, 10).map((option, idx) => ( | ||
<Chips.Toggle | ||
key={option.label} | ||
selected={isSelected(option)} | ||
onClick={() => handleClick(option)} | ||
> | ||
{option.label} | ||
</Chips.Toggle> | ||
))} | ||
</Chips> | ||
</VStack> | ||
) | ||
} |
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 |
---|---|---|
|
@@ -53,6 +53,7 @@ export default ({ eksisterendeBrukernavn, organisasjon, addToSession }: Brukerna | |
resolver: yupResolver(validation), | ||
mode: 'onChange', | ||
}) | ||
|
||
const [loading, setLoading] = useState(false) | ||
const [error, setError] = useState(null as string | null) | ||
|
||
|
@@ -115,8 +116,15 @@ export default ({ eksisterendeBrukernavn, organisasjon, addToSession }: Brukerna | |
size="large" | ||
defaultValue={eksisterendeBrukernavn} | ||
isDisabled={loading || !!eksisterendeBrukernavn} | ||
useControlled | ||
/> | ||
<DollyTextInput | ||
name="epost" | ||
label="Epost" | ||
size="large" | ||
isDisabled={loading} | ||
useControlled | ||
Comment on lines
+119
to
+126
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [nitpick] The Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||
/> | ||
<DollyTextInput name="epost" label="Epost" size="large" isDisabled={loading} /> | ||
<ButtonDiv> | ||
<NavButton | ||
type="submit" | ||
|
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The component parameters are not typed. Consider adding TypeScript interfaces for better type safety and developer experience.
Copilot uses AI. Check for mistakes.