Skip to content

Commit

Permalink
oppdaterer frontend
Browse files Browse the repository at this point in the history
  • Loading branch information
mettok committed Dec 10, 2024
1 parent 829c23b commit 78cae3c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ jobs:
build_and_deploy:
name: Build, push and deploy
runs-on: ubuntu-latest
env:
REACT_APP_BASE_URL: ${{ secrets.REACT_APP_BASE_URL }}
permissions:
contents: read
id-token: write
Expand Down
4 changes: 2 additions & 2 deletions lps-client-frontend/src/FiltererInntektsmeldinger.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ function FiltererInntektsmeldinger() {
const handleSecondFormSubmit = async () => {
try {
setError(null);
await checkAndRefreshToken();
// await checkAndRefreshToken();
const token = localStorage.getItem('token');
const response = await axios.post('https://hag-lps-api-client.ekstern.dev.nav.no/filterInntektsmeldingerToken', secondFormData, {
const response = await axios.post(`${process.env.REACT_APP_BASE_URL}/filterInntektsmeldingerToken`, secondFormData, {
headers: {
"authorization": `${token}`,
'Content-Type': 'application/x-www-form-urlencoded'
Expand Down
21 changes: 10 additions & 11 deletions lps-client-frontend/src/LoginForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import axios from 'axios';
import { useNavigate } from 'react-router-dom';

function LoginForm() {
const [formData, setFormData] = useState({ kid: '', privateKey: '', issuer: '', consumerOrgNr: '' });
const [formData, setFormData] = useState({ kid: '', privateKey: '', issuer: '', orgnr: '' });
const [error, setError] = useState(null);
const navigate = useNavigate();

Expand All @@ -17,17 +17,16 @@ function LoginForm() {

const handleSubmit = async () => {
try {
const response = await axios.post('https://hag-lps-api-client.ekstern.dev.nav.no/getToken', new URLSearchParams(formData), {
const response = await axios.post(`${process.env.REACT_APP_BASE_URL}/systembruker`, new URLSearchParams(formData), {
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
});
localStorage.setItem('token', response.data.tokenResponse.access_token);
localStorage.setItem('exp', Date.now() + response.data.tokenResponse.expires_in * 1000);
localStorage.setItem('kid', formData.kid);
localStorage.setItem('privateKey', formData.privateKey);
localStorage.setItem('issuer', formData.issuer);
localStorage.setItem('consumerOrgNr', formData.consumerOrgNr);
console.log(response.data);
localStorage.setItem('token', response.data);
// localStorage.setItem('exp', Date.now() + response.data.tokenResponse.expires_in * 1000);
localStorage.setItem('consumerOrgNr', formData.orgnr);
console.log('Token:', response.data);
navigate('/search');
} catch (error) {
setError('Error submitting form');
Expand All @@ -37,7 +36,7 @@ function LoginForm() {
const handleRegistrerNyBedrift = async () => {
try {
const response = await axios.post('http://localhost:8080/registrer-ny-bedrift', {
kundeOrgnr: formData.consumerOrgNr,
kundeOrgnr: formData.orgnr,
}, {
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
Expand All @@ -59,8 +58,8 @@ function LoginForm() {
<Box component="form" noValidate autoComplete="true">
<TextField
label="Consumer orgnr"
name="consumerOrgNr"
value={formData.consumerOrgNr}
name="orgnr"
value={formData.orgnr}
onChange={handleInputChange}
fullWidth
margin="normal"
Expand Down

0 comments on commit 78cae3c

Please sign in to comment.