mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-20 05:22:02 +00:00
init
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
import { BaseApiResponse, SuccessApiResponse } from '@/types/api';
|
||||
|
||||
export const isResponseSuccess = <T>(
|
||||
res?: BaseApiResponse<T>
|
||||
): res is SuccessApiResponse<T> => {
|
||||
return res?.status === 'success';
|
||||
};
|
||||
@@ -0,0 +1,29 @@
|
||||
import moment from 'moment';
|
||||
import { twMerge } from 'tailwind-merge';
|
||||
import clsx, { ClassValue } from 'clsx';
|
||||
|
||||
export const sleep = (ms: number = 1000) =>
|
||||
new Promise((resolve) => setTimeout(resolve, ms));
|
||||
|
||||
export const formatDate = (date: moment.MomentInput, format?: string) => {
|
||||
return moment(date).format(format);
|
||||
};
|
||||
|
||||
export const cn = (...inputs: ClassValue[]) => {
|
||||
return twMerge(clsx(inputs));
|
||||
};
|
||||
|
||||
export const formatCurrency = (
|
||||
value: number | bigint | Intl.StringNumericLiteral,
|
||||
currency = 'USD',
|
||||
locale = 'en-US',
|
||||
minimumFractionDigits = 0,
|
||||
maximumFractionDigits = 2
|
||||
) => {
|
||||
return new Intl.NumberFormat(locale, {
|
||||
style: 'currency',
|
||||
currency,
|
||||
minimumFractionDigits,
|
||||
maximumFractionDigits,
|
||||
}).format(value);
|
||||
};
|
||||
@@ -0,0 +1,13 @@
|
||||
import * as Yup from 'yup';
|
||||
|
||||
export const EmailSchema = Yup.string().email('Format email invalid!');
|
||||
|
||||
export const PasswordSchema = Yup.string()
|
||||
.min(8, 'Password harus setidaknya memiliki 8 karakter')
|
||||
.matches(/[a-z]/, 'Harus memiliki setidaknya 1 huruf kecil')
|
||||
.matches(/[A-Z]/, 'Harus memiliki setidaknya 1 huruf besar')
|
||||
.matches(/\d/, 'Harus memiliki setidaknya 1 angka')
|
||||
.matches(
|
||||
/[@$!%*?&^#()_\-+={}[\]|:;"'<>,.\\/]/,
|
||||
'Harus memiliki setidaknya 1 karakter spesial'
|
||||
);
|
||||
Reference in New Issue
Block a user