Skip to content

Commit c51334b

Browse files
chemonoworldRyz0nd
andauthored
BACG-341 (#69)
* backend, common: implement UpdateCustomerInfo * customer_dashboard: implement UpdateCustomerInfo(draft) * customer_dashboard: enhance logo upload functionality - Implement drag-and-drop support for logo uploads. - Add validation for image dimensions (128x128 px) and file size (under 1 MB). - Update error handling for unsupported file types (SVG not allowed). - Introduce a flag to mark logos for deletion. - Update API request to handle logo deletion and modifications accordingly. * customer_dashboard: update logo upload validation and enhance API handling - Refine file upload validation to restrict accepted formats to PNG, JPG, and WebP, excluding SVG and GIF. - Implement file size limit of 1MB and ensure only one file can be uploaded. - Enhance error handling for file upload issues, including specific messages for file type and size errors. - Update API to handle logo deletion and ensure logo images are processed to meet specified dimensions (128x128 px) before upload. - Add support for deleting logos via a new request parameter. * oko_sdk_cosmos: remove unnecessary options parameter * customer_dashboard: update logo styling in account info components - Resize logos to 40x40 pixels with rounded corners for better presentation. - Ensure consistent logo styling across account info and account info with submenu components. - Apply object-fit cover to maintain aspect ratio of logos. * customer_dashboard: refactor logo upload and validation in createCustomer - Update logo upload requirements to accept only PNG, JPG, JPEG, and WebP formats, excluding SVG and GIF. - Implement a file size limit of 1MB and ensure uploaded images are exactly 128x128 pixels. - Improve error handling for invalid file types and dimensions during logo upload. - Add validation for customer label to ensure it meets specified criteria before processing. * customer_dashboard: enhance drag-and-drop functionality for logo uploads - Add drag-and-drop support to the logo upload input, improving user experience. - Implement visual feedback during drag events with updated styles for the upload area. - Introduce state management for drag events to handle file uploads seamlessly. * customer_dashboard: add express-rate-limit middleware for customer update route - Introduce rate limiting to the customer update endpoint to prevent abuse. - Set a limit of 20 requests per 10 minutes with a custom error message for rate limit exceedance. - Update package.json and yarn.lock to include express-rate-limit dependency. * customer_dashboard: refactor authentication, file upload, and rate limiting middleware - Introduce customer JWT authentication middleware to validate Bearer tokens for secure access. - Implement Multer middleware for handling logo uploads with file size and type restrictions. - Add rate limiting middleware to control request frequency and prevent abuse on customer routes. - Update customer routes to utilize the new middleware for improved security and functionality. --------- Co-authored-by: devmosis <[email protected]>
1 parent 7a3f3e8 commit c51334b

File tree

40 files changed

+1509
-561
lines changed

40 files changed

+1509
-561
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,8 @@ $RECYCLE.BIN/
398398

399399
# Claude
400400
.claude/
401+
.plans/
402+
.tasks/
401403

402404
# vscode
403405
.vscode/
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
.wrapper {
2+
display: flex;
3+
justify-content: center;
4+
height: 100vh;
5+
flex-direction: column;
6+
}
7+
8+
.body {
9+
width: 411px;
10+
margin: 80px auto auto auto;
11+
}
12+
13+
.description {
14+
margin-bottom: 40px;
15+
}
16+
17+
.backButton {
18+
margin-left: -8px;
19+
margin-bottom: 24px;
20+
padding: 0;
21+
background: none;
22+
border: none;
23+
cursor: pointer;
24+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
"use client";
2+
3+
import React from "react";
4+
import { useRouter } from "next/navigation";
5+
import { Typography } from "@oko-wallet/oko-common-ui/typography";
6+
import { Spacing } from "@oko-wallet/oko-common-ui/spacing";
7+
import { ChevronLeftIcon } from "@oko-wallet/oko-common-ui/icons/chevron_left";
8+
9+
import { DashboardHeader } from "@oko-wallet-ct-dashboard/components/dashboard_header/dashboard_header";
10+
import { Authorized } from "@oko-wallet-ct-dashboard/components/authorized/authorized";
11+
import { EditInfoForm } from "@oko-wallet-ct-dashboard/components/edit_info_form/edit_info_form";
12+
import styles from "./page.module.scss";
13+
14+
export default function EditInfoPage() {
15+
const router = useRouter();
16+
17+
return (
18+
<Authorized>
19+
<div className={styles.wrapper}>
20+
<DashboardHeader />
21+
<div className={styles.body}>
22+
<button className={styles.backButton} onClick={() => router.back()}>
23+
<ChevronLeftIcon size={24} color="var(--fg-tertiary)" />
24+
</button>
25+
26+
<Typography
27+
tagType="h1"
28+
size="display-sm"
29+
weight="semibold"
30+
color="primary"
31+
>
32+
Edit App Information
33+
</Typography>
34+
<Spacing height={8} />
35+
36+
<Typography
37+
size="md"
38+
weight="regular"
39+
color="secondary"
40+
className={styles.description}
41+
>
42+
Update your app name and logo
43+
</Typography>
44+
45+
<EditInfoForm />
46+
</div>
47+
</div>
48+
</Authorized>
49+
);
50+
}

apps/customer_dashboard/src/components/account_info/account_info.module.scss

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,14 @@
88
.customerInfo {
99
display: flex;
1010
align-items: center;
11+
12+
// Resize logo to 40x40
13+
img {
14+
width: 40px;
15+
height: 40px;
16+
border-radius: 8px;
17+
object-fit: cover;
18+
}
1119
}
1220

1321
.fallbackImageText {
@@ -19,7 +27,7 @@
1927
justify-content: center;
2028
align-items: center;
2129

22-
border-radius: 999px;
30+
border-radius: 8px;
2331
border: 1px solid var(--gray-200);
2432
background: var(--bg-tertiary);
2533

@@ -42,4 +50,4 @@
4250
.externalLinkIcon {
4351
width: 16px;
4452
height: 16px;
45-
}
53+
}

apps/customer_dashboard/src/components/account_info_with_sub_menu/account_info_with_sub_menu.module.scss

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,20 @@
88
top: -1px;
99
left: -1px;
1010
cursor: default;
11+
12+
img {
13+
width: 40px !important;
14+
height: 40px !important;
15+
object-fit: cover;
16+
}
17+
}
18+
19+
.sidebarTrigger {
20+
img {
21+
width: 40px !important;
22+
height: 40px !important;
23+
object-fit: cover;
24+
}
1125
}
1226

1327
.iconWrapper {
@@ -22,4 +36,4 @@
2236
&:hover {
2337
background-color: var(--bg-primary-hover);
2438
}
25-
}
39+
}

