nuxt4, and some changes on packages

This commit is contained in:
2025-08-19 21:38:30 +03:30
parent 61fee6c3da
commit 5b6f1a1cdf
900 changed files with 11139 additions and 15161 deletions
@@ -0,0 +1,282 @@
import { ref, reactive, computed } from 'vue';
import { cloneDeep } from 'lodash-es';
import { z as supabaseService } from './server.mjs';
const getFeatureList = async () => supabaseService.fetch("attributes", "select", {
columns: "*, attribute_values(*)"
// field: 'borrower_id',
// value: id
});
const getOneFeature = async (id) => supabaseService.fetch("attributes", "select", {
columns: "*, attribute_values(*)",
field: "id",
value: id
});
const createFeature = async (obj) => {
await supabaseService.fetch("attributes", "insert", {
data: obj
});
};
const createFeatureAttribute = async (obj) => {
await supabaseService.fetch("attribute_values", "insert", {
data: obj
});
};
const previewImg = ref();
const loading = ref(false);
const priceType = ref(1);
let temp = [];
const defaultVariant = ref();
const myAttributeValue = ref([]);
const myAttributes = ref([]);
const mediaFilesUrl = ref([]);
const original = ref({ url: void 0, index: 0 });
const originalFile = ref();
ref();
const items = ref([]);
const variants = ref([]);
const selectedFeatures = ref([]);
const featureItems = ref([]);
const formFields = reactive(
{
title_fa: "",
title: "",
price: 0,
body: "",
is_show: true,
is_active: true,
box_size: 0,
sell_type: "numeric",
original_image: void 0,
product_attributes: [],
files: [],
price_type: "manual",
auto_calculate: false,
sku: null,
created_at: void 0,
updated_at: void 0,
deleted_at: null,
count_order: void 0,
count_fav: void 0,
count_view: void 0,
min_price: void 0,
max_price: void 0,
type: "simple",
owner_id: void 0,
users: void 0,
saved: [],
variants: [],
code: void 0,
brand_id: void 0,
// brand: undefined,
collection_id: void 0,
discount: void 0,
discount_type: void 0,
// main_slider: false,
// bottom_slider: false,
id: void 0,
count: void 0,
display_price: void 0,
// weight: null,
meta: void 0,
seo_title: void 0,
description: void 0,
product_type: void 0,
weight: void 0,
rial_fee: void 0,
percent_fee: void 0
}
);
const baseFormFields = cloneDeep(formFields);
function resetFormFields() {
Object.assign(formFields, baseFormFields);
myAttributes.value = [];
myAttributeValue.value = [];
variants.value = [];
priceType.value = 1;
original.value = { url: void 0, index: 0 };
mediaFilesUrl.value = [];
defaultVariant.value = void 0;
previewImg.value = void 0;
}
const files = computed(() => {
let tempMedia = cloneDeep(mediaFilesUrl.value);
tempMedia?.splice(0, 0, original.value);
tempMedia = tempMedia?.map((value, index) => {
return value;
});
console.log(tempMedia);
return tempMedia;
});
function addToVariants() {
let attrIds = [];
let attrNames = [];
myAttributeValue.value?.forEach((attributeValue) => {
if (!attributeValue.valueId) ;
attrIds.push(attributeValue.valueId);
attrNames.push(attributeValue.valueName);
});
console.log(attrIds, myAttributeValue.value);
formFields.variants?.push({
id: void 0,
attribute_values: [],
attribute_values_name: [],
price: 0,
weight: 0,
stock: 0,
auto_calculate: false,
discount_type: void 0,
discount: void 0,
is_default: false,
sku: ""
});
console.log(variants, formFields.variants);
}
function updateMyAttrs(newValue, flag) {
let tempAttributes = newValue;
priceType.value = 1;
myAttributes.value = [];
myAttributeValue.value = [];
console.log(newValue);
console.log("why");
let tempIndex = 0;
let notShowInVarIndexArray = [];
newValue?.forEach((x, index) => {
console.log(x, index);
if (x.show_in_variable) {
priceType.value = 2;
if (formFields.variants.length === 0)
addToVariants();
myAttributes.value.push({
attributeId: x.id,
name: x.name,
values: x.new_feature,
show: x.show_in_variable,
valueKey: index
});
x.new_feature?.forEach((val, i) => {
myAttributeValue.value.push({
attributeName: x.name,
attributeId: x.id,
valueId: val.id,
valueName: val.value,
valueKey: tempIndex
});
});
} else {
notShowInVarIndexArray.push(index);
variants.value?.forEach((val) => {
console.log("val.attribute_values>", index);
console.log(val.attribute_values);
console.log("myAttributes.value.length " + tempAttributes.length);
console.log("val.attribute_values.length " + val.attribute_values.length);
if (tempAttributes.length > val.attribute_values.length && val.attribute_values[index] != null) {
if (val.attribute_values.length != index) {
val.attribute_values.splice(index, 0, null);
val.attribute_values_name.splice(index, 0, null);
} else {
val.attribute_values = [...val.attribute_values, null];
val.attribute_values_name = [...val.attribute_values_name, null];
}
}
console.log("val.attribute_values After slice>" + index);
console.log(val.attribute_values);
});
}
tempIndex++;
variants.value?.forEach((val, ind) => {
if (tempAttributes.length > val.attribute_values.length && val.attribute_values[index] != null) {
val.attribute_values = [...val.attribute_values, null];
val.attribute_values_name = [...val.attribute_values_name, null];
}
});
console.log("variants+++");
});
console.log("tempIndexArray");
console.log(notShowInVarIndexArray);
sortAttributeByValueKey(variants.value);
if (notShowInVarIndexArray.length != 0) {
variants.value?.forEach((val) => {
notShowInVarIndexArray.forEach((y) => {
val.attribute_values[y] = null;
val.attribute_values_name[y] = null;
});
});
}
}
function sortAttributeByValueKey(x) {
console.log("444444", x);
x?.forEach((val, ind) => {
temp = cloneDeep(val.attribute_values);
if (myAttributes.value.length <= temp.length) {
temp?.forEach((x2, i) => {
myAttributeValue.value?.forEach((item, index) => {
if (temp.find((e) => e == item?.valueId) && val.attribute_values[item.valueKey] != temp.find((e) => e == item.valueId)) {
val.attribute_values[item.valueKey] = temp.find((e) => e == item.valueId);
val.attribute_values_name[item.valueKey] = item.valueName;
}
console.log(val?.attribute_values + "AFTER CHANGE ITEM" + ind);
});
});
}
if (ind == 0) {
defaultVariant.value = showDefaultVal(val.attribute_values_name);
}
if (val.is_default) {
console.log("val.attribute_values", val.attribute_values_name);
defaultVariant.value = showDefaultVal(val.attribute_values_name);
console.log("defaultVariant", defaultVariant.value);
}
});
}
function showDefaultVal(val) {
console.log(val, defaultVariant.value);
let res = "";
val.forEach((x, index) => {
if (x) return res += (index !== 0 ? " - " : "") + x;
});
return res;
}
async function getFeatures() {
try {
loading.value = true;
featureItems.value = await getFeatureList();
} catch (e) {
console.log(e);
} finally {
loading.value = false;
}
}
async function setItems(new_features) {
let featureTemp;
if (new_features[new_features.length - 1] != null)
featureTemp = await getOneFeature(new_features[new_features.length - 1]);
let feature;
feature = featureTemp[0];
Object.assign(feature, {
new_feature: [],
show_in_product: false,
show_in_variable: false
});
console.log("gggggggggggggggggggggggggggggggg", feature);
items.value.push(feature);
}
async function editItems(id) {
const featureTemp = await getOneFeature(id);
const forEditAttribute = items.value.find((x) => x.id === id);
if (forEditAttribute) {
console.log(forEditAttribute.attribute_values, featureTemp[0].attribute_values);
forEditAttribute.attribute_values = [];
forEditAttribute.attribute_values = featureTemp[0]?.attribute_values ? cloneDeep(featureTemp[0]?.attribute_values) : [];
console.log(forEditAttribute.attribute_values);
}
}
const findEdit = (val) => {
console.log("fsdfuygiuhguighuisdf", val);
return val.split("-")[0] === "edit";
};
const firstFiles = ref([]);
ref([]);
export { files as a, setItems as b, formFields as c, findEdit as d, priceType as e, firstFiles as f, addToVariants as g, myAttributes as h, items as i, featureItems as j, getFeatures as k, createFeature as l, mediaFilesUrl as m, createFeatureAttribute as n, original as o, previewImg as p, editItems as q, resetFormFields as r, selectedFeatures as s, loading as t, updateMyAttrs as u, variants as v, originalFile as w };
//# sourceMappingURL=handle-B6YUQ-uU.mjs.map