Skip to content

Commit

Permalink
Fix types
Browse files Browse the repository at this point in the history
  • Loading branch information
OhKai committed Oct 16, 2023
1 parent 26eab38 commit a6d831c
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 15 deletions.
4 changes: 3 additions & 1 deletion src/management-system-v2/app/(dashboard)/iam/roles/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import useFuzySearch from '@/lib/useFuzySearch';
import { AuthCan } from '@/lib/iamComponents';
import Link from 'next/link';
import { toCaslResource } from '@/lib/ability/caslAbility';
import Bar from '@/components/bar';

type Role = ApiData<'/roles', 'get'>[number];

Expand Down Expand Up @@ -86,7 +87,8 @@ const RolesPage: FC = () => {
);

return (
<Content title="Identity and Access Management" rightNode={<HeaderActions />}>
<Content title="Identity and Access Management">
<Bar rightNode={<HeaderActions />} />
<Row className={styles.Headerrow}>
<Col
xs={24}
Expand Down
16 changes: 9 additions & 7 deletions src/management-system-v2/components/userProfile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,6 @@ const UserDataModal: FC<{
email: userData.email,
firstName: userData.firstName,
lastName: userData.lastName,
firstName: userData.firstName,
lastName: userData.lastName,
username: userData.username,
...values,
};
Expand Down Expand Up @@ -227,11 +225,15 @@ const UserProfile: FC = () => {

async function deleteUser() {
try {
await deleteUserMutation({
params: { path: { id: user && user.sub } },
});
messageApi.success({ content: 'Your account was deleted' });
logout();
// Since this should only be callable once the user was loaded, we can assume that the user is not false.
// Check is only for typescript.
if (user && user.sub) {
await deleteUserMutation({
params: { path: { id: user.sub } },
});
messageApi.success({ content: 'Your account was deleted' });
logout();
}
} catch (e) {
messageApi.error({ content: 'An error ocurred' });
}
Expand Down
2 changes: 1 addition & 1 deletion src/management-system-v2/components/version-toolbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ const VersionToolbar: React.FC<VersionToolbarProps> = () => {
},
);
const response = await post('/process', {
body: { bpmn: newBpmn, description: values.description, departments: [] },
body: { bpmn: newBpmn, /*description: values.description,*/ departments: [] },
parseAs: 'text',
});
}
Expand Down
10 changes: 7 additions & 3 deletions src/management-system-v2/lib/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ async function versionUserTasks(
params: {
path: {
definitionId: processInfo.definitionId,
userTaskFileName: htmlMapping[userTaskId].fileName,
userTaskFileName: htmlMapping[userTaskId].fileName!,
},
},
parseAs: 'text',
Expand All @@ -115,7 +115,7 @@ async function versionUserTasks(
params: {
path: {
definitionId: processInfo.definitionId,
userTaskFileName: basedOnVersionFileInfo.fileName,
userTaskFileName: basedOnVersionFileInfo.fileName!,
},
},
parseAs: 'text',
Expand All @@ -125,7 +125,7 @@ async function versionUserTasks(
if (basedOnVersionFileInfo && basedOnVersionUserTaskHTML === html) {
// reuse the html of the previous version
userTaskHtmlAlreadyExisting = true;
fileName = basedOnVersionFileInfo.fileName;
fileName = basedOnVersionFileInfo.fileName!;
}
}

Expand All @@ -151,6 +151,10 @@ export async function createNewProcessVersion(
const bpmnObj = await toBpmnObject(bpmn);
const definitionId = await getDefinitionsId(bpmnObj);

if (!definitionId) {
throw new Error("There is no definitionId for the process. Can't create a new version");
}

const processInfo = (
await get('/process/{definitionId}', {
params: { path: { definitionId: definitionId } },
Expand Down
4 changes: 2 additions & 2 deletions src/management-system-v2/lib/openapiSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ export interface components {
| 'versions'
>;
processVersion: {
version: string;
version: number;
name: string;
description: string;
};
Expand Down Expand Up @@ -339,7 +339,7 @@ export interface components {
/** Format: email */
email: string;
username: string;
'firstName ': string;
firstName: string;
lastName: string;
};
/** user */
Expand Down
3 changes: 2 additions & 1 deletion src/management-system-v2/lib/useFuzySearch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ export default function useFuzySearch<TData extends Record<string, any>>(
const searchParams = useSearchParams();

const [searchQuery, setSearchQuery] = useState(
searchParams.get(fuzzySearchOptions.useSearchParams ? fuzzySearchOptions.queryName : ''),
searchParams.get(fuzzySearchOptions.useSearchParams ? fuzzySearchOptions.queryName : '') ??
undefined,
);
const debouncedSearchQuery = useDebounce(searchQuery, 200, fuzzySearchOptions.useSearchParams);

Expand Down

0 comments on commit a6d831c

Please sign in to comment.