From 088628aeab8e14273a4f4cbda2c9069231413084 Mon Sep 17 00:00:00 2001 From: Dat Hoang Date: Mon, 23 Oct 2023 20:43:40 +0700 Subject: [PATCH 1/2] added "REAL" display name --- app/(basic)/users/[id]/page.tsx | 1064 ++++++++++++++++--------------- 1 file changed, 543 insertions(+), 521 deletions(-) diff --git a/app/(basic)/users/[id]/page.tsx b/app/(basic)/users/[id]/page.tsx index c53478b..5b174fe 100644 --- a/app/(basic)/users/[id]/page.tsx +++ b/app/(basic)/users/[id]/page.tsx @@ -1,548 +1,570 @@ -"use client" +'use client' -import StatCard from "@/components/leaderboard/personal-achievements/StatCard" -import PlayerInformation from "@/components/player/PlayerInformation" -import Button from "@/components/ui/Button" -import IconButton from "@/components/ui/IconButton" -import Image from "next/image" -import Link from "next/link" -import React from "react" +import StatCard from '@/components/leaderboard/personal-achievements/StatCard' +import PlayerInformation from '@/components/player/PlayerInformation' +import Button from '@/components/ui/Button' +import IconButton from '@/components/ui/IconButton' +import useCheckAuthorization from '@/features/user/useCheckAuthorization' +import Image from 'next/image' +import Link from 'next/link' +import React from 'react' function UserInfo() { - return ( - // TODO: Còn Hard Code dữ liệu! -
-
-
-
-
-
- -
- - - -
-
+ const { data: user } = useCheckAuthorization() -
- - - -
-
-
+ return ( + // TODO: Còn Hard Code dữ liệu! +
+
+
+
+
+
+ +
+ + + +
+
-
-
-
-
-
Chọn Quốc Gia
- -
+
+ + + +
+
+
-
-
- Chọn Ảnh Đại Diện -
-
- - - - - - - -
-
+
+
+
+
+
+ Chọn Quốc Gia +
+ +
+ +
+
+ Chọn Ảnh Đại Diện +
+
+
+ avatar1 +
+
+ avatar2 +
+
+ avatar3 +
+
+ avatar4 +
+
+ avatar5 +
+
+ avatar6 +
+ +
+
-
- +
+ +
+
+
+
-
-
-
-
-
-
-
-
Bạn Bè
- + + +
+ +
+ {players.map((p) => ( + + ))} +
-
- {/* closes when clicked outside */} -
- -
- -
- -
- {players.map((p) => ( - - ))}
-
-
-
- ) + ) } interface PlayerData { - username: string - avatarSrc: string - flagSrc: string - status: "Rảnh tay" | "Đang chơi" | "Ngoại tuyến" - score: number + username: string + avatarSrc: string + flagSrc: string + status: 'Rảnh tay' | 'Đang chơi' | 'Ngoại tuyến' + score: number } const players: PlayerData[] = [ - { - username: "Player 1", - avatarSrc: "/assets/avatars/avatar1.png", - flagSrc: "/assets/flags/VN.svg", - status: "Ngoại tuyến", - score: 140, - }, - { - username: "Player 2", - avatarSrc: "/assets/avatars/avatar2.png", - flagSrc: "/assets/flags/BO.svg", - status: "Đang chơi", - score: 130, - }, - { - username: "Player 3", - avatarSrc: "/assets/avatars/avatar3.png", - flagSrc: "/assets/flags/AC.svg", - status: "Rảnh tay", - score: 242, - }, - { - username: "Player 4", - avatarSrc: "/assets/avatars/avatar4.png", - flagSrc: "/assets/flags/VN.svg", - status: "Đang chơi", - score: 45, - }, - { - username: "Player 5", - avatarSrc: "/assets/avatars/avatar5.png", - flagSrc: "/assets/flags/AZ.svg", - status: "Đang chơi", - score: 1314, - }, - { - username: "Player 6", - avatarSrc: "/assets/avatars/avatar6.png", - flagSrc: "/assets/flags/VN.svg", - status: "Ngoại tuyến", - score: 4564, - }, - { - username: "Player 7", - avatarSrc: "/assets/avatars/avatar6.png", - flagSrc: "/assets/flags/VN.svg", - status: "Rảnh tay", - score: 884, - }, + { + username: 'Player 1', + avatarSrc: '/assets/avatars/avatar1.png', + flagSrc: '/assets/flags/VN.svg', + status: 'Ngoại tuyến', + score: 140, + }, + { + username: 'Player 2', + avatarSrc: '/assets/avatars/avatar2.png', + flagSrc: '/assets/flags/BO.svg', + status: 'Đang chơi', + score: 130, + }, + { + username: 'Player 3', + avatarSrc: '/assets/avatars/avatar3.png', + flagSrc: '/assets/flags/AC.svg', + status: 'Rảnh tay', + score: 242, + }, + { + username: 'Player 4', + avatarSrc: '/assets/avatars/avatar4.png', + flagSrc: '/assets/flags/VN.svg', + status: 'Đang chơi', + score: 45, + }, + { + username: 'Player 5', + avatarSrc: '/assets/avatars/avatar5.png', + flagSrc: '/assets/flags/AZ.svg', + status: 'Đang chơi', + score: 1314, + }, + { + username: 'Player 6', + avatarSrc: '/assets/avatars/avatar6.png', + flagSrc: '/assets/flags/VN.svg', + status: 'Ngoại tuyến', + score: 4564, + }, + { + username: 'Player 7', + avatarSrc: '/assets/avatars/avatar6.png', + flagSrc: '/assets/flags/VN.svg', + status: 'Rảnh tay', + score: 884, + }, ] // TODO: Sẽ cập nhật thành object chứa value & icon const flags = [ - "Afghanistan", - "Åland Islands", - "Albania", - "Algeria", - "American Samoa", - "Andorra", - "Angola", - "Anguilla", - "Antarctica", - "Antigua and Barbuda", - "Argentina", - "Armenia", - "Aruba", - "Australia", - "Austria", - "Azerbaijan", - "Bahamas", - "Bahrain", - "Bangladesh", - "Barbados", - "Belarus", - "Belgium", - "Belize", - "Benin", - "Bermuda", - "Bhutan", - "Bolivia (Plurinational State of)", - "Bonaire, Sint Eustatius and Saba", - "Bosnia and Herzegovina", - "Botswana", - "Bouvet Island", - "Brazil", - "British Indian Ocean Territory", - "Brunei Darussalam", - "Bulgaria", - "Burkina Faso", - "Burundi", - "Cabo Verde", - "Cambodia", - "Cameroon", - "Canada", - "Cayman Islands", - "Central African Republic", - "Chad", - "Chile", - "China", - "Christmas Island", - "Cocos (Keeling) Islands", - "Colombia", - "Comoros", - "Congo", - "Congo, Democratic Republic of the", - "Cook Islands", - "Costa Rica", - "Côte d'Ivoire", - "Croatia", - "Cuba", - "Curaçao", - "Cyprus", - "Czechia", - "Denmark", - "Djibouti", - "Dominica", - "Dominican Republic", - "Ecuador", - "Egypt", - "El Salvador", - "Equatorial Guinea", - "Eritrea", - "Estonia", - "Eswatini", - "Ethiopia", - "Falkland Islands (Malvinas)", - "Faroe Islands", - "Fiji", - "Finland", - "France", - "French Guiana", - "French Polynesia", - "French Southern Territories", - "Gabon", - "Gambia", - "Georgia", - "Germany", - "Ghana", - "Gibraltar", - "Greece", - "Greenland", - "Grenada", - "Guadeloupe", - "Guam", - "Guatemala", - "Guernsey", - "Guinea", - "Guinea-Bissau", - "Guyana", - "Haiti", - "Heard Island and McDonald Islands", - "Holy See", - "Honduras", - "Hong Kong", - "Hungary", - "Iceland", - "India", - "Indonesia", - "Iran (Islamic Republic of)", - "Iraq", - "Ireland", - "Isle of Man", - "Israel", - "Italy", - "Jamaica", - "Japan", - "Jersey", - "Jordan", - "Kazakhstan", - "Kenya", - "Kiribati", - "Korea (Democratic People's Republic of)", - "Korea, Republic of", - "Kuwait", - "Kyrgyzstan", - "Lao People's Democratic Republic", - "Latvia", - "Lebanon", - "Lesotho", - "Liberia", - "Libya", - "Liechtenstein", - "Lithuania", - "Luxembourg", - "Macao", - "Madagascar", - "Malawi", - "Malaysia", - "Maldives", - "Mali", - "Malta", - "Marshall Islands", - "Martinique", - "Mauritania", - "Mauritius", - "Mayotte", - "Mexico", - "Micronesia (Federated States of)", - "Moldova, Republic of", - "Monaco", - "Mongolia", - "Montenegro", - "Montserrat", - "Morocco", - "Mozambique", - "Myanmar", - "Namibia", - "Nauru", - "Nepal", - "Netherlands, Kingdom of the", - "New Caledonia", - "New Zealand", - "Nicaragua", - "Niger", - "Nigeria", - "Niue", - "Norfolk Island", - "North Macedonia", - "Northern Mariana Islands", - "Norway", - "Oman", - "Pakistan", - "Palau", - "Palestine, State of", - "Panama", - "Papua New Guinea", - "Paraguay", - "Peru", - "Philippines", - "Pitcairn", - "Poland", - "Portugal", - "Puerto Rico", - "Qatar", - "Réunion", - "Romania", - "Russian Federation", - "Rwanda", - "Saint Barthélemy", - "Saint Helena, Ascension and Tristan da Cunha", - "Saint Kitts and Nevis", - "Saint Lucia", - "Saint Martin (French part)", - "Saint Pierre and Miquelon", - "Saint Vincent and the Grenadines", - "Samoa", - "San Marino", - "Sao Tome and Principe", - "Saudi Arabia", - "Senegal", - "Serbia", - "Seychelles", - "Sierra Leone", - "Singapore", - "Sint Maarten (Dutch part)", - "Slovakia", - "Slovenia", - "Solomon Islands", - "Somalia", - "South Africa", - "South Georgia and the South Sandwich Islands", - "South Sudan", - "Spain", - "Sri Lanka", - "Sudan", - "Suriname", - "Svalbard and Jan Mayen", - "Sweden", - "Switzerland", - "Syrian Arab Republic", - "Taiwan, Province of China", - "Tajikistan", - "Tanzania, United Republic of", - "Thailand", - "Timor-Leste", - "Togo", - "Tokelau", - "Tonga", - "Trinidad and Tobago", - "Tunisia", - "Türkiye", - "Turkmenistan", - "Turks and Caicos Islands", - "Tuvalu", - "Uganda", - "Ukraine", - "United Arab Emirates", - "United Kingdom of Great Britain and Northern Ireland", - "United States of America", - "United States Minor Outlying Islands", - "Uruguay", - "Uzbekistan", - "Vanuatu", - "Venezuela (Bolivarian Republic of)", - "Viet Nam", - "Virgin Islands (British)", - "Virgin Islands (U.S.)", - "Wallis and Futuna", - "Western Sahara", - "Yemen", - "Zambia", - "Zimbabwe", + 'Afghanistan', + 'Åland Islands', + 'Albania', + 'Algeria', + 'American Samoa', + 'Andorra', + 'Angola', + 'Anguilla', + 'Antarctica', + 'Antigua and Barbuda', + 'Argentina', + 'Armenia', + 'Aruba', + 'Australia', + 'Austria', + 'Azerbaijan', + 'Bahamas', + 'Bahrain', + 'Bangladesh', + 'Barbados', + 'Belarus', + 'Belgium', + 'Belize', + 'Benin', + 'Bermuda', + 'Bhutan', + 'Bolivia (Plurinational State of)', + 'Bonaire, Sint Eustatius and Saba', + 'Bosnia and Herzegovina', + 'Botswana', + 'Bouvet Island', + 'Brazil', + 'British Indian Ocean Territory', + 'Brunei Darussalam', + 'Bulgaria', + 'Burkina Faso', + 'Burundi', + 'Cabo Verde', + 'Cambodia', + 'Cameroon', + 'Canada', + 'Cayman Islands', + 'Central African Republic', + 'Chad', + 'Chile', + 'China', + 'Christmas Island', + 'Cocos (Keeling) Islands', + 'Colombia', + 'Comoros', + 'Congo', + 'Congo, Democratic Republic of the', + 'Cook Islands', + 'Costa Rica', + "Côte d'Ivoire", + 'Croatia', + 'Cuba', + 'Curaçao', + 'Cyprus', + 'Czechia', + 'Denmark', + 'Djibouti', + 'Dominica', + 'Dominican Republic', + 'Ecuador', + 'Egypt', + 'El Salvador', + 'Equatorial Guinea', + 'Eritrea', + 'Estonia', + 'Eswatini', + 'Ethiopia', + 'Falkland Islands (Malvinas)', + 'Faroe Islands', + 'Fiji', + 'Finland', + 'France', + 'French Guiana', + 'French Polynesia', + 'French Southern Territories', + 'Gabon', + 'Gambia', + 'Georgia', + 'Germany', + 'Ghana', + 'Gibraltar', + 'Greece', + 'Greenland', + 'Grenada', + 'Guadeloupe', + 'Guam', + 'Guatemala', + 'Guernsey', + 'Guinea', + 'Guinea-Bissau', + 'Guyana', + 'Haiti', + 'Heard Island and McDonald Islands', + 'Holy See', + 'Honduras', + 'Hong Kong', + 'Hungary', + 'Iceland', + 'India', + 'Indonesia', + 'Iran (Islamic Republic of)', + 'Iraq', + 'Ireland', + 'Isle of Man', + 'Israel', + 'Italy', + 'Jamaica', + 'Japan', + 'Jersey', + 'Jordan', + 'Kazakhstan', + 'Kenya', + 'Kiribati', + "Korea (Democratic People's Republic of)", + 'Korea, Republic of', + 'Kuwait', + 'Kyrgyzstan', + "Lao People's Democratic Republic", + 'Latvia', + 'Lebanon', + 'Lesotho', + 'Liberia', + 'Libya', + 'Liechtenstein', + 'Lithuania', + 'Luxembourg', + 'Macao', + 'Madagascar', + 'Malawi', + 'Malaysia', + 'Maldives', + 'Mali', + 'Malta', + 'Marshall Islands', + 'Martinique', + 'Mauritania', + 'Mauritius', + 'Mayotte', + 'Mexico', + 'Micronesia (Federated States of)', + 'Moldova, Republic of', + 'Monaco', + 'Mongolia', + 'Montenegro', + 'Montserrat', + 'Morocco', + 'Mozambique', + 'Myanmar', + 'Namibia', + 'Nauru', + 'Nepal', + 'Netherlands, Kingdom of the', + 'New Caledonia', + 'New Zealand', + 'Nicaragua', + 'Niger', + 'Nigeria', + 'Niue', + 'Norfolk Island', + 'North Macedonia', + 'Northern Mariana Islands', + 'Norway', + 'Oman', + 'Pakistan', + 'Palau', + 'Palestine, State of', + 'Panama', + 'Papua New Guinea', + 'Paraguay', + 'Peru', + 'Philippines', + 'Pitcairn', + 'Poland', + 'Portugal', + 'Puerto Rico', + 'Qatar', + 'Réunion', + 'Romania', + 'Russian Federation', + 'Rwanda', + 'Saint Barthélemy', + 'Saint Helena, Ascension and Tristan da Cunha', + 'Saint Kitts and Nevis', + 'Saint Lucia', + 'Saint Martin (French part)', + 'Saint Pierre and Miquelon', + 'Saint Vincent and the Grenadines', + 'Samoa', + 'San Marino', + 'Sao Tome and Principe', + 'Saudi Arabia', + 'Senegal', + 'Serbia', + 'Seychelles', + 'Sierra Leone', + 'Singapore', + 'Sint Maarten (Dutch part)', + 'Slovakia', + 'Slovenia', + 'Solomon Islands', + 'Somalia', + 'South Africa', + 'South Georgia and the South Sandwich Islands', + 'South Sudan', + 'Spain', + 'Sri Lanka', + 'Sudan', + 'Suriname', + 'Svalbard and Jan Mayen', + 'Sweden', + 'Switzerland', + 'Syrian Arab Republic', + 'Taiwan, Province of China', + 'Tajikistan', + 'Tanzania, United Republic of', + 'Thailand', + 'Timor-Leste', + 'Togo', + 'Tokelau', + 'Tonga', + 'Trinidad and Tobago', + 'Tunisia', + 'Türkiye', + 'Turkmenistan', + 'Turks and Caicos Islands', + 'Tuvalu', + 'Uganda', + 'Ukraine', + 'United Arab Emirates', + 'United Kingdom of Great Britain and Northern Ireland', + 'United States of America', + 'United States Minor Outlying Islands', + 'Uruguay', + 'Uzbekistan', + 'Vanuatu', + 'Venezuela (Bolivarian Republic of)', + 'Viet Nam', + 'Virgin Islands (British)', + 'Virgin Islands (U.S.)', + 'Wallis and Futuna', + 'Western Sahara', + 'Yemen', + 'Zambia', + 'Zimbabwe', ] export default UserInfo From 7948408bd4a9deb1fed26e1d1f4a7816898262a0 Mon Sep 17 00:00:00 2001 From: Dat Hoang Date: Mon, 23 Oct 2023 20:50:25 +0700 Subject: [PATCH 2/2] updated relevances --- app/(basic)/settings/account/page.tsx | 2 - .../account/forms/ChangePasswordForm.tsx | 2 - components/account/forms/UpdateEmailForm.tsx | 139 +++++++++-------- .../account/forms/UpdateUsernameForm.tsx | 141 +++++++++--------- 4 files changed, 136 insertions(+), 148 deletions(-) diff --git a/app/(basic)/settings/account/page.tsx b/app/(basic)/settings/account/page.tsx index 1a6f81d..ce2f7df 100644 --- a/app/(basic)/settings/account/page.tsx +++ b/app/(basic)/settings/account/page.tsx @@ -1,5 +1,3 @@ -"use client" - import React from "react" import Title from "@/components/ui/Title" diff --git a/components/account/forms/ChangePasswordForm.tsx b/components/account/forms/ChangePasswordForm.tsx index 0ca83e2..624b582 100644 --- a/components/account/forms/ChangePasswordForm.tsx +++ b/components/account/forms/ChangePasswordForm.tsx @@ -1,5 +1,3 @@ -"use client" - import React from "react" const ChangePasswordForm: React.FC = () => { diff --git a/components/account/forms/UpdateEmailForm.tsx b/components/account/forms/UpdateEmailForm.tsx index 49bf6a5..7975323 100644 --- a/components/account/forms/UpdateEmailForm.tsx +++ b/components/account/forms/UpdateEmailForm.tsx @@ -1,78 +1,75 @@ -"use client" +'use client' -import React from "react" -import IconButton from "@/components/ui/IconButton" - -interface PlayerData { - username: string - email: string -} - -const sampleData: PlayerData = { - username: "Owlvernyte", - email: "owlvernyte@gmail.com", -} +import React from 'react' +import IconButton from '@/components/ui/IconButton' +import useCheckAuthorization from '@/features/user/useCheckAuthorization' const UpdateEmailForm: React.FC = () => { - return ( -
-
- Email -
-
-
- {sampleData.email} -
- (window as any).modal_update_email.showModal()} - buttonVariants="btn-neutral" - buttonSize="btn-lg" - /> - -
-
- -

