Hadeeratef91 commited on
Commit
120f885
ยท
verified ยท
1 Parent(s): a148838

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -2
app.py CHANGED
@@ -58,9 +58,35 @@ if not st.session_state.is_logged_in:
58
  # -----------------------------------------
59
  # ู…ู‚ุฏู… ุงู„ุดูƒูˆู‰
60
  elif st.session_state.user_type == "sender":
61
- st.title("๐Ÿ“จ ุชู‚ุฏูŠู… ุดูƒูˆู‰")
62
- if "complaint_input" not in st.session_state:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
63
  st.session_state["complaint_input"] = ""
 
 
 
64
 
65
  complaint_text = st.text_area("๐Ÿ“ ูˆุตู ุงู„ุดูƒูˆู‰", key="complaint_input")
66
  if st.button("๐Ÿ“ค ุฅุฑุณุงู„ ุงู„ุดูƒูˆู‰"):
 
58
  # -----------------------------------------
59
  # ู…ู‚ุฏู… ุงู„ุดูƒูˆู‰
60
  elif st.session_state.user_type == "sender":
61
+ complaint_text = st.text_area("๐Ÿ“ ูˆุตู ุงู„ุดูƒูˆู‰", key="complaint_input")
62
+
63
+ if st.button("๐Ÿ“ค ุฅุฑุณุงู„ ุงู„ุดูƒูˆู‰"):
64
+ existing_user_complaints = df[df["username"] == st.session_state.username]
65
+ if st.session_state["complaint_input"].strip() in existing_user_complaints["complaint_text"].values:
66
+ st.warning("โš ๏ธ ุชู… ุฅุฑุณุงู„ ู‡ุฐู‡ ุงู„ุดูƒูˆู‰ ู…ุณุจู‚ู‹ุง!")
67
+ elif st.session_state["complaint_input"].strip() == "":
68
+ st.warning("โš ๏ธ ุงู„ุฑุฌุงุก ุฅุฏุฎุงู„ ู†ุต ุงู„ุดูƒูˆู‰.")
69
+ else:
70
+ prefix = st.session_state.username[:4].lower()
71
+ next_id = len(existing_user_complaints) + 1
72
+ complaint_id = f"{prefix}_{next_id:06}"
73
+ timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
74
+ new_complaint = {
75
+ "complaint_id": complaint_id,
76
+ "username": st.session_state.username,
77
+ "complaint_text": st.session_state["complaint_input"].strip(),
78
+ "status": "Pending",
79
+ "response": "",
80
+ "timestamp": timestamp
81
+ }
82
+ df = pd.concat([df, pd.DataFrame([new_complaint])], ignore_index=True)
83
+ df.to_csv(file_path, index=False, encoding='utf-8-sig')
84
+ st.success("โœ… ุชู… ุชู‚ุฏูŠู… ุงู„ุดูƒูˆู‰ ุจู†ุฌุงุญ")
85
+ # ุฅุนุงุฏุฉ ุชุนูŠูŠู† ุงู„ู‚ูŠู…ุฉ ุนุจุฑ ุทุฑูŠู‚ุฉ rerun ุงู„ุขู…ู†ุฉ:
86
  st.session_state["complaint_input"] = ""
87
+ st.rerun()
88
+
89
+
90
 
91
  complaint_text = st.text_area("๐Ÿ“ ูˆุตู ุงู„ุดูƒูˆู‰", key="complaint_input")
92
  if st.button("๐Ÿ“ค ุฅุฑุณุงู„ ุงู„ุดูƒูˆู‰"):