-
Notifications
You must be signed in to change notification settings - Fork 0
refacout: account setttings #69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
48826c8
refacout: account setttings
LoiTang1710 d5f8af4
refacout: require login
LoiTang1710 77b65de
Update client/src/pages/Account/SecuritySettings.jsx
LoiTang1710 7a59f09
Update client/src/api/userApi.js
LoiTang1710 eeeeeb9
Update client/src/pages/Account/ProfilesManagement.jsx
LoiTang1710 433cbb6
Update server/src/controllers/user.controller.js
LoiTang1710 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| import { apiClient } from './axiosClient' | ||
|
|
||
| export const getUserProfileApi = () => | ||
| apiClient.get('/users/profile').then((res) => res.data.data) | ||
|
|
||
| export const updateUserProfileApi = (data) => { | ||
| const formData = new FormData() | ||
| if (data.fullName) formData.append('fullName', data.fullName) | ||
| if (data.phone) formData.append('phone', data.phone) | ||
| if (data.dateOfBirth) formData.append('dateOfBirth', data.dateOfBirth) | ||
| if (data.gender) formData.append('gender', data.gender) | ||
| if (data.avatar) formData.append('avatar', data.avatar) | ||
|
|
||
| return apiClient.put('/users/profile', formData, { | ||
| headers: { | ||
| 'Content-Type': 'multipart/form-data', | ||
| }, | ||
| }).then((res) => res.data.data) | ||
| } | ||
|
|
||
| export const changePasswordApi = (data) => | ||
| apiClient.post('/users/change-password', data).then((res) => res.data.data) | ||
|
|
||
| export const getSubscriptionHistoryApi = () => | ||
| apiClient.get('/users/subscription-history').then((res) => res.data.data) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| import { useState } from 'react' | ||
| import { User, Shield, CreditCard, Users } from 'lucide-react' | ||
| import PersonalInfo from './PersonalInfo' | ||
| import SecuritySettings from './SecuritySettings' | ||
| import SubscriptionHistory from './SubscriptionHistory' | ||
| import ProfilesManagement from './ProfilesManagement' | ||
|
|
||
| export default function AccountSettings() { | ||
| const [activeTab, setActiveTab] = useState('personal') | ||
|
|
||
| const tabs = [ | ||
| { id: 'personal', label: 'Thông tin cá nhân', icon: User }, | ||
| { id: 'security', label: 'Bảo mật', icon: Shield }, | ||
| { id: 'subscription', label: 'Gói dịch vụ', icon: CreditCard }, | ||
| { id: 'profiles', label: 'Hồ sơ xem chung', icon: Users }, | ||
| ] | ||
|
|
||
| const renderContent = () => { | ||
| switch (activeTab) { | ||
| case 'personal': | ||
| return <PersonalInfo /> | ||
| case 'security': | ||
| return <SecuritySettings /> | ||
| case 'subscription': | ||
| return <SubscriptionHistory /> | ||
| case 'profiles': | ||
| return <ProfilesManagement /> | ||
| default: | ||
| return <PersonalInfo /> | ||
| } | ||
| } | ||
|
|
||
| return ( | ||
| <div className="min-h-screen bg-bg-default text-slate-200 pt-7 pb-12 px-4 sm:px-6 lg:px-8"> | ||
| <div className="max-w-6xl mx-auto"> | ||
| <div className="mb-8"> | ||
| <h1 className="text-3xl font-bold text-white mb-2">Cài đặt tài khoản</h1> | ||
| <p className="text-slate-400">Quản lý thông tin, bảo mật và các gói dịch vụ của bạn</p> | ||
| </div> | ||
|
|
||
| <div className="flex flex-col lg:flex-row gap-8"> | ||
| {/* Sidebar Navigation */} | ||
| <div className="w-full lg:w-64 shrink-0"> | ||
| <nav className="flex lg:flex-col gap-2 overflow-x-auto lg:overflow-visible pb-4 lg:pb-0 hide-scrollbar"> | ||
| {tabs.map((tab) => { | ||
| const Icon = tab.icon | ||
| const isActive = activeTab === tab.id | ||
| return ( | ||
| <button | ||
| key={tab.id} | ||
| onClick={() => setActiveTab(tab.id)} | ||
| className={`flex items-center gap-3 px-4 py-3 rounded transition-all duration-200 whitespace-nowrap lg:whitespace-normal | ||
| ${isActive | ||
| ? 'bg-red-500/10 text-red-500 border border-red-500/20' | ||
| : 'text-slate-400 hover:bg-white/5 hover:text-slate-200 border border-transparent' | ||
| }`} | ||
| > | ||
| <Icon className={`w-5 h-5 ${isActive ? 'text-red-500' : 'text-slate-400'}`} /> | ||
| <span className="font-medium text-sm">{tab.label}</span> | ||
| </button> | ||
| ) | ||
| })} | ||
| </nav> | ||
| </div> | ||
|
|
||
| {/* Main Content Area */} | ||
| <div className="flex-1 min-w-0"> | ||
| {renderContent()} | ||
| </div> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| ) | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.