Skip to content

Commit

Permalink
Resolve all typescript errors
Browse files Browse the repository at this point in the history
  • Loading branch information
mattwalo32 committed Jan 15, 2024
1 parent bc2ae38 commit fe6e62f
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 27 deletions.
3 changes: 1 addition & 2 deletions apps/frontend/src/components/BottomBar/BottomBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ const BottomBar = ({
};

const onStatusSelected: MouseEventHandler<HTMLDivElement> = (e) => {
// TODO: Look into this
onStatusChange('status', e.target.value);
onStatusChange('status', (e.target as any).value);
}

/**
Expand Down
13 changes: 3 additions & 10 deletions apps/frontend/src/components/EditFieldModal/EditFieldModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
FormControl,
FormControlLabel,
} from '@material-ui/core';
import PropTypes from 'prop-types';
import _ from 'lodash';
import swal from 'sweetalert';

Expand All @@ -24,18 +23,12 @@ import { useErrorWrap } from '../../hooks/useErrorWrap';
import { Field, FieldType, Language, QuestionOption, TranslatedString, Unsaved } from '@3dp4me/types';
import { FormOption } from '../Fields/FormOption';

type OmitDeep<T, K extends keyof any> = T extends object
? {
[P in Exclude<keyof T, K>]: OmitDeep<T[P], K>;
}
: T;

export interface EditFieldModalProps {
isOpen: boolean
initialData: Field
onModalClose: () => void
allRoles: FormOption[]
onEditField: (field: Field) => void
onEditField: (field: Unsaved<Field>) => void
}

const EditFieldModal = ({
Expand Down Expand Up @@ -278,7 +271,7 @@ const EditFieldModal = ({

const getUpdatedData = () => {
const formattedOptions = options.map((option, index) => {
return { Index: index, Question: option };
return { Index: index, Question: option, IsHidden: false };
});

const updatedFieldData: Unsaved<Field> = {
Expand Down Expand Up @@ -306,7 +299,7 @@ const EditFieldModal = ({
editField(newFieldData);
};

const editField = (newFieldData: Field) => {
const editField = (newFieldData: Unsaved<Field>) => {
errorWrap(
() => {
validateField(newFieldData);
Expand Down
3 changes: 1 addition & 2 deletions apps/frontend/src/components/Fields/PhotoField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ const PhotoField = <T extends string>({
await getMedia(PERMISSION_CONSTRAINTS);
if (navigator.permissions && navigator.permissions.query) {
const permissionStatus = await navigator.permissions.query({
name: 'camera',
name: 'camera' as any
});
setPermissionListener(permissionStatus);
}
Expand Down Expand Up @@ -197,7 +197,6 @@ const PhotoField = <T extends string>({
return (
<ImageGallery
items={images}
className="image-gallery"
showBullets={
images.length <= NUMBER_OF_PHOTOS_FOR_BULLET_VIEW
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import RadioButtonField from '../Fields/RadioButtonField';
import { useTranslations } from '../../hooks/useTranslations';
import { getJSONReferenceByStringPath } from '../../utils/utils';
import { FormOption } from '../Fields/FormOption';
import { Field, FieldType, Language, PathToField, StepPathToField } from '@3dp4me/types';
import { Field, FieldType, Language, MaxRecursionDepth, PathToField, StepPathToField } from '@3dp4me/types';

export interface StepManagementContentProps {
onDownPressed: (key: string, root: StepPathToField, index: number) => void
Expand Down Expand Up @@ -160,7 +160,7 @@ const StepManagementContent = ({
}

function getPathToSubfields(fieldRoot: StepPathToField, fieldNumber: number): StepPathToField {
const root: PathToField<`fields`, 6> = `${fieldRoot}[${getFieldIndexGivenFieldNumber(
const root: PathToField<`fields`, MaxRecursionDepth> = `${fieldRoot}[${getFieldIndexGivenFieldNumber(
fieldRoot,
fieldNumber,
)}].subFields`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,6 @@ const SectionTab = () => {
The result is stepMetadata will be modified, meaning the changes
will only be saved locally.
*/

const addNewField = (newFieldData: Unsaved<Omit<Field, "fieldNumber"|"key"|"isHidden"|"isDeleted"|"additionalData">>) => {
const updatedMetadata = _.cloneDeep(stepMetadata);

Expand All @@ -389,7 +388,8 @@ const SectionTab = () => {
}

// Mark as not being deleted and not hidden
const newField: UnsavedField = {
// const newField: UnsavedField = {
const newField = {
additionalData: undefined,
isDeleted: false,
isHidden: false,
Expand All @@ -409,7 +409,7 @@ const SectionTab = () => {
setStepMetadata(updatedMetadata);
};

const editField = (updatedFieldData: Field) => {
const editField = (updatedFieldData: Unsaved<Field>) => {
const updatedField = _.cloneDeep(updatedFieldData);
const updatedMetadata = _.cloneDeep(stepMetadata);

Expand All @@ -431,7 +431,8 @@ const SectionTab = () => {

if (fieldIndex < 0) return;

fieldArrayReference[fieldIndex] = updatedField;
// TODO: Type all this as unsaved
fieldArrayReference[fieldIndex] = updatedField as any;

setStepMetadata(updatedMetadata);
};
Expand Down
14 changes: 7 additions & 7 deletions apps/frontend/webpack.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ import nodeExternals from "webpack-node-externals"
const config = {
mode: "production",
entry: "./src/index.tsx",
externals: [
nodeExternals({
// modulesFromFile: true,
modulesDir: path.resolve(__dirname, '../../'),
}),
],
// externals: [
// nodeExternals({
// // modulesFromFile: true,
// modulesDir: path.resolve(__dirname, '../../'),
// }),
// ],
module: {
rules: [
{
Expand Down Expand Up @@ -99,7 +99,7 @@ const config = {
}),

new Dotenv({
path: './production.env',
path: './.env',
safe: true,
}),
],
Expand Down

0 comments on commit fe6e62f

Please sign in to comment.