This commit is contained in:
ValdiANS
2025-09-26 11:06:31 +07:00
parent a5524686a6
commit 2e1b0fef2b
36 changed files with 8716 additions and 79 deletions
+7
View File
@@ -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';
};
+29
View File
@@ -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);
};
+13
View File
@@ -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'
);