Thay đổi Email

-
- - -
- + const { data: user } = useCheckAuthorization() + + return ( +
+
+ Email +
+
+
+ {user?.email ?? 'Trống'}
-
- -
- {/* closes when clicked outside */} -
- -
-
-
-
- ) + + (window as any).modal_update_email.showModal() + } + buttonVariants="btn-neutral" + buttonSize="btn-lg" + /> + +
+
+ +

+ Thay đổi Email +

+
+ + +
+ +
+
+ +
+ {/* closes when clicked outside */} +
+ +
+
+ + + ) } export default UpdateEmailForm diff --git a/components/account/forms/UpdateUsernameForm.tsx b/components/account/forms/UpdateUsernameForm.tsx index e1e9d3c..5b31530 100644 --- a/components/account/forms/UpdateUsernameForm.tsx +++ b/components/account/forms/UpdateUsernameForm.tsx @@ -1,80 +1,75 @@ -"use client" +'use client' -import React from "react" -import IconButton from "@/components/ui/IconButton" - -interface PlayerData { - username: string - email: string -} - -const sampleData: PlayerData = { - username: "Owlvernyte", - email: "owlvernyte@gmail.com", -} +import React from 'react' +import IconButton from '@/components/ui/IconButton' +import useCheckAuthorization from '@/features/user/useCheckAuthorization' const UpdateUsernameForm: React.FC = () => { - return ( -
-
- Tên Người Dùng -
-
-
- {sampleData.username} -
- (window as any).modal_update_username.showModal()} - buttonVariants="btn-neutral" - buttonSize="btn-lg" - /> - -
-
- -

- Thay đổi Tên Người Dùng -

-
- - -
- + const { data: user } = useCheckAuthorization() + + return ( +
+
+ Tên Người Dùng +
+
+
+ {user?.userName ?? 'Trống'}
-
- -
- {/* closes when clicked outside */} -
- -
-
-
-
- ) + + (window as any).modal_update_username.showModal() + } + buttonVariants="btn-neutral" + buttonSize="btn-lg" + /> + +
+
+ +

+ Thay đổi Tên Người Dùng +

+
+ + +
+ +
+
+ +
+ {/* closes when clicked outside */} +
+ +
+
+ + + ) } export default UpdateUsernameForm