refactor: remove console logs for token refresh and user profile requests in SubmitData and AppointmentPage components
This commit is contained in:
@@ -13,7 +13,6 @@ function SubmitData({ setStep, data, prevData, setErrors }) {
|
|||||||
try {
|
try {
|
||||||
const refreshToken = Cookies.get("refresh_token");
|
const refreshToken = Cookies.get("refresh_token");
|
||||||
if (!refreshToken) {
|
if (!refreshToken) {
|
||||||
console.log("⚠️ refresh_token موجود نیست");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -23,7 +22,6 @@ function SubmitData({ setStep, data, prevData, setErrors }) {
|
|||||||
formData.append("client_secret", process.env.NEXT_PUBLIC_CLIENT_SECRET || "13yfCHptFjsIoEzwA996bjGuSEFy02Dkc");
|
formData.append("client_secret", process.env.NEXT_PUBLIC_CLIENT_SECRET || "13yfCHptFjsIoEzwA996bjGuSEFy02Dkc");
|
||||||
formData.append("refresh_token", refreshToken);
|
formData.append("refresh_token", refreshToken);
|
||||||
|
|
||||||
console.log("🔄 در حال refresh کردن access token...");
|
|
||||||
const response = await request.postRefreshToken(formData);
|
const response = await request.postRefreshToken(formData);
|
||||||
|
|
||||||
if (response?.access_token) {
|
if (response?.access_token) {
|
||||||
@@ -31,10 +29,9 @@ function SubmitData({ setStep, data, prevData, setErrors }) {
|
|||||||
if (response.refresh_token) {
|
if (response.refresh_token) {
|
||||||
Cookies.set("refresh_token", response.refresh_token, { expires: 7 });
|
Cookies.set("refresh_token", response.refresh_token, { expires: 7 });
|
||||||
}
|
}
|
||||||
console.log("✅ access token با موفقیت refresh شد");
|
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log("❌ خطا در refresh token:", error);
|
// خطا در refresh token
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -90,14 +87,11 @@ function SubmitData({ setStep, data, prevData, setErrors }) {
|
|||||||
try {
|
try {
|
||||||
if (uuid) {
|
if (uuid) {
|
||||||
// اگر uuid داریم، پروفایل وجود داره و باید PATCH کنیم
|
// اگر uuid داریم، پروفایل وجود داره و باید PATCH کنیم
|
||||||
console.log('📤 ارسال درخواست PATCH - UUID:', uuid, 'Payload:', payload);
|
|
||||||
await request.patchUserProfile(payload, uuid);
|
await request.patchUserProfile(payload, uuid);
|
||||||
} else {
|
} else {
|
||||||
// اگر uuid نداریم، پروفایل وجود نداره و باید POST کنیم
|
// اگر uuid نداریم، پروفایل وجود نداره و باید POST کنیم
|
||||||
console.log('📤 ارسال درخواست POST - Payload:', payload);
|
|
||||||
await request.postUserProfile(payload);
|
await request.postUserProfile(payload);
|
||||||
}
|
}
|
||||||
console.log('✅ پروفایل با موفقیت ذخیره شد');
|
|
||||||
|
|
||||||
// فوراً بعد از موفقیت، refresh token میزنیم
|
// فوراً بعد از موفقیت، refresh token میزنیم
|
||||||
await refreshAccessToken();
|
await refreshAccessToken();
|
||||||
@@ -105,7 +99,6 @@ function SubmitData({ setStep, data, prevData, setErrors }) {
|
|||||||
setLoading(false);
|
setLoading(false);
|
||||||
newStep();
|
newStep();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log('❌ خطا در ذخیره پروفایل:', error?.response?.data || error);
|
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
// اگر خطای validation بود، error ها را ست میکنیم
|
// اگر خطای validation بود، error ها را ست میکنیم
|
||||||
if (error?.response?.data) {
|
if (error?.response?.data) {
|
||||||
|
|||||||
@@ -52,13 +52,9 @@ function AppointmentPage({ doctor, disabledDates, matchedCity }) {
|
|||||||
// سپس اگر uuid داریم، بقیه اطلاعات را از API میگیریم
|
// سپس اگر uuid داریم، بقیه اطلاعات را از API میگیریم
|
||||||
if (userInfo && parsedData) {
|
if (userInfo && parsedData) {
|
||||||
try {
|
try {
|
||||||
console.log('📤 درخواست دریافت پروفایل کاربر - UUID:', parsedData.uuid);
|
|
||||||
const res = await request.getUserProfile(parsedData.uuid);
|
const res = await request.getUserProfile(parsedData.uuid);
|
||||||
console.log('📥 پاسخ دریافتی از API:', res);
|
|
||||||
|
|
||||||
if (res) {
|
if (res) {
|
||||||
console.log('🏥 basic_insurance از API:', res.basic_insurance);
|
|
||||||
console.log('🏥 supplementary_insurance از API:', res.supplementary_insurance);
|
|
||||||
const newData = {
|
const newData = {
|
||||||
uuid: res.uuid,
|
uuid: res.uuid,
|
||||||
phone: { value: usernameFromCookie, isEdit: false },
|
phone: { value: usernameFromCookie, isEdit: false },
|
||||||
@@ -120,7 +116,6 @@ function AppointmentPage({ doctor, disabledDates, matchedCity }) {
|
|||||||
|
|
||||||
if (userInfo && parsedData && !data.uuid) {
|
if (userInfo && parsedData && !data.uuid) {
|
||||||
try {
|
try {
|
||||||
console.log('📤 درخواست مجدد دریافت پروفایل (step 3) - UUID:', parsedData.uuid);
|
|
||||||
const res = await request.getUserProfile(parsedData.uuid);
|
const res = await request.getUserProfile(parsedData.uuid);
|
||||||
|
|
||||||
if (res) {
|
if (res) {
|
||||||
|
|||||||
Reference in New Issue
Block a user