Skip to content

Commit dc712dc

Browse files
authored
Merge branch 'main' into ahmad/weatherstack-app
2 parents 96f3f63 + b47c09d commit dc712dc

File tree

62 files changed

+2355
-31
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+2355
-31
lines changed

.github/workflows/deploy.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,18 @@ jobs:
7171
admin_dashboard)
7272
echo "EXTRA_ARGS=" >> $GITHUB_ENV
7373
;;
74+
admin_panel)
75+
echo "EXTRA_ARGS=" >> $GITHUB_ENV
76+
;;
7477
stock_market_dashboard)
7578
echo "EXTRA_ARGS=" >> $GITHUB_ENV
7679
;;
7780
business_analytics_dashboard)
7881
echo "EXTRA_ARGS=" >> $GITHUB_ENV
7982
;;
83+
retail_dashboard)
84+
echo "EXTRA_ARGS=" >> $GITHUB_ENV
85+
;;
8086
manufacturing_dashboard)
8187
echo "EXTRA_ARGS=" >> $GITHUB_ENV
8288
;;
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
reflex>=0.7.8
1+
reflex>=0.7.11
22
python-dateutil>=2.9.0

admin_dashboard/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
reflex>=0.7.8
1+
reflex>=0.7.11

admin_panel/.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
.states
2+
__pycache__/
3+
*.py[cod]
4+
assets/external/
5+
.web
6+
*.db

admin_panel/admin_panel/__init__.py

Whitespace-only changes.
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import reflex as rx
2+
3+
from admin_panel.components.customer_form import customer_edit_form
4+
from admin_panel.components.customer_table import customer_table
5+
from admin_panel.states.customer_state import CustomerState
6+
7+
8+
def index() -> rx.Component:
9+
return rx.el.div(
10+
rx.el.main(
11+
rx.el.div(
12+
rx.cond(
13+
CustomerState.error_message != "",
14+
rx.el.div(
15+
CustomerState.error_message,
16+
class_name=rx.cond(
17+
CustomerState.error_message.contains("Failed")
18+
| CustomerState.error_message.contains(
19+
"Failed to simulate"
20+
),
21+
"mb-4 p-4 rounded-md text-sm bg-red-100 border border-red-300 text-red-700 shadow",
22+
"mb-4 p-4 rounded-md text-sm bg-yellow-100 border border-yellow-300 text-yellow-700 shadow",
23+
),
24+
),
25+
rx.fragment(),
26+
),
27+
customer_table(),
28+
customer_edit_form(),
29+
class_name="mx-auto w-full lg:p-8 p-4",
30+
)
31+
),
32+
class_name="min-h-screen bg-gray-100 font-['Inter']",
33+
)
34+
35+
36+
app = rx.App(
37+
theme=rx.theme(appearance="light"),
38+
head_components=[
39+
rx.el.link(
40+
rel="preconnect",
41+
href="https://fonts.googleapis.com",
42+
),
43+
rx.el.link(
44+
rel="preconnect",
45+
href="https://fonts.gstatic.com",
46+
crossorigin="",
47+
),
48+
rx.el.link(
49+
href="https://fonts.googleapis.com/css2?family=Inter:wght@400..700&display=swap",
50+
rel="stylesheet",
51+
),
52+
],
53+
)
54+
app.add_page(index, route="/", on_load=CustomerState.fetch_customers)

admin_panel/admin_panel/components/__init__.py

