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: [DHIS2-15879] Unable to schedule event with note #3421

Merged
merged 4 commits into from
Oct 27, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// @flow
import { useMemo } from 'react';
import { useDataQuery } from '@dhis2/app-runtime';
import uuid from 'd2-utilizr/lib/uuid';
import { generateUID } from '../../../utils/uid/generateUID';

export const useCommentDetails = () => {
const { data, error, loading } = useDataQuery(useMemo(() => ({
Expand All @@ -18,6 +18,6 @@ export const useCommentDetails = () => {
return {
error,
currentUser: !loading && data.currentUser,
noteId: uuid(),
noteId: generateUID(),
};
};
18 changes: 18 additions & 0 deletions src/core_modules/capture-core/utils/uid/generateUID.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// @flow

export const generateUID = (): string => {
const letters = 'abcdefghijklmnopqrstuvwxyz' + 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
const allowedChars = `0123456789${letters}`;
const NUMBER_OF_CODEPOINTS = allowedChars.length;
const CODESIZE = 11;
let uid;

// the uid should start with a char
uid = letters.charAt(Math.random() * (letters.length));

for (let i = 1; i < CODESIZE; ++i) {
uid += allowedChars.charAt(Math.random() * (NUMBER_OF_CODEPOINTS));
}

return uid;
};
Loading