apps/customer_dashboard/src/components/account_info_with_sub_menu/account_info_with_sub_menu.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export const AccountInfoWithSubMenu = () => {
2727
email={user?.email ?? ""}
2828
label={customer.data?.label ?? ""}
2929
logoImageUrl={customer.data?.logo_url ?? ""}
30+
className={styles.sidebarTrigger}
3031
TopRightIcon={
3132
<span className={styles.iconWrapper}>
3233
<ThreeDotsVerticalIcon color="var(--fg-quaternary)" size={16} />
@@ -43,6 +44,14 @@ export const AccountInfoWithSubMenu = () => {
4344
/>
4445
}
4546
menuItems={[
47+
{
48+
id: "edit-info",
49+
label: "Edit Info",
50+
icon: <EditIcon size={16} />,
51+
onClick: () => {
52+
router.push(paths.edit_info);
53+
},
54+
},
4655
{
4756
id: "change-password",
4857
label: "Change Password",
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
.form {
2+
display: flex;
3+
flex-direction: column;
4+
align-items: flex-start;
5+
gap: 32px;
6+
width: 100%;
7+
}
8+
9+
.input {
10+
width: 100%;
11+
}
12+
13+
.plusIcon {
14+
width: 20px;
15+
height: 20px;
16+
flex-shrink: 0;
17+
opacity: 0.5;
18+
}
19+
20+
.appLogoUploadWrapper {
21+
display: flex;
22+
flex-direction: column;
23+
justify-content: center;
24+
align-items: flex-start;
25+
gap: 16px;
26+
align-self: stretch;
27+
}
28+
29+
.appLogoUploadDescription {
30+
color: var(--text-primary);
31+
font-size: 14px;
32+
font-style: normal;
33+
font-weight: 500;
34+
line-height: 20px;
35+
}
36+
37+
.appLogoUploadLabel {
38+
display: flex;
39+
align-items: flex-start;
40+
gap: 2px;
41+
}
42+
43+
.appLogoUploadLabelText {
44+
color: var(--text-secondary);
45+
font-size: 14px;
46+
font-style: normal;
47+
font-weight: 500;
48+
line-height: 20px;
49+
}
50+
51+
.appLogoUploadInput {
52+
display: flex;
53+
width: 85px;
54+
height: 85px;
55+
justify-content: center;
56+
align-items: center;
57+
border-radius: 12px;
58+
border: 1px solid #eaecf0;
59+
cursor: pointer;
60+
transition: all 0.2s ease;
61+
position: relative;
62+
overflow: hidden;
63+
64+
&:hover {
65+
border-color: #d0d5dd;
66+
}
67+
68+
&.dragging {
69+
border-color: #7f56d9;
70+
border-width: 2px;
71+
background-color: rgba(127, 86, 217, 0.05);
72+
}
73+
}
74+
75+
.logoPreview {
76+
position: relative;
77+
width: 100%;
78+
height: 100%;
79+
display: flex;
80+
align-items: center;
81+
justify-content: center;
82+
}
83+
84+
.logoPreviewImage {
85+
width: 100%;
86+
height: 100%;
87+
object-fit: cover;
88+
border-radius: 12px;
89+
}
90+
91+
.removeButton {
92+
position: absolute;
93+
padding: 4px;
94+
top: 0px;
95+
right: 0px;
96+
border-radius: 0px 12px 0px 0px;
97+
background: rgba(0, 0, 0, 0.5);
98+
border: none;
99+
color: white;
100+
display: flex;
101+
align-items: center;
102+
justify-content: center;
103+
cursor: pointer;
104+
transition: background-color 0.2s ease;
105+
106+
&:hover {
107+
background-color: rgba(0, 0, 0, 0.8);
108+
}
109+
}
110+
111+
.xCloseIcon {
112+
width: 16px;
113+
height: 16px;
114+
}
115+
116+
.error {
117+
color: var(--text-error, #d92d20);
118+
font-size: 14px;
119+
font-weight: 500;
120+
line-height: 20px;
121+
}
122+
123+
.submitButton {
124+
width: 100%;
125+
margin-top: 8px;
126+
}

0 commit comments

Comments
 (0)