Whitespace-only changes.
Lines changed: 184 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,184 @@
1+
import reflex as rx
2+
3+
from admin_panel.states.customer_state import CustomerState
4+
5+
6+
def customer_edit_form() -> rx.Component:
7+
return rx.el.dialog(
8+
rx.el.div(
9+
rx.el.h2(
10+
rx.cond(
11+
CustomerState.form_customer_id == 0,
12+
"Add New User",
13+
"Edit User",
14+
),
15+
class_name="text-lg sm:text-xl font-semibold mb-4 sm:mb-6 text-gray-800",
16+
),
17+
rx.el.form(
18+
rx.el.input(
19+
type="hidden",
20+
name="customer_id",
21+
default_value=CustomerState.form_customer_id.to_string(),
22+
key=rx.cond(
23+
CustomerState.form_customer_id == 0,
24+
"customer_id-new-form",
25+
CustomerState.form_customer_id.to_string() + "_cust_id_form",
26+
),
27+
),
28+
rx.el.div(
29+
rx.el.label(
30+
"First Name:",
31+
html_for="form_first_name_input",
32+
class_name="block text-xs sm:text-sm font-medium text-gray-700 mb-1",
33+
),
34+
rx.el.input(
35+
id="form_first_name_input",
36+
name="first_name",
37+
class_name="mt-1 block w-full px-3 py-2 bg-white border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 text-xs sm:text-sm",
38+
placeholder="Enter first name",
39+
default_value=CustomerState.form_first_name,
40+
key=rx.cond(
41+
CustomerState.form_customer_id == 0,
42+
"form_first_name-new-form",
43+
CustomerState.form_customer_id.to_string() + "_fn_form",
44+
),
45+
),
46+
class_name="mb-3 sm:mb-4",
47+
),
48+
rx.el.div(
49+
rx.el.label(
50+
"Last Name:",
51+
html_for="form_last_name_input",
52+
class_name="block text-xs sm:text-sm font-medium text-gray-700 mb-1",
53+
),
54+
rx.el.input(
55+
id="form_last_name_input",
56+
name="last_name",
57+
class_name="mt-1 block w-full px-3 py-2 bg-white border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 text-xs sm:text-sm",
58+
placeholder="Enter last name",
59+
default_value=CustomerState.form_last_name,
60+
key=rx.cond(
61+
CustomerState.form_customer_id == 0,
62+
"form_last_name-new-form",
63+
CustomerState.form_customer_id.to_string() + "_ln_form",
64+
),
65+
),
66+
class_name="mb-3 sm:mb-4",
67+
),
68+
rx.el.div(
69+
rx.el.label(
70+
"Email:",
71+
html_for="form_email_input",
72+
class_name="block text-xs sm:text-sm font-medium text-gray-700 mb-1",
73+
),
74+
rx.el.input(
75+
id="form_email_input",
76+
name="email",
77+
type="email",
78+
class_name="mt-1 block w-full px-3 py-2 bg-white border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 text-xs sm:text-sm",
79+
placeholder="Enter email",
80+
default_value=CustomerState.form_email,
81+
key=rx.cond(
82+
CustomerState.form_customer_id == 0,
83+
"form_email-new-form",
84+
CustomerState.form_customer_id.to_string() + "_email_form",
85+
),
86+
),
87+
class_name="mb-3 sm:mb-4",
88+
),
89+
rx.el.div(
90+
rx.el.label(
91+
"Tag:",
92+
html_for="form_tags_input",
93+
class_name="block text-xs sm:text-sm font-medium text-gray-700 mb-1",
94+
),
95+
rx.el.input(
96+
id="form_tags_input",
97+
name="tags",
98+
class_name="mt-1 block w-full px-3 py-2 bg-white border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 text-xs sm:text-sm",
99+
placeholder="Enter a single tag",
100+
default_value=CustomerState.form_tags,
101+
key=rx.cond(
102+
CustomerState.form_customer_id == 0,
103+
"form_tags-new-form",
104+
CustomerState.form_customer_id.to_string() + "_tags_form",
105+
),
106+
),
107+
class_name="mb-3 sm:mb-4",
108+
),
109+
rx.el.div(
110+
rx.el.label(
111+
"Role:",
112+
html_for="form_role_select",
113+
class_name="block text-xs sm:text-sm font-medium text-gray-700 mb-1",
114+
),
115+
rx.el.select(
116+
rx.foreach(
117+
CustomerState.available_roles,
118+
lambda role: rx.el.option(role, value=role),
119+
),
120+
id="form_role_select",
121+
name="role",
122+
value=CustomerState.form_role,
123+
on_change=CustomerState.set_form_role,
124+
class_name="mt-1 block w-full pl-3 pr-10 py-2 text-base bg-white border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 text-xs sm:text-sm",
125+
key=rx.cond(
126+
CustomerState.form_customer_id == 0,
127+
"form_role-new-form",
128+
CustomerState.form_customer_id.to_string() + "_role_form",
129+
),
130+
),
131+
class_name="mb-3 sm:mb-4",
132+
),
133+
rx.el.div(
134+
rx.el.label(
135+
"Status:",
136+
html_for="form_status_select",
137+
class_name="block text-xs sm:text-sm font-medium text-gray-700 mb-1",
138+
),
139+
rx.el.select(
140+
rx.foreach(
141+
CustomerState.customer_statuses,
142+
lambda status: rx.el.option(status, value=status),
143+
),
144+
id="form_status_select",
145+
name="status",
146+
value=CustomerState.form_status,
147+
on_change=CustomerState.set_form_status,
148+
class_name="mt-1 block w-full pl-3 pr-10 py-2 text-base bg-white border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 text-xs sm:text-sm",
149+
key=rx.cond(
150+
CustomerState.form_customer_id == 0,
151+
"form_status-new-form",
152+
CustomerState.form_customer_id.to_string() + "_status_form",
153+
),
154+
),
155+
class_name="mb-4 sm:mb-6",
156+
),
157+
rx.el.div(
158+
rx.el.button(
159+
"Cancel",
160+
type="button",
161+
on_click=CustomerState.toggle_edit_dialog,
162+
class_name="mr-2 sm:mr-3 px-3 py-2 sm:px-4 text-xs sm:text-sm font-medium text-gray-700 bg-white border border-gray-300 rounded-md shadow-sm hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500",
163+
),
164+
rx.el.button(
165+
rx.cond(
166+
CustomerState.form_customer_id == 0,
167+
"Add User",
168+
"Save Changes",
169+
),
170+
type="submit",
171+
class_name="px-3 py-2 sm:px-4 text-xs sm:text-sm font-medium text-white bg-blue-600 border border-transparent rounded-md shadow-sm hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500",
172+
),
173+
class_name="flex justify-end pt-1 sm:pt-2",
174+
),
175+
on_submit=CustomerState.handle_edit_customer,
176+
reset_on_submit=False,
177+
class_name="space-y-3 sm:space-y-4",
178+
),
179+
class_name="bg-white p-4 sm:p-6 rounded-lg shadow-xl w-full max-w-md mx-auto",
180+
),
181+
open=CustomerState.show_edit_dialog,
182+
data_state=rx.cond(CustomerState.show_edit_dialog, "open", "closed"),
183+
class_name="fixed inset-0 z-50 overflow-y-auto bg-black bg-opacity-50 data-[state=open]:flex items-center justify-center p-2 sm:p-4 h-screen w-screen",
184+
)

0 commit comments

Comments
 (0)