Untitled

mail@pastecode.io avatar
unknown
plain_text
2 months ago
1.7 kB
1
Indexable
Never
import { DEFAULT_NPWP_RELEASE_DATE } from "@Constants/general";
// import remoteConfig from '@react-native-firebase/remote-config';
import Constants, { ExecutionEnvironment } from "expo-constants";

// Add this to validate when open in Expo Go app
const isExpoGo = Constants.executionEnvironment === ExecutionEnvironment.StoreClient;

var remoteConfig;
if (!isExpoGo) {
	remoteConfig = require("@react-native-firebase/remote-config").default;
}

export function getInitialName(contactName?: string) {
	if (!contactName) return "";
	const nameArr: string[] = contactName.split(" ");

	var nameInitial = "";
	if (nameArr.length > 1) {
		nameInitial = (nameArr[0][0] ? nameArr[0][0] : "") + (nameArr[1][0] ? nameArr[1][0] : "");
	} else {
		nameInitial = nameArr[0][0] ?? "";
	}

	return nameInitial;
}

export async function getRemoteNpwpReleaseDate() {
	const res = await remoteConfig()
		.setConfigSettings({
			minimumFetchIntervalMillis: 0,
		})
		.then(() => {
			remoteConfig().setDefaults({
				npwp_release_date: DEFAULT_NPWP_RELEASE_DATE,
			});
		})
		.then(() => remoteConfig().fetchAndActivate())
		.then(() => remoteConfig().getString("npwp_release_date"));

	return res;
}

export const regexKtp = {
	Mr: /^\d{6}(0[1-9]|1\d|2[0-9]|3[01])(0[1-9]|1[0-2])\d{6}$/,
	Ms: /^\d{6}(4[1-9]|5\d|6[0-9]|7[01])(0[1-9]|1[0-2])\d{6}$/,
	Company: /^[0-9]+$/,
	default: /^[0-9]+$/,
};

export const errorMessageNPWPandNIK = {
	npwpNew: "Format No NPWP belum sesuai (Harus 16 digit)",
	npwpOld: "No NPWP harus 15 angka",
	ktpNew: "Format No KTP belum sesuai (Harus 16 digit dan digit 7, 8, 9, 10 harus sesuai regulasi pemerintah)",
	ktpOld: "No KTP harus 16 angka",
};
Leave a Comment