Skip to content

Commit

Permalink
Refaktor
Browse files Browse the repository at this point in the history
#deploy-endringsmelding-frontend
#deploy-endringsmelding-service
  • Loading branch information
stigus committed Mar 7, 2024
1 parent 8790bcd commit fde9e4b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
2 changes: 1 addition & 1 deletion apps/endringsmelding-frontend/src/main/js/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const App = () => (
<Header title="Endringsmeldinger" profile={<ProfilLoader {...ProfilService} />} />
<Routes>
<Route path="/login" element={<LoginPage />} />
<Route path="/" element={<EndringsmeldingPage />} />
<Route path="*" element={<EndringsmeldingPage />} />
</Routes>
</Router>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import {
WarningAlert,
WarningAlertstripe,
} from '@navikt/dolly-komponenter';
import { Action } from '@/pages/endringsmelding-page/form/endringsmelding-form/EndringsmeldingReducer';
import _ from 'lodash';
import { Api } from '@navikt/dolly-lib';

const Search = styled.div`
display: flex;
Expand Down Expand Up @@ -57,7 +57,7 @@ const StyledWarning = styled(WarningAlertstripe)`
width: -webkit-fill-available;
`;

export default <T extends unknown>({ labels, onChange, setMiljoer, dispatch }: Props<T>) => {
export default <T extends unknown>({ labels, onChange, setMiljoer }: Props<T>) => {
const [value, setValue] = useState('');
const [search, setSearch] = useState(null);
const [response, setResponse] = useState(null);
Expand All @@ -67,13 +67,18 @@ export default <T extends unknown>({ labels, onChange, setMiljoer, dispatch }: P
const hentMiljoeInfo = async (ident: string) => {
setError(false);
setLoading(true);
return fetch(`/endringsmelding-service/api/v1/ident/miljoer`, {
method: 'POST',
body: JSON.stringify({ ident }),
})
return Api.fetchJson(
`/endringsmelding-service/api/v1/ident/miljoer`,
{
method: 'POST',
headers: { 'Content-Type': 'application/json' },
},
JSON.stringify({ ident }),
)
.then((res) => {
console.log('res: ', res); //TODO - SLETT MEG
setLoading(false);
setResponse(res.json());
setResponse(res);
})
.catch((reason) => {
setLoading(false);
Expand All @@ -93,6 +98,8 @@ export default <T extends unknown>({ labels, onChange, setMiljoer, dispatch }: P
useEffect(() => {
if (search && search.length === 11) {
hentMiljoeInfo(search);
} else {
setError('Ident må være 11 siffer.');
}
}, [search]);

Expand Down

0 comments on commit fde9e4b

Please sign in to comment.