feat: update color carrier
This commit is contained in:
@@ -16,9 +16,10 @@ export type Carrier = {
|
||||
city: string;
|
||||
city_id: number;
|
||||
logo: string;
|
||||
// main_color: string;
|
||||
// left_color: string;
|
||||
// right_color: string;
|
||||
main_color: string;
|
||||
left_color: string;
|
||||
right_color: string;
|
||||
rgb_color: string;
|
||||
};
|
||||
|
||||
type CarrierData = {
|
||||
@@ -112,6 +113,10 @@ class CarrierStore {
|
||||
createCarrierData = {
|
||||
city_id: 0,
|
||||
logo: "",
|
||||
main_color: "",
|
||||
left_color: "",
|
||||
right_color: "",
|
||||
rgb_color: "",
|
||||
ru: {
|
||||
full_name: "",
|
||||
short_name: "",
|
||||
@@ -135,10 +140,17 @@ class CarrierStore {
|
||||
cityId: number,
|
||||
slogan: string,
|
||||
logoId: string,
|
||||
language: Language
|
||||
language: Language,
|
||||
colors?: { main_color?: string; left_color?: string; right_color?: string; rgb_color?: string }
|
||||
) => {
|
||||
this.createCarrierData.city_id = cityId;
|
||||
this.createCarrierData.logo = logoId;
|
||||
if (colors) {
|
||||
if (colors.main_color !== undefined) this.createCarrierData.main_color = colors.main_color;
|
||||
if (colors.left_color !== undefined) this.createCarrierData.left_color = colors.left_color;
|
||||
if (colors.right_color !== undefined) this.createCarrierData.right_color = colors.right_color;
|
||||
if (colors.rgb_color !== undefined) this.createCarrierData.rgb_color = colors.rgb_color;
|
||||
}
|
||||
this.createCarrierData[language] = {
|
||||
full_name: fullName,
|
||||
short_name: shortName,
|
||||
@@ -198,9 +210,11 @@ class CarrierStore {
|
||||
city: cityName,
|
||||
city_id: this.createCarrierData.city_id,
|
||||
slogan: (this.createCarrierData[language].slogan || "").trim(),
|
||||
...(this.createCarrierData.logo
|
||||
? { logo: this.createCarrierData.logo }
|
||||
: {}),
|
||||
...(this.createCarrierData.logo ? { logo: this.createCarrierData.logo } : {}),
|
||||
...(this.createCarrierData.rgb_color ? { rgb_color: this.createCarrierData.rgb_color } : {}),
|
||||
...(this.createCarrierData.main_color ? { main_color: this.createCarrierData.main_color } : {}),
|
||||
...(this.createCarrierData.left_color ? { left_color: this.createCarrierData.left_color } : {}),
|
||||
...(this.createCarrierData.right_color ? { right_color: this.createCarrierData.right_color } : {}),
|
||||
};
|
||||
|
||||
const response = await languageInstance(language).post("/carrier", payload);
|
||||
@@ -243,6 +257,10 @@ class CarrierStore {
|
||||
this.createCarrierData = {
|
||||
city_id: 0,
|
||||
logo: "",
|
||||
main_color: "",
|
||||
left_color: "",
|
||||
right_color: "",
|
||||
rgb_color: "",
|
||||
ru: {
|
||||
full_name: "",
|
||||
short_name: "",
|
||||
@@ -265,53 +283,46 @@ class CarrierStore {
|
||||
ru: {
|
||||
full_name: "",
|
||||
short_name: "",
|
||||
|
||||
// main_color: "",
|
||||
// left_color: "",
|
||||
// right_color: "",
|
||||
slogan: "",
|
||||
},
|
||||
en: {
|
||||
full_name: "",
|
||||
short_name: "",
|
||||
|
||||
// main_color: "",
|
||||
// left_color: "",
|
||||
// right_color: "",
|
||||
slogan: "",
|
||||
},
|
||||
zh: {
|
||||
full_name: "",
|
||||
short_name: "",
|
||||
slogan: "",
|
||||
},
|
||||
city_id: 0,
|
||||
logo: "",
|
||||
zh: {
|
||||
full_name: "",
|
||||
short_name: "",
|
||||
|
||||
// main_color: "",
|
||||
// left_color: "",
|
||||
// right_color: "",
|
||||
slogan: "",
|
||||
},
|
||||
main_color: "",
|
||||
left_color: "",
|
||||
right_color: "",
|
||||
rgb_color: "",
|
||||
};
|
||||
|
||||
setEditCarrierData = (
|
||||
fullName: string,
|
||||
shortName: string,
|
||||
cityId: number,
|
||||
// main_color: string,
|
||||
// left_color: string,
|
||||
// right_color: string,
|
||||
slogan: string,
|
||||
logoId: string,
|
||||
language: Language
|
||||
language: Language,
|
||||
colors?: { main_color?: string; left_color?: string; right_color?: string; rgb_color?: string }
|
||||
) => {
|
||||
this.editCarrierData.city_id = cityId;
|
||||
this.editCarrierData.logo = logoId;
|
||||
if (colors) {
|
||||
if (colors.main_color !== undefined) this.editCarrierData.main_color = colors.main_color;
|
||||
if (colors.left_color !== undefined) this.editCarrierData.left_color = colors.left_color;
|
||||
if (colors.right_color !== undefined) this.editCarrierData.right_color = colors.right_color;
|
||||
if (colors.rgb_color !== undefined) this.editCarrierData.rgb_color = colors.rgb_color;
|
||||
}
|
||||
this.editCarrierData[language] = {
|
||||
full_name: fullName,
|
||||
short_name: shortName,
|
||||
// main_color: main_color,
|
||||
// left_color: left_color,
|
||||
// right_color: right_color,
|
||||
slogan: slogan,
|
||||
};
|
||||
};
|
||||
@@ -326,9 +337,11 @@ class CarrierStore {
|
||||
slogan: (this.editCarrierData[lang].slogan || "").trim(),
|
||||
city: cityName,
|
||||
city_id: this.editCarrierData.city_id,
|
||||
...(this.editCarrierData.logo
|
||||
? { logo: this.editCarrierData.logo }
|
||||
: {}),
|
||||
...(this.editCarrierData.logo ? { logo: this.editCarrierData.logo } : {}),
|
||||
...(this.editCarrierData.rgb_color ? { rgb_color: this.editCarrierData.rgb_color } : {}),
|
||||
...(this.editCarrierData.main_color ? { main_color: this.editCarrierData.main_color } : {}),
|
||||
...(this.editCarrierData.left_color ? { left_color: this.editCarrierData.left_color } : {}),
|
||||
...(this.editCarrierData.right_color ? { right_color: this.editCarrierData.right_color } : {}),
|
||||
});
|
||||
|
||||
runInAction(() => {
|
||||
|
||||
Reference in New Issue
Block a user