Skip to content
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

fix boolean comparison, remove flow-types packages #493

Merged
merged 3 commits into from
Jun 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
{
"presets": [
"@babel/preset-env",
"@babel/preset-react",
"@babel/preset-flow"
"@babel/preset-react"
],
"env": {
"test": {
Expand Down
6 changes: 2 additions & 4 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
{
"extends": [
"eslint:recommended",
"plugin:react/recommended",
"plugin:flowtype/recommended"
"plugin:react/recommended"
],
"env": {
"browser": true,
Expand Down Expand Up @@ -32,8 +31,7 @@
"no-case-declarations": "off"
},
"plugins": [
"react",
"flowtype"
"react"
],
"settings": {
"react": {
Expand Down
7 changes: 1 addition & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,11 @@
"instrument": false
},
"scripts": {
"flow": "flow; test $? -eq 0 -o $? -eq 2",
"flow-typed": "flow-typed install",
"lint": "eslint src",
"serve": "webpack serve",
"start": "node scripts/start.js",
"compile": "node scripts/compile.js",
"precommit": "npm-run-all flow lint",
"precommit": "npm-run-all lint",
"prepush": "npm-run-all test",
"test": "mocha --require @babel/register --require ts-node/register --require tsconfig-paths/register --require src/test.ts \"src/**/*spec.ts\"",
"test:coverage": "cross-env NODE_ENV=test nyc --reporter=lcov --reporter=text --require ts-node/register --require tsconfig-paths/register mocha \"src/**/*spec.ts\" --exit",
Expand Down Expand Up @@ -79,7 +77,6 @@
"@babel/plugin-proposal-class-properties": "^7.18.6",
"@babel/polyfill": "^7.12.1",
"@babel/preset-env": "^7.5.5",
"@babel/preset-flow": "^7.23.3",
"@babel/preset-react": "^7.23.3",
"@babel/register": "^7.23.7",
"@hot-loader/react-dom": "17.0.2",
Expand Down Expand Up @@ -107,11 +104,9 @@
"enzyme": "^3.10.0",
"enzyme-adapter-react-16": "^1.14.0",
"eslint": "^8.56.0",
"eslint-plugin-flowtype": "^8.0.3",
"eslint-plugin-react": "^7.14.3",
"favicons-webpack-plugin": "^6.0.1",
"file-loader": "^6.2.0",
"flow-typed": "^3.9.0",
"fs-extra": "^11.2.0",
"html-webpack-plugin": "^5.6.0",
"json-loader": "^0.5.7",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { UsersPermissions } from "usersPermissions/enums";
import { PermissionMissingTexts } from "enums";
import type { UsersPermissions as UsersPermissionsType } from "usersPermissions/types";
import { withLeaseInvoicingConfirmationReportAttributes } from "components/attributes/LeaseInvoicingConfirmationReportAttributes";
import type { ReportOptions } from "leaseStatisticReport/types";
type Props = {
isFetchingLeaseInvoicingConfirmationReportAttributes: boolean;
leaseInvoicingConfirmationReportAttributes: Attributes;
Expand All @@ -30,7 +31,7 @@ type Props = {
usersPermissions: UsersPermissionsType;
isFetchingReportData: boolean;
reportData: any;
reportOptions: Record<string, any>;
reportOptions: ReportOptions;
payload: Record<string, any>;
reports: Reports;
};
Expand Down
10 changes: 4 additions & 6 deletions src/leaseStatisticReport/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { formatDate, formatNumber } from "util/helpers";
import { LeaseStatisticReportFormatOptions } from "leaseStatisticReport/enums";
import type { Reports } from "types";
import { FieldTypes } from "enums";
import type { ReportOptions, ReportOutputField } from "./types";

/**
* Get report type options
Expand Down Expand Up @@ -120,20 +121,17 @@ export const getQueryParams = (formValues: Record<string, any>): any => {
* @param {Object} options
* @return {Array[]}
*/
export const getOutputFields = (options: Record<string, any>): Array<Record<string, any>> => {
export const getOutputFields = (options: ReportOptions): Array<ReportOutputField> => {
if (options) return Object.entries(options.output_fields).map(([key, value]) => {
return {
key: key,
// @ts-ignore: Property 'choices' does not exist on type 'unknown'.
label: value.label,
// @ts-ignore: Property 'choices' does not exist on type 'unknown'.
choices: value.choices,
// @ts-ignore: Property 'choices' does not exist on type 'unknown'.
format: value.format,
// @ts-ignore: Property 'choices' does not exist on type 'unknown'.
isNumeric: value.is_numeric
};
});else return [];
});
else return [];
};

/**
Expand Down
16 changes: 15 additions & 1 deletion src/leaseStatisticReport/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,18 @@ export type NoMailSentAction = Action<string, void>;
export type MailSentAction = Action<string, void>;
export type FetchOptionsAction = Action<string, void>;
export type ReceiveOptionsAction = Action<string, void>;
export type OptionsNotFoundAction = Action<string, void>;
export type OptionsNotFoundAction = Action<string, void>;
export interface ReportOutputFieldInput {
label: string;
choices: Array<any>;
format: string;
is_numeric: boolean;
}
export interface ReportOutputField extends Omit<ReportOutputFieldInput, 'is_numeric'> {
key: string;
isNumeric: boolean;
}
export type ReportOptions = {
output_fields: Record<string, ReportOutputFieldInput>;
is_already_sorted: boolean;
}
3 changes: 1 addition & 2 deletions src/leases/components/LeasePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -868,8 +868,7 @@ class LeasePage extends Component<Props, State> {
hasError: isSaveClicked && !isTenantsFormValid
}, {
label: 'Vuokrat',
// @ts-ignore: Type 'boolean' is not assignable to type 'string'
allow: isFieldAllowedToRead(leaseAttributes, LeaseRentsFieldPaths.RENTS || isFieldAllowedToRead(leaseAttributes, LeaseBasisOfRentsFieldPaths.BASIS_OF_RENTS)),
allow: isFieldAllowedToRead(leaseAttributes, LeaseRentsFieldPaths.RENTS) || isFieldAllowedToRead(leaseAttributes, LeaseBasisOfRentsFieldPaths.BASIS_OF_RENTS),
isDirty: isRentsFormDirty,
hasError: isSaveClicked && !isRentsFormValid
}, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,6 @@ class InvoiceTableAndPanel extends PureComponent<Props, State> {
invoices,
openedInvoice
} = this.state;
// @ts-ignore: No matching overloader (invoiceToCredit)
return <TableAndPanelWrapper ref={this.setTableAndPanelWrapperRef} hasData={!!invoices.length} isPanelOpen={isPanelOpen} onPanelClosed={this.handlePanelClosed} panelComponent={<InvoicePanel invoice={openedInvoice} onClose={this.handlePanelClose} onInvoiceLinkClick={this.handleInvoiceLinkClick} onSave={this.editInvoice} />} tableComponent={<SortableTable columns={columns} data={invoices} defaultSortKey='due_date' defaultSortOrder={TableSortOrder.DESCENDING} fixedHeader={true} invoiceToCredit={invoiceToCredit} onDataUpdate={this.handleDataUpdate} onRowClick={this.handleRowClick} onSelectNext={this.selectOpenedInvoice} onSelectPrevious={this.selectOpenedInvoice} onSelectRow={this.handleSelectRow} selectedRow={openedInvoice} sortable={true} />} />;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,7 @@ const renderNotes = ({
return <NewCollectionNote key={index} field={field} onCancel={handleCancel} onSave={handleSave} />;
})}
<Authorization allow={hasPermissions(usersPermissions, UsersPermissions.ADD_COLLECTIONNOTE)}>
{/** @ts-ignore: Operator '<' cannot be applied to types 'boolean' and 'number' */}
{!!fields.length < 1 && <AddButtonThird label='Lisää huomautus' onClick={handleAdd} />}
{fields.length === 0 && <AddButtonThird label='Lisää huomautus' onClick={handleAdd} />}
</Authorization>
</Fragment>;
};
Expand Down
Loading