Skip to content

Commit 869b9d5

Browse files
committed
WIP
1 parent 2d15a10 commit 869b9d5

File tree

5 files changed

+61
-16
lines changed

5 files changed

+61
-16
lines changed

app/actions/data.ts

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import type {
2+
AdditionalFlatData,
23
FlatData,
34
OverviewDataEntry,
4-
RawFlatData,
5+
RawFlatDataExpose,
6+
RawFlatDataUtag,
57
RawOverviewData,
68
RawOverviewDataEntry,
79
StringBoolean,
@@ -99,17 +101,24 @@ export function getOverviewData(): ThunkAction {
99101
};
100102
}
101103

102-
function processFlatData(flatData: RawFlatData): FlatData {
104+
function processFlatData(
105+
flatDataUtag: RawFlatDataUtag,
106+
flatDataExpose: RawFlatDataExpose,
107+
additionalFlatData: AdditionalFlatData
108+
): FlatData {
103109
return {
104-
id: flatData.obj_scoutId,
105-
yearConstructed: parseInt(flatData.obj_yearConstructed, 10),
106-
floor: parseInt(flatData.obj_floor, 10),
110+
id: flatDataUtag.obj_scoutId,
111+
yearConstructed: parseInt(flatDataUtag.obj_yearConstructed, 10),
112+
floor: parseInt(flatDataUtag.obj_floor, 10),
107113
rent: {
108-
total: parseFloat(flatData.obj_totalRent),
109-
base: parseFloat(flatData.obj_baseRent),
110-
additional: parseFloat(flatData.obj_serviceCharge)
114+
total: parseFloat(flatDataUtag.obj_totalRent),
115+
base: parseFloat(flatDataUtag.obj_baseRent),
116+
additional: parseFloat(flatDataUtag.obj_serviceCharge)
111117
},
112-
requiresWBS: flatData.additionalData.requiresWBS
118+
applicationLinksExternally: Boolean(
119+
flatDataExpose.contactData.contactButton.clickOutUrl
120+
),
121+
requiresWBS: additionalFlatData.requiresWBS
113122
};
114123
}
115124

@@ -118,13 +127,23 @@ export function getFlatData(): ThunkAction {
118127
const electronUtils = new ElectronUtils(
119128
electronObjects.views.puppet.webContents
120129
);
121-
const rawFlatData: RawFlatData = await electronUtils.evaluate(`utag_data`);
122-
rawFlatData.additionalData = {
130+
const rawFlatDataUtag: RawFlatDataUtag =
131+
await electronUtils.evaluate(`utag_data`);
132+
const rawFlatDataExpose: RawFlatDataExpose = await electronUtils.evaluate(
133+
`JSON.parse(JSON.stringify(IS24.expose))`
134+
);
135+
const additionalData = {
123136
requiresWBS: await electronUtils.elementExists(
124137
'.is24qa-wohnberechtigungsschein-erforderlich-label'
125138
)
126139
};
127-
const flatData = processFlatData(rawFlatData);
140+
console.log(rawFlatDataExpose);
141+
const flatData = processFlatData(
142+
rawFlatDataUtag,
143+
rawFlatDataExpose,
144+
additionalData
145+
);
146+
console.log(flatData);
128147
dispatch({
129148
type: SET_FLAT_DATA,
130149
payload: {

app/flat/assessment.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,13 @@ export function assessFlat(
167167
result: flatData.yearConstructed < 1950
168168
});
169169
}
170+
171+
if (flatData.applicationLinksExternally) {
172+
reasons.push({
173+
reason: `Verweist auf externe Website`,
174+
result: false
175+
});
176+
}
170177
}
171178

172179
const result = reasons.every((reason) => reason.result);

app/reducers/data.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,17 +98,24 @@ export type OverviewDataEntry = {
9898
isPartOfProject: boolean;
9999
hasAlreadyApplied: boolean;
100100
};
101-
export type RawFlatData = {
101+
export type RawFlatDataUtag = {
102102
obj_scoutId: string;
103103
obj_yearConstructed: string;
104104
obj_totalRent: string;
105105
obj_baseRent: string;
106106
obj_serviceCharge: string;
107107
obj_floor: string;
108-
additionalData: {
109-
requiresWBS: boolean;
108+
};
109+
export type RawFlatDataExpose = {
110+
contactData: {
111+
contactButton: {
112+
clickOutUrl?: string;
113+
};
110114
};
111115
};
116+
export type AdditionalFlatData = {
117+
requiresWBS: boolean;
118+
};
112119
export type FlatData = {
113120
id: string;
114121
yearConstructed: number;
@@ -118,6 +125,7 @@ export type FlatData = {
118125
additional: number;
119126
};
120127
floor: number;
128+
applicationLinksExternally: boolean;
121129
requiresWBS: boolean;
122130
};
123131
export const enum FlatAction {

app/utils/electronUtils.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,23 @@ export default class ElectronUtils {
2222
try {
2323
resolve(${javaScript})
2424
} catch(err) {
25+
resolve({ __error: { name: err.name, message: err.message, stack: err.stack } })
2526
throw { name: err.name, message: err.message, stack: err.stack }
2627
}
2728
})`;
2829
// save a stack trace in case we have an error later
2930
const { stack } = new Error();
3031

3132
try {
32-
return await this.webContents.executeJavaScript(code, isUserGesture);
33+
const result = await this.webContents.executeJavaScript(
34+
code,
35+
isUserGesture
36+
);
37+
console.log(result);
38+
if ('__error' in Object(result)) {
39+
throw result.__error;
40+
}
41+
return result;
3342
} catch (error) {
3443
// eslint-disable-next-line no-console
3544
console.error(`Error executing JavaScript-snippet within webContents:

app/utils/performApplication.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ export default function* performApplication(
3131
// there seems to be a problem with the captcha implementation: https://github.com/google/recaptcha/issues/269
3232
yield electronUtils.evaluate(`grecaptcha = undefined`);
3333

34+
// window.IS24.expose.contactData.contactButton.clickOutUrl
35+
3436
// click on button to compose a message
3537
if (!(yield electronUtils.elementExists(composeMessageButtonSelector))) {
3638
dispatch(setBotMessage('"Nachricht schreiben"-Button nicht gefunden'));

0 commit comments

Comments
 (0)