Initial commit
This commit is contained in:
106
src/utils/constants.ts
Normal file
106
src/utils/constants.ts
Normal file
@@ -0,0 +1,106 @@
|
||||
import { t } from "i18next";
|
||||
|
||||
export const BASE_URL = "https://dev.fascano.com/api/user_app/";
|
||||
export const default_image = "/default.png";
|
||||
export const FilterBaseFromDate = "2020-01-01";
|
||||
|
||||
const ROOTS_DEFAULT = "";
|
||||
const ROOTS_AUTH = "/auth";
|
||||
const ROOTS_ERRORS = "/errors";
|
||||
|
||||
export const PATH_AUTH = {
|
||||
root: ROOTS_AUTH,
|
||||
login: path(ROOTS_AUTH, "/login"),
|
||||
signin: path(ROOTS_AUTH, "/signin"),
|
||||
signup: path(ROOTS_AUTH, "/signup"),
|
||||
passwordReset: path(ROOTS_AUTH, "/password-reset"),
|
||||
passwordConfirm: path(ROOTS_AUTH, "/password-confirmation"),
|
||||
welcome: path(ROOTS_AUTH, "/welcome"),
|
||||
verifyEmail: path(ROOTS_AUTH, "/verify-email"),
|
||||
accountDelete: path(ROOTS_AUTH, "/account-delete"),
|
||||
};
|
||||
|
||||
export const PATH_ERROR = {
|
||||
root: ROOTS_ERRORS,
|
||||
error400: path(ROOTS_ERRORS, "/400"),
|
||||
error403: path(ROOTS_ERRORS, "/403"),
|
||||
error404: path(ROOTS_ERRORS, "/404"),
|
||||
error500: path(ROOTS_ERRORS, "/500"),
|
||||
error503: path(ROOTS_ERRORS, "/503"),
|
||||
};
|
||||
|
||||
export const AUTHENTICATION_ITEMS = [
|
||||
{ title: "sign in", path: PATH_AUTH.signin },
|
||||
{ title: "password reset", path: PATH_AUTH.passwordReset },
|
||||
];
|
||||
export const ERROR_ITEMS = [
|
||||
{ title: "400", path: PATH_ERROR.error400 },
|
||||
{ title: "403", path: PATH_ERROR.error403 },
|
||||
{ title: "404", path: PATH_ERROR.error404 },
|
||||
{ title: "500", path: PATH_ERROR.error500 },
|
||||
{ title: "503", path: PATH_ERROR.error503 },
|
||||
];
|
||||
|
||||
export const ACCESS_TOKEN = "token";
|
||||
export const USER_NAME = "username";
|
||||
export const THEME_STORAGE_KEY = "themeKey";
|
||||
export const USER_EMAIL = "userEmail";
|
||||
export const DEFAULT_LANGUAGE = "selectedLang";
|
||||
|
||||
export const UI_DATE_FORMAT = "YYYY-MM-DD";
|
||||
|
||||
export const CONTACTS_URL = "LT";
|
||||
export const FILTER_PARAMS = "";
|
||||
export const SEARCH_THRESHOLD = 0.2;
|
||||
|
||||
export const taxTypes = [
|
||||
{ id: "PERCENTAGE", name: "نسبة من المبلغ الكلي" },
|
||||
{ id: "FIXED", name: "كمية من المبلغ الكلي" },
|
||||
];
|
||||
|
||||
export const DefaultModalPageSizeOptions = [20, 50, 100];
|
||||
|
||||
export enum ModalSize {
|
||||
"small",
|
||||
"default",
|
||||
"large",
|
||||
"medium",
|
||||
}
|
||||
|
||||
export const paymentTypes: { id: string; name: string }[] = [
|
||||
{ id: "CASH", name: t("cash") },
|
||||
{ id: "E-PAYMENT", name: t("e-payment") },
|
||||
{ id: "DEBIT", name: t("debit") },
|
||||
];
|
||||
function path(root: string, sublink: string) {
|
||||
return `${root}${sublink}`;
|
||||
}
|
||||
|
||||
export const ROOTS_LANDING = import.meta.env.VITE_BASE_URL;
|
||||
export const API_BASE_URL = import.meta.env.VITE_BASE_API_URL;
|
||||
|
||||
export const PATHS = {
|
||||
root: ROOTS_DEFAULT,
|
||||
menu: path(ROOTS_DEFAULT, "/menu"),
|
||||
address: path(ROOTS_DEFAULT, "/address"),
|
||||
order: path(ROOTS_DEFAULT, "/order"),
|
||||
profile: path(ROOTS_DEFAULT, "/profile"),
|
||||
settings: path(ROOTS_DEFAULT, "/settings"),
|
||||
support: path(ROOTS_DEFAULT, "/support"),
|
||||
terms: path(ROOTS_DEFAULT, "/terms"),
|
||||
privacy: path(ROOTS_DEFAULT, "/privacy"),
|
||||
};
|
||||
|
||||
export const RESTAURANT_DETAILS_URL = `${BASE_URL}restaurant/selectLanguage/`;
|
||||
export const PRODUCTS_AND_CATEGORIES_URL = `${BASE_URL}getRestaurantItems/`;
|
||||
export const PRODUCT_DETAILS_URL = `${BASE_URL}getOptionsForItem/`;
|
||||
export const ORDERS_URL = `${BASE_URL}customer_orders`;
|
||||
export const CREATE_ORDER_URL = `${BASE_URL}create_order_webmenu`;
|
||||
export const LOGIN_URL = `${API_BASE_URL}login`;
|
||||
export const SEND_OTP_URL = `${API_BASE_URL}sendOtp`;
|
||||
export const CONFIRM_OTP_URL = `${API_BASE_URL}confirmOtp`;
|
||||
export const USERS_DATA_URL = `${API_BASE_URL}users`;
|
||||
export const TABLE_HEADERS = `${API_BASE_URL}tableheader`;
|
||||
export const PERMISSIONS_DATA_URL = `${API_BASE_URL}permissions`;
|
||||
export const SINGED_USER_INFO_URL = `${API_BASE_URL}users/authenticated`;
|
||||
export const ROLES_DATA_URL = `${API_BASE_URL}roles`;
|
||||
276
src/utils/helpers.ts
Normal file
276
src/utils/helpers.ts
Normal file
@@ -0,0 +1,276 @@
|
||||
import { t } from "i18next";
|
||||
import { DEFAULT_LANGUAGE } from "./constants";
|
||||
import {
|
||||
ProColumnType,
|
||||
RegisterType,
|
||||
TableHeaderType,
|
||||
Translation
|
||||
} from "./types/appTypes";
|
||||
|
||||
export default function getRandomColor() {
|
||||
const letters = "0123456789ABCDEF";
|
||||
let color = "#";
|
||||
for (let i = 0; i < 6; i += 1) {
|
||||
color += letters[Math.floor(Math.random() * 16)];
|
||||
}
|
||||
return color;
|
||||
}
|
||||
|
||||
export const RGBLinearShade = (p: number, color: string) => {
|
||||
const i = parseInt;
|
||||
const r = Math.round;
|
||||
const [a, b, c, d] = color.split(",");
|
||||
|
||||
const t = p < 0 ? 0 : 255 * p;
|
||||
|
||||
const P = p < 0 ? 1 + p : 1 - p;
|
||||
return `rgb${d ? "a(" : "("}${r(
|
||||
i(a[3] === "a" ? a.slice(5) : a.slice(4)) * P + t
|
||||
)},${r(i(b) * P + t)},${r(i(c) * P + t)}${d ? `,${d}` : ")"}`;
|
||||
};
|
||||
|
||||
export const parseTranslationObj = (
|
||||
prefix: any,
|
||||
obj: object,
|
||||
form: FormData
|
||||
) => {
|
||||
Object.entries(obj).forEach(([key, value]) => {
|
||||
form.append(`${prefix}[${key}]`, value as string);
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* prepare data in the right format
|
||||
* @param formGroup
|
||||
*/
|
||||
export const parseDataToFormData = (data: any) => {
|
||||
const formData = new FormData();
|
||||
Object.entries(data).map((field: any) => {
|
||||
const key = field[0];
|
||||
const value = field[1];
|
||||
if (key === "ar" || key === "en")
|
||||
parseTranslationObj(key, value, formData);
|
||||
// cleaning (no need to add properties with undefined, null .. etc values)
|
||||
else if (value || value === 0) formData.append(key, value);
|
||||
});
|
||||
return formData;
|
||||
};
|
||||
|
||||
export const objPropsCalculate = (data: any) => {
|
||||
let total = 0;
|
||||
Object.entries(data).map((field: any) => {
|
||||
const value = field[1];
|
||||
if (value) total += value;
|
||||
});
|
||||
return total;
|
||||
};
|
||||
|
||||
export const calculateRegisterBalance = (data: Partial<RegisterType>) => {
|
||||
return (
|
||||
Number(data.opening_balance || 0) +
|
||||
Number(data.total_income || 0) -
|
||||
Number(data.total_expenses || 0)
|
||||
);
|
||||
};
|
||||
|
||||
export function getArraysDiff(arr1: Array<string>, arr2: Array<string>) {
|
||||
if (arr1.length > arr2.length)
|
||||
return arr1.filter((el) => arr2.indexOf(el) < 0);
|
||||
|
||||
return arr2.filter((el) => arr1.indexOf(el) < 0);
|
||||
}
|
||||
|
||||
export function translatedColumnTitle(
|
||||
title: string | { key: string; varKey: string },
|
||||
t2: any
|
||||
): string {
|
||||
if (title && typeof title === "string") return t2(title);
|
||||
// @ts-ignore
|
||||
if (title?.key) {
|
||||
// @ts-ignore
|
||||
return t2(title.key, { var: t2(title.varKey || "") });
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
export function getModifiedColProps(
|
||||
col: TableHeaderType | Partial<ProColumnType<any>>
|
||||
): Partial<ProColumnType<any>> {
|
||||
const translatedTitle = translatedColumnTitle(col.title || "", t);
|
||||
let calcColumnWidth = col.width;
|
||||
if (!calcColumnWidth) {
|
||||
const letterCount = translatedTitle.toString().length || 0;
|
||||
const uppercaseLetterCount = (
|
||||
translatedTitle.toString().match(/[A-Z]/g) || ""
|
||||
).length;
|
||||
calcColumnWidth =
|
||||
(letterCount - uppercaseLetterCount) * 10 +
|
||||
uppercaseLetterCount * 14 +
|
||||
25;
|
||||
if (col.sorter) calcColumnWidth += 12;
|
||||
if (calcColumnWidth < 80) calcColumnWidth = 80;
|
||||
}
|
||||
return {
|
||||
title: translatedTitle,
|
||||
width: calcColumnWidth,
|
||||
};
|
||||
}
|
||||
|
||||
export function getModifiedColumnProps(col: ProColumnType<any>, t2: any) {
|
||||
const translatedTitle = translatedColumnTitle(col.title || "", t2);
|
||||
let calcColumnWidth = col.width;
|
||||
if (!calcColumnWidth) {
|
||||
const letterCount = translatedTitle.toString().length || 0;
|
||||
const uppercaseLetterCount = (
|
||||
translatedTitle.toString().match(/[A-Z]/g) || ""
|
||||
).length;
|
||||
calcColumnWidth =
|
||||
(letterCount - uppercaseLetterCount) * 10 +
|
||||
uppercaseLetterCount * 14 +
|
||||
25;
|
||||
if (col.sorter) calcColumnWidth += 12;
|
||||
if (calcColumnWidth < 80) calcColumnWidth = 80;
|
||||
}
|
||||
return {
|
||||
title: translatedTitle,
|
||||
width: calcColumnWidth,
|
||||
};
|
||||
}
|
||||
|
||||
export function prepareNextKey(dataSource: any[]): number {
|
||||
return (
|
||||
dataSource.reduce((a, b) => (a.key > b.key ? a : b), {
|
||||
key: 0,
|
||||
} as any).key + 1
|
||||
);
|
||||
}
|
||||
|
||||
export function objectArrayToFormData(
|
||||
arr: Array<Record<string, any>>,
|
||||
parentKey?: string,
|
||||
formData?: FormData
|
||||
): FormData {
|
||||
const form = formData || new FormData();
|
||||
|
||||
arr.forEach((obj, index) => {
|
||||
Object.keys(obj).forEach((key) => {
|
||||
const value = obj[key];
|
||||
const fullKey = parentKey ? `${parentKey}[${index}][${key}]` : `${key}`;
|
||||
|
||||
if (value instanceof File) {
|
||||
form.append(fullKey, value);
|
||||
} else if (Array.isArray(value)) {
|
||||
value.forEach((v, i) => {
|
||||
form.append(`${fullKey}[${i}]`, v);
|
||||
});
|
||||
} else if (typeof value === "object" && value !== null) {
|
||||
objectArrayToFormData([value], fullKey, form);
|
||||
} else {
|
||||
form.append(fullKey, value);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
return form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add prefix to the invoice number
|
||||
* note: it's static prefix for all the number.
|
||||
* @param invoiceNumber
|
||||
* @returns
|
||||
*/
|
||||
export const addInvoiceNumberPrefix = (invoiceNumber?: string | number) => {
|
||||
return invoiceNumber ? "EP" + invoiceNumber : "";
|
||||
};
|
||||
|
||||
/**
|
||||
* Calculate the ceil
|
||||
* @param value
|
||||
* @returns
|
||||
*/
|
||||
export const ceil = (value: string | number = 0) => {
|
||||
return Math.ceil(Number(value) / 100) * 100;
|
||||
};
|
||||
|
||||
/**
|
||||
* Calculate the ceil
|
||||
* @param value
|
||||
* @returns
|
||||
*/
|
||||
export const formatNumbers = (value: string | number = 0) => {
|
||||
return new Intl.NumberFormat("en-US", {
|
||||
minimumFractionDigits: 0,
|
||||
maximumFractionDigits: 2,
|
||||
}).format(Number(value));
|
||||
};
|
||||
|
||||
/**
|
||||
* Translated the current entity name
|
||||
* @param data
|
||||
* @param propName
|
||||
* @returns
|
||||
*/
|
||||
export const parseTranslations = (data: any) => {
|
||||
return {
|
||||
arabic_name: data?.translations?.find(
|
||||
(t: Translation) => t.locale === "ar"
|
||||
)?.name,
|
||||
name: data?.translations?.find((t: Translation) => t.locale === "en")
|
||||
?.name,
|
||||
en: {
|
||||
name: data?.translations?.find((t: Translation) => t.locale === "en")
|
||||
?.name,
|
||||
},
|
||||
ar: {
|
||||
name: data?.translations?.find((t: Translation) => t.locale === "ar")
|
||||
?.name,
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* Translated a foreign info (like categories in the warehouse'product)
|
||||
* @param data
|
||||
* @param propName
|
||||
* @returns
|
||||
*/
|
||||
export const parseTranslationLabel = (
|
||||
data: any,
|
||||
propName: string,
|
||||
translationPropName?: string
|
||||
) => {
|
||||
return {
|
||||
["arabic_" + propName]: data?.translations?.find(
|
||||
(t: Translation) => t.locale === "ar"
|
||||
)?.[translationPropName || "name"],
|
||||
[propName]: data?.translations?.find(
|
||||
(t: Translation) => t.locale === "en"
|
||||
)?.[translationPropName || "name"],
|
||||
};
|
||||
};
|
||||
|
||||
export const getTranslatedColumnDataIndex = (dataIndex: string) => {
|
||||
return localStorage.getItem(DEFAULT_LANGUAGE) === "ar"
|
||||
? "arabic_" + dataIndex
|
||||
: dataIndex;
|
||||
};
|
||||
|
||||
export const saveTranslationsParse = (
|
||||
selectedRecord: any,
|
||||
dataIndex: string,
|
||||
lang: "ar" | "en",
|
||||
value: string
|
||||
) => {
|
||||
return lang === "ar"
|
||||
? {
|
||||
ar: { ...selectedRecord.ar, [dataIndex]: value },
|
||||
}
|
||||
: {
|
||||
en: { ...selectedRecord.en, [dataIndex]: value },
|
||||
};
|
||||
};
|
||||
|
||||
export const fixNumbers = (number: string) => {
|
||||
return number.slice(0, -3);
|
||||
};
|
||||
7
src/utils/types/apiTypes.ts
Normal file
7
src/utils/types/apiTypes.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
export type ReqOptionsType = {
|
||||
url: string;
|
||||
method: "GET" | "POST" | "PUT" | "DELETE";
|
||||
data?: any | undefined;
|
||||
noAuth?: boolean;
|
||||
mode?: "cors" | "no-cors";
|
||||
};
|
||||
657
src/utils/types/appTypes.ts
Normal file
657
src/utils/types/appTypes.ts
Normal file
@@ -0,0 +1,657 @@
|
||||
// zero value may be considered an undefined ... donn't use in enums
|
||||
import { ColumnType } from "antd/es/table";
|
||||
import { PermissionType } from "modules/system/rolesManagement/types";
|
||||
import { TaxType } from "modules/system/taxes/types";
|
||||
import { QrCode } from "pages/pos/orders/components/order-panel/types";
|
||||
import { ItemType, OrderType } from "pages/pos/orders/types";
|
||||
|
||||
export enum AlignType {
|
||||
"left" = "left",
|
||||
"center" = "center",
|
||||
"right" = "right",
|
||||
}
|
||||
export enum RowSelectionType {
|
||||
Radio = "radio",
|
||||
Checkbox = "checkbox",
|
||||
}
|
||||
export enum SortOrder {
|
||||
Descend = "descend",
|
||||
Ascend = "ascend",
|
||||
}
|
||||
|
||||
export interface ProColumnType<T extends Record<string, any>>
|
||||
extends Omit<ColumnType<T>, "title" | "dataIndex"> {
|
||||
notSearchable?: boolean;
|
||||
title?: string;
|
||||
dataIndex: string;
|
||||
visible?: boolean;
|
||||
defaultVisible?: boolean;
|
||||
editable?: boolean;
|
||||
dataType?: CellDataTypes;
|
||||
rules?: any;
|
||||
width?: number;
|
||||
onCell?: (rec: T) => any;
|
||||
excelStyle?: any;
|
||||
fixed?: FixedType;
|
||||
}
|
||||
|
||||
export enum CellDataTypes {
|
||||
TextCell = 1,
|
||||
NumberCell = 2,
|
||||
DateCell = 3,
|
||||
CheckboxCell = 4,
|
||||
SelectCell = 5,
|
||||
MonetaryCell = 6,
|
||||
}
|
||||
|
||||
export interface ProEditableColumnType<T extends Record<string, any>>
|
||||
extends Omit<ColumnType<T>, "title" | "dataIndex"> {
|
||||
title: string;
|
||||
dataIndex: string;
|
||||
children?: Array<ProColumnType<T>>;
|
||||
visible?: boolean;
|
||||
defaultVisible?: boolean;
|
||||
editable?: boolean;
|
||||
dataType?: CellDataTypes;
|
||||
rules?: any;
|
||||
width?: number;
|
||||
onCell?: (rec: any) => any;
|
||||
inputValidations?: any;
|
||||
fixed?: FixedType;
|
||||
}
|
||||
|
||||
export interface ProFullColumnType<T extends Record<string, any>>
|
||||
extends ProColumnType<T> {
|
||||
visible: boolean;
|
||||
defaultVisible: boolean;
|
||||
}
|
||||
|
||||
// export interface ProEditableColumnType<T> extends ColumnType<T> {
|
||||
// title: string | { key: string; varKey: string };
|
||||
// children?: Array<ProColumnType<T>>;
|
||||
// visible?: boolean;
|
||||
// defaultVisible?: boolean;
|
||||
// editable?: boolean;
|
||||
// dataType?: CellDataTypes;
|
||||
// rules?: any;
|
||||
// width?: number;
|
||||
// onCell?: any;
|
||||
// inputValidations?: any;
|
||||
// }
|
||||
|
||||
export interface ResizableColumnType<T> extends ColumnType<T> {
|
||||
width: number;
|
||||
onResize: (index: number) => void;
|
||||
}
|
||||
|
||||
export enum UploadFileStatus {
|
||||
done = "done",
|
||||
success = "success",
|
||||
error = "error",
|
||||
uploading = "uploading",
|
||||
removed = "removed",
|
||||
}
|
||||
|
||||
export type ProcessInfoType = {
|
||||
processId?: number;
|
||||
dataUrl?: string;
|
||||
saveDataUrl?: string;
|
||||
deleteDataUrl?: string;
|
||||
tableInfoUrl?: string;
|
||||
documentRout?: string; // used document "id" link
|
||||
moduleName?: string; // used in the Title of the printed report
|
||||
totalColumns?: Array<string>;
|
||||
staticTableHeaders?: Array<ProFullColumnType<any>>;
|
||||
staticContentTableHeaders?: Array<ProFullColumnType<any>>;
|
||||
|
||||
contentTableInfoUrl?: string;
|
||||
extraParams?: string;
|
||||
parseFunc?: (list: any) => any[];
|
||||
saveParse?: (list: any) => FormData;
|
||||
title?: string;
|
||||
|
||||
filterColumns?: FilterIdentifier[];
|
||||
stopTotalsCalcBySlice?: boolean;
|
||||
stopParseBySlice?: boolean;
|
||||
filterColumnsInfo?: Array<FilterColumnInfo>;
|
||||
noDocDateFilter?: boolean;
|
||||
withImage?: boolean;
|
||||
isReport?: boolean;
|
||||
handleCardClick?: (entityId?: number) => void;
|
||||
};
|
||||
|
||||
export enum FixedType {
|
||||
"left" = "left",
|
||||
"right" = "right",
|
||||
}
|
||||
|
||||
export enum ResourceViewType {
|
||||
"Top" = 1,
|
||||
"Bottom" = 2,
|
||||
"Both" = 3,
|
||||
}
|
||||
|
||||
export type LinkParameterType = {
|
||||
key: string;
|
||||
sign: "=" | ">" | ">=" | "<" | "<=";
|
||||
value: string;
|
||||
};
|
||||
|
||||
export type LoginResponseType = {
|
||||
status: string;
|
||||
token?: string;
|
||||
error?: string;
|
||||
};
|
||||
|
||||
export type LoginUserType = {
|
||||
username?: string;
|
||||
password?: string;
|
||||
};
|
||||
|
||||
export type UserType = {
|
||||
id?: number;
|
||||
first_name?: string;
|
||||
last_name?: string;
|
||||
password?: string;
|
||||
phone_number?: string;
|
||||
salary?: any;
|
||||
employment_date?: any;
|
||||
email?: string;
|
||||
username?: string;
|
||||
personal_image?: any;
|
||||
identity_card_front?: any;
|
||||
identity_card_back?: any;
|
||||
driving_license_front?: any;
|
||||
driving_license_back?: any;
|
||||
roles?: RolesType[];
|
||||
menus: string[];
|
||||
};
|
||||
|
||||
export enum Mode {
|
||||
Edit = 1,
|
||||
New = 2,
|
||||
View = 3,
|
||||
Delete = 4,
|
||||
}
|
||||
|
||||
export type ProTabPaneProps = {
|
||||
key: string;
|
||||
dataIndex?: string;
|
||||
title: string;
|
||||
content?: React.ReactNode;
|
||||
disabled?: boolean;
|
||||
};
|
||||
|
||||
export type TableHeaderType = {
|
||||
extrainfo?: string | number;
|
||||
width?: number;
|
||||
sorter?: any;
|
||||
rowid: number;
|
||||
key: number; // for table header automation
|
||||
id: number;
|
||||
tablename: string;
|
||||
index: string;
|
||||
title: string;
|
||||
order: number;
|
||||
visible: boolean;
|
||||
preset: string;
|
||||
defaultvisible: boolean;
|
||||
};
|
||||
|
||||
export type FilterComponentProps = {
|
||||
filterIdentifier: FilterIdentifier; // unique identifier for all filters
|
||||
};
|
||||
|
||||
export type ActiveFilterType = {
|
||||
filterIdentifier: FilterIdentifier; // unique identifier for all filters
|
||||
filterField?: FilterColumn;
|
||||
filterTitle: string;
|
||||
filterValue: any;
|
||||
filterDefaultValue?: any;
|
||||
filterValueTitle: string;
|
||||
filterRequired?: boolean;
|
||||
filterExtra?: any;
|
||||
};
|
||||
|
||||
export type FilterColumn =
|
||||
| "filters[id][$eq]"
|
||||
| "name"
|
||||
| "documentid"
|
||||
| "documentnumber"
|
||||
| "page"
|
||||
| "filters[is_fully_paid][$eq]"
|
||||
| "filters[customer][first_name][$contains]"
|
||||
| "filters[print_times][$gte]"
|
||||
| "location_id"
|
||||
| "documentdate"
|
||||
| "filters[printed_at][$null]"
|
||||
| "per_page"
|
||||
| "filters[printed_at][$eq]"
|
||||
| "created_at"
|
||||
| "warehouse_id"
|
||||
| "filters[send_datetime][$eq]"
|
||||
| "warehouse_id"
|
||||
| "account_id"
|
||||
| "customer_id"
|
||||
| "currency_id"
|
||||
| "conversion_method"
|
||||
| "financeAccountId"
|
||||
| "printed_at"
|
||||
| "filters[customer][id][$eq]"
|
||||
| "filters['printed_at'][$between][0]"
|
||||
| "supplier_id";
|
||||
|
||||
export type FilterIdentifier =
|
||||
| "DatePicker"
|
||||
| "DateRange"
|
||||
| "DocId"
|
||||
| "DocStatus"
|
||||
| "Page"
|
||||
| "PageSize"
|
||||
| "ShowDebitInvoice"
|
||||
| "CustomerName"
|
||||
| "PrintTimes"
|
||||
| "IsFinanciallyCompleted"
|
||||
| "Floor"
|
||||
| "Warehouse"
|
||||
|
||||
/*
|
||||
** Note: if you need to send some extra default vale without showing an input add its Identifier here
|
||||
** (add the word "Fake" at the end)
|
||||
*/
|
||||
| "ResourceTypeFake"
|
||||
| "ActiveFake"
|
||||
| "ModuleFake";
|
||||
|
||||
export type FilterColumnInfo = {
|
||||
filterIdentifier: FilterIdentifier; // unique identifier for all filters
|
||||
dataIndex?: FilterColumn;
|
||||
defaultValue?: any;
|
||||
required?: boolean;
|
||||
title?: string;
|
||||
valueTitle?: string;
|
||||
extra?: any;
|
||||
};
|
||||
|
||||
export interface ResponseType {
|
||||
status: number;
|
||||
data: Data;
|
||||
}
|
||||
|
||||
export interface Data {
|
||||
message: string;
|
||||
}
|
||||
|
||||
export type ImageType = {
|
||||
collection_name: string;
|
||||
name: string;
|
||||
file_name: string;
|
||||
mime_type: string;
|
||||
size: number;
|
||||
url: string;
|
||||
};
|
||||
|
||||
export enum TableStatus {
|
||||
available = "AVAILABLE",
|
||||
busy = "BUSY",
|
||||
requestPayment = "PENDING_INVOICE",
|
||||
}
|
||||
|
||||
export interface ReservationType {
|
||||
id: number;
|
||||
start_datetime: string;
|
||||
end_datetime: any;
|
||||
seats_reserved: number;
|
||||
orders: OrderType[];
|
||||
invoice: InvoiceType;
|
||||
}
|
||||
|
||||
export interface InvoiceType {
|
||||
id: number;
|
||||
number: number;
|
||||
uuid: string;
|
||||
sub_total: number;
|
||||
grand_total: number;
|
||||
discount_amount: number;
|
||||
taxes_total: number;
|
||||
print_times: number;
|
||||
start_datetime: string;
|
||||
end_datetime: string;
|
||||
printed_at: string;
|
||||
remaining_amount: number;
|
||||
qr_code: QrCode;
|
||||
taxes: TaxType[];
|
||||
items: ItemType[];
|
||||
}
|
||||
|
||||
export interface RegisterType {
|
||||
id: number;
|
||||
opening_balance: number;
|
||||
total_income: number;
|
||||
total_expenses: number;
|
||||
closing_balance: number;
|
||||
grand_total: number;
|
||||
total_cashier_income: number;
|
||||
}
|
||||
|
||||
export interface SessionPayload {
|
||||
closing_balance?: number;
|
||||
total_expenses?: number;
|
||||
}
|
||||
|
||||
export interface RolesType {
|
||||
id: number;
|
||||
name: string;
|
||||
permissions: PermissionType[];
|
||||
}
|
||||
|
||||
export enum Roles {
|
||||
SuperUser = "super-admin",
|
||||
Admin = "admin",
|
||||
Cashier = "cashier",
|
||||
Manager = "manager",
|
||||
TaxAccount = "tax-account",
|
||||
}
|
||||
|
||||
export interface District {
|
||||
id: number;
|
||||
name: string;
|
||||
area: Area;
|
||||
}
|
||||
|
||||
export interface Area {
|
||||
id: number;
|
||||
name: string;
|
||||
province: Province;
|
||||
}
|
||||
|
||||
export interface Province {
|
||||
id: number;
|
||||
name: string;
|
||||
}
|
||||
|
||||
export interface Translation {
|
||||
name: string;
|
||||
locale: string;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// #################################################
|
||||
|
||||
|
||||
export interface CartItem {
|
||||
id: number | string;
|
||||
name: string;
|
||||
price: number;
|
||||
image: string;
|
||||
quantity: number;
|
||||
description: string;
|
||||
variant?: string;
|
||||
extras?: string[];
|
||||
extrasgroup?: string[];
|
||||
}
|
||||
|
||||
export interface User {
|
||||
id: string;
|
||||
email: string;
|
||||
name: string;
|
||||
role: "admin" | "user";
|
||||
}
|
||||
|
||||
export interface Order {
|
||||
id: string;
|
||||
userId: string;
|
||||
items: CartItem[];
|
||||
total: number;
|
||||
status: "pending" | "confirmed" | "completed" | "cancelled";
|
||||
createdAt: string;
|
||||
}
|
||||
|
||||
export type Locale = "en" | "ar";
|
||||
export type Theme = "light" | "dark";
|
||||
|
||||
export interface ApiResponse {
|
||||
success: boolean;
|
||||
result: any;
|
||||
message: string;
|
||||
error: any;
|
||||
}
|
||||
|
||||
export interface Restaurant {
|
||||
id: string;
|
||||
name: string;
|
||||
nameAR: string;
|
||||
address: string;
|
||||
addressAR: string;
|
||||
description: string;
|
||||
descriptionAR: string;
|
||||
lat: string;
|
||||
lng: string;
|
||||
logo: string;
|
||||
cover: string;
|
||||
icon: string;
|
||||
phone: string;
|
||||
subdomain: string;
|
||||
menu_url: string;
|
||||
map_url: string;
|
||||
instagram: string;
|
||||
primary_color: string;
|
||||
package_id: number;
|
||||
price_rate: number;
|
||||
vat: number;
|
||||
delivery_fees: string;
|
||||
global_currency: string;
|
||||
local_currency: string;
|
||||
hasDinein: boolean;
|
||||
dineIn: boolean;
|
||||
viewMenuOnly: boolean;
|
||||
pickup: boolean;
|
||||
delivery: boolean;
|
||||
gift: boolean;
|
||||
toOffice: boolean;
|
||||
toRoom: boolean;
|
||||
online_payment: number;
|
||||
cash_payment: number;
|
||||
isCashPaymentEnabled: boolean;
|
||||
is_wallet_payment_enabled: number;
|
||||
is_booking_enabled: number;
|
||||
is_loyalty_enabled: number;
|
||||
loyalty_stamps: any;
|
||||
loyalty_stamp_image: string;
|
||||
is_call_waiter_enabled: number;
|
||||
is_hotel: number;
|
||||
is_schedule_order_enabled: number;
|
||||
pickup_type: string;
|
||||
use_googlemaps_url: number;
|
||||
view_webmenu_only: number;
|
||||
enable_apple_passkey: number;
|
||||
menu_background: string;
|
||||
taxes: any[];
|
||||
hours: Hours;
|
||||
logom?: string;
|
||||
coverm?: string;
|
||||
}
|
||||
|
||||
export interface Hours {
|
||||
id: number;
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
"0_from": string;
|
||||
"0_to": string;
|
||||
"1_from": string;
|
||||
"1_to": string;
|
||||
"2_from": string;
|
||||
"2_to": string;
|
||||
"3_from": string;
|
||||
"3_to": string;
|
||||
"4_from": string;
|
||||
"4_to": string;
|
||||
"5_from": string;
|
||||
"5_to": string;
|
||||
"6_from": string;
|
||||
"6_to": string;
|
||||
restorant_id: number;
|
||||
"2_0_from": any;
|
||||
"2_0_to": any;
|
||||
"2_1_from": any;
|
||||
"2_1_to": any;
|
||||
"2_2_from": any;
|
||||
"2_2_to": any;
|
||||
"2_3_from": any;
|
||||
"2_3_to": any;
|
||||
"2_4_from": any;
|
||||
"2_4_to": any;
|
||||
"2_5_from": any;
|
||||
"2_5_to": any;
|
||||
"2_6_from": any;
|
||||
"2_6_to": any;
|
||||
}
|
||||
|
||||
export interface RestaurantDetails {
|
||||
dineIn: boolean;
|
||||
viewMenuOnly: boolean;
|
||||
pickup: boolean;
|
||||
delivery: boolean;
|
||||
gift: boolean;
|
||||
toOffice: boolean;
|
||||
toRoom: boolean;
|
||||
restaurant: Restaurant;
|
||||
}
|
||||
|
||||
export interface Category {
|
||||
id: number;
|
||||
name: string;
|
||||
nameAR?: string;
|
||||
nameEN?: string;
|
||||
image?: string;
|
||||
description?: string;
|
||||
descriptionAR?: string;
|
||||
order?: number;
|
||||
is_active?: boolean;
|
||||
created_at?: string;
|
||||
updated_at?: string;
|
||||
}
|
||||
|
||||
export interface Product {
|
||||
id: number;
|
||||
css_object_fit: string;
|
||||
isAvailableBasedOnTime: boolean;
|
||||
no_of_stamps_give: number;
|
||||
isHasLoyalty: boolean;
|
||||
name: string;
|
||||
nameOther: string;
|
||||
price: number;
|
||||
pricing_method: string;
|
||||
original_price: number;
|
||||
preperation_minutes: number;
|
||||
description: string;
|
||||
descriptionAR: string;
|
||||
image: string;
|
||||
imageNew: string;
|
||||
image_small: string;
|
||||
available: boolean;
|
||||
currency: string;
|
||||
variants: Variant[];
|
||||
extras: Extra2[];
|
||||
categoryId?: number; // to be sent
|
||||
isHasExtras: boolean;
|
||||
isHasVarint: boolean;
|
||||
isHasextraGroup: boolean;
|
||||
is_vat_disabled: number;
|
||||
ingredients?: string[];
|
||||
nutritionalInfo?: {
|
||||
calories: number;
|
||||
protein: number;
|
||||
carbs: number;
|
||||
fat: number;
|
||||
};
|
||||
variantsArray: VariantsArray[];
|
||||
theExtrasGroups: TheExtrasGroup[];
|
||||
}
|
||||
|
||||
export interface Variant {
|
||||
id: number;
|
||||
price: number;
|
||||
available: string;
|
||||
options: Option[];
|
||||
optionsAR: Option[];
|
||||
extras: Extra[];
|
||||
}
|
||||
|
||||
export interface Option {
|
||||
option: string;
|
||||
value: string;
|
||||
}
|
||||
|
||||
export interface Extra {
|
||||
id: number;
|
||||
price: number;
|
||||
name: string;
|
||||
}
|
||||
|
||||
export interface Extra2 {
|
||||
id: number;
|
||||
price: number;
|
||||
name: string;
|
||||
}
|
||||
|
||||
export interface TheExtrasGroup {
|
||||
id: number;
|
||||
name: string;
|
||||
nameAR: string;
|
||||
label: string;
|
||||
labelAR: string;
|
||||
limit: number;
|
||||
item_id: number;
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
deleted_at: any;
|
||||
force_limit_selection: number;
|
||||
extras: Extra[];
|
||||
}
|
||||
|
||||
export interface VariantsArray {
|
||||
id: number;
|
||||
price: number;
|
||||
options: string;
|
||||
image: string;
|
||||
qty: number;
|
||||
enable_qty: number;
|
||||
order: number;
|
||||
item_id: number;
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
deleted_at: any;
|
||||
available: string;
|
||||
extras: Extra3[];
|
||||
OptionsList: string;
|
||||
}
|
||||
|
||||
export interface Extra3 {
|
||||
id: number;
|
||||
item_id: number;
|
||||
price: number;
|
||||
name: string;
|
||||
nameAR: string;
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
deleted_at: any;
|
||||
extra_for_all_variants: number;
|
||||
is_custome: number;
|
||||
is_available: number;
|
||||
modifier_id: any;
|
||||
pivot: Pivot;
|
||||
}
|
||||
|
||||
export interface Pivot {
|
||||
variant_id: number;
|
||||
extra_id: number;
|
||||
}
|
||||
|
||||
export interface NutritionalInfo {
|
||||
calories: number;
|
||||
protein: number;
|
||||
carbs: number;
|
||||
fat: number;
|
||||
}
|
||||
62
src/utils/types/bidding.ts
Normal file
62
src/utils/types/bidding.ts
Normal file
@@ -0,0 +1,62 @@
|
||||
export type Bidding = {
|
||||
auction_id: string;
|
||||
nft_name: string;
|
||||
nft_image: string;
|
||||
seller_username: string;
|
||||
buyer_username: string;
|
||||
start_price: number;
|
||||
end_price: number;
|
||||
start_date: string;
|
||||
end_date: string;
|
||||
status: 'active' | 'ending soon' | string;
|
||||
is_highest_bid_mine: boolean;
|
||||
winning_bid: number;
|
||||
time_left: string;
|
||||
};
|
||||
|
||||
export type AuctionCreator = {
|
||||
creator_id: string;
|
||||
first_name: string;
|
||||
last_name: string;
|
||||
age: number;
|
||||
email: string;
|
||||
country: string;
|
||||
postal_code: string | null;
|
||||
favorite_color: string;
|
||||
sales_count: number;
|
||||
total_sales: string;
|
||||
};
|
||||
|
||||
export type AuctionSales = {
|
||||
id: string;
|
||||
title: string;
|
||||
artist: string;
|
||||
volume: number;
|
||||
status: number;
|
||||
owners_count: number;
|
||||
description: string;
|
||||
image_url: string;
|
||||
creation_date: string;
|
||||
edition: number;
|
||||
price: number;
|
||||
owner: string;
|
||||
collection: string;
|
||||
verified: boolean;
|
||||
};
|
||||
|
||||
export type AuctionTransactions = {
|
||||
id: string;
|
||||
image: string;
|
||||
product_id: string;
|
||||
transaction_date: string;
|
||||
seller: string;
|
||||
buyer: string;
|
||||
purchase_price: number;
|
||||
sale_price: number;
|
||||
profit: number;
|
||||
quantity: number;
|
||||
shipping_address: string;
|
||||
state: string | null;
|
||||
country: string;
|
||||
transaction_type: string;
|
||||
};
|
||||
Reference in New Issue
Block a user