feat: add user submission history preparations
This commit is contained in:
@@ -7,3 +7,24 @@ export const normalizePhone = (phone: string): string => {
|
||||
|
||||
return phone;
|
||||
};
|
||||
|
||||
type GenerateCodeOptions = {
|
||||
prefix?: string;
|
||||
length?: number;
|
||||
};
|
||||
|
||||
export const generateCode = (options?: GenerateCodeOptions) => {
|
||||
const prefix = options?.prefix || '';
|
||||
const length = options?.length || 5;
|
||||
|
||||
const characters =
|
||||
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
||||
|
||||
let random = '';
|
||||
|
||||
for (let i = 0; i < length; i++) {
|
||||
random += characters.charAt(Math.floor(Math.random() * characters.length));
|
||||
}
|
||||
|
||||
return `${prefix}${random}`;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user