feat: complete admin panel and backend admin api migration

This commit is contained in:
s.esmaeili
2026-09-13 21:02:25 +03:30
parent 03119cd655
commit 267fc7b7d1
239 changed files with 25431 additions and 935 deletions
+72
View File
@@ -0,0 +1,72 @@
// Ported from legacy henza_admin/src/filters/filters.js
//
// Vue 3 removed `Vue.filter`, so these are plain functions imported where needed.
// Each body is carried over verbatim, including legacy's quirks:
// - priceUnit returns the input UNCHANGED when falsy (so 0 renders as "0",
// not "0 تومان") and appends a trailing space after 'تومان'
// - jdateTime uses 'hh:mm:ss' (12-hour) rather than 'HH:mm:ss'
import moment from 'moment-jalaali';
export function capitalize(value: string) {
if (!value) return '';
value = value.toString();
const arr = value.split(' ');
const capitalized_array: string[] = [];
arr.forEach((word) => {
const capitalized = word.charAt(0).toUpperCase() + word.slice(1);
capitalized_array.push(capitalized);
});
return capitalized_array.join(' ');
}
export function title(value: string, replacer = '_') {
if (!value) return '';
value = value.toString();
const arr = value.split(replacer);
const capitalized_array: string[] = [];
arr.forEach((word) => {
const capitalized = word.charAt(0).toUpperCase() + word.slice(1);
capitalized_array.push(capitalized);
});
return capitalized_array.join(' ');
}
export function truncate(value: string, limit: number) {
return value.substring(0, limit);
}
/** legacy: thousands separators + ' تومان ' (note the trailing space) */
export function priceUnit(val: unknown) {
if (val) {
return val.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',') + ' تومان ';
}
return val;
}
/** legacy: plain thousands separators, no unit */
export function price(val: unknown) {
if (val) {
return val.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',');
}
return val;
}
/** Jalali date, legacy format 'jYYYY/jMM/jDD' */
export function jdate(val: unknown) {
if (val) {
return moment(val as string).format('jYYYY/jMM/jDD');
}
return val;
}
/** Jalali date+time. Legacy used 12-hour 'hh' here — preserved. */
export function jdateTime(val: unknown) {
if (val) {
return moment(val as string).format('jYYYY/jMM/jDD - hh:mm:ss');
}
return val;
}
export function none<T>(val: T) {
return val;
}
+19
View File
@@ -0,0 +1,19 @@
// Ported from legacy henza_admin/src/utils/index.js
//
// Legacy:
// export function isBranch(){
// console.log(process.env.NODE_ENV)
// return process.env.NODE_ENV=='branch'
// }
//
// Vite has no process.env at runtime; the equivalent build-time switch is the
// --mode flag, exposed as import.meta.env.MODE. Run `pnpm dev:branch` for branch mode.
// The legacy console.log is intentionally not carried over (debug noise, no behaviour).
export function isBranch(): boolean {
return import.meta.env.MODE === 'branch';
}
// Legacy stored the token under a different localStorage key per mode.
// See henza_admin/src/axios.js:6 and router.js:173-174,188.
export const tokenName = isBranch() ? 'branch_token' : 'token';
export const userName = isBranch() ? 'branch_user' : 'user';