Skip to content

Commit c0882f2

Browse files
committed
profile
1 parent 98a6822 commit c0882f2

File tree

7 files changed

+54
-6
lines changed

7 files changed

+54
-6
lines changed

.env.development

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
ST_SERVICE_API_ENDPOINT=https://service-api.nightly.staging.colivery.app
2+
ST_MATCHING_API_ENDPOINT=https://matching-api.nightly.staging.colivery.app

.env.production

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
ST_SERVICE_API_ENDPOINT=https://service-api.colivery.app
2+
ST_MATCHING_API_ENDPOINT=https://matching-api.colivery.app

src/config/endpoints.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
// https://colivery-api.s0ra.de/api-docs/swagger-ui/index.html?url=/api-docs/api-docs&validatorUrl=#/
3-
export const SERVICE_API_ENDPOINT = 'https://colivery-app-gttzwulpia-ew.a.run.app';
4-
export const MATCHING_API_ENDPOINT = 'https://matching-api-gttzwulpia-ew.a.run.app/';
3+
export const SERVICE_API_ENDPOINT = process.env.ST_SERVICE_API_ENDPOINT;
4+
export const MATCHING_API_ENDPOINT = process.env.ST_MATCHING_API_ENDPOINT;
55
// temporary access token, expires: Apr 12 2020
66
export const ESRI_API_TOKEN = '5S-CKwF1TuE5Lfh-WPEI34H0tDRlBNG8Cqk9pT-Wc3zu4paCFlWr8sQ8LM6ywfrVe5j2ApQA84Ru88ZW5WadxUAEAby9Ly4CHNfcSuUgXGGWs0P8hyCFifyAECaVZMpr29zl3E8b3ZsH-elOTr676_kjDXGr0hQopfy6h4ZVuohkIEUro1ulwIgK_kVtpKfHRdORsKl43CpjjByiSzVbYA..';
77
export const REVERSE_GEOCODE_API_ENDPOINT = 'https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/reverseGeocode';

src/index.tsx

+1-2
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,8 @@ export class App extends st.component implements ILifecycle {
5656
// example:
5757
this.i18nService.setLanguage(SupportedLanguages.DE);
5858

59-
console.log('i18n test', st.t('Hello, world!'));
6059

61-
console.log('i18n virtualNode (used with render())', <T tag="p" style={{ color: '#cc0000' }}>Hello, world</T>);
60+
console.log('endpoint', process.env.ST_SERVICE_API_ENDPOINT);
6261

6362

6463
/*

src/page/user-profile/user-profile.tpl.tsx

+17-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { UserProfilePage } from "./user-profile";
66
import { ErrorMessage } from "../../component/error-message/error-message";
77
import { MatModal } from "../../component/mat/mat-modal";
88
import { MatLoadingIndicator } from "../../component/mat/mat-loading-indicator";
9+
import { MatCard } from "../../component/mat/mat-card";
910

1011
export default (component: UserProfilePage) => (
1112
<fragment>
@@ -21,13 +22,28 @@ export default (component: UserProfilePage) => (
2122
</center>
2223
</div>
2324

24-
<div ref={{ formContainer: component}}>
25+
<div ref={{ formContainer: component }}>
2526
</div>
2627
<ErrorMessage ref={{ errorMessage: component }}
2728
class={['col', 's12', 'm6', 'offset-m3', 'l4', 'offset-l4']} />
2829

2930
<a ref={{ submitButton: component }} style={{ marginTop: '10px' }} class={['waves-effect', 'waves-light', 'btn', 'col', 's12', 'm6', 'offset-m3', 'l4', 'offset-l4']}
3031
onClick={component.updateUserProfile}>Speichern</a>
32+
33+
</div>
34+
<div class="row">
35+
<MatCard>
36+
<center>
37+
<h5>Achtung</h5>
38+
<p>
39+
Diese Aktion kann nicht rückgängig gemacht werden.
40+
<br />
41+
<br />
42+
</p>
43+
<a ref={{ deleteButton: component }} class={['waves-effect', 'waves-light', 'btn', 'cancel-button']}
44+
onClick={component.deleteUserProfile}>Benutzerkonto löschen</a>
45+
</center>
46+
</MatCard>
3147
</div>
3248
</div>
3349

src/page/user-profile/user-profile.tsx

+7
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ export class UserProfilePage extends st.component implements ILifecycle {
6565
@ref
6666
formContainer: HTMLElement;
6767

68+
@ref
69+
deleteButton: HTMLElement;
70+
6871
userGeoLocation: {
6972
lat: number;
7073
lng: number;
@@ -212,4 +215,8 @@ export class UserProfilePage extends st.component implements ILifecycle {
212215
<MatLoaderCircle ref={{ matLoaderCircle: this }} class={['col', 's12',]} />
213216
</fragment>
214217
}
218+
219+
deleteUserProfile = () => {
220+
console.log('deleteUserProfile')
221+
}
215222
}

src/service/user.ts

+23-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,29 @@ export class UserService {
1414
@inject(StorageService)
1515
storageService: StorageService;
1616

17-
async getUserProfile(): Promise<IUserProfileResponse | undefined> {
17+
async deleteOwnUser(): Promise<void> {
18+
19+
try {
20+
await fetch(`${SERVICE_API_ENDPOINT}/user/own/delete`, {
21+
method: 'GET',
22+
mode: 'cors', // no-cors, *cors, same-origin
23+
cache: 'no-cache', // *default, no-cache, reload, force-cache, only-if-cached
24+
credentials: 'same-origin', // include, *same-origin, omit
25+
headers: {
26+
'Content-Type': 'application/json',
27+
"Accept": "application/json",
28+
'Authorization': `Bearer ${await window.authService.getIdToken()}`
29+
},
30+
redirect: 'follow',
31+
referrerPolicy: 'no-referrer', // no-referrer, *client
32+
});
33+
34+
} catch (e) {
35+
st.error('error in deleting user profile', e)
36+
}
37+
}
38+
39+
async getUserProfile(): Promise<IUserProfileResponse | void> {
1840

1941
if (this.userProfile) {
2042
return this.userProfile;

0 commit comments

Comments
 (0)