diff --git a/packages/web/src/components/profilePage/profilePage.tsx b/packages/web/src/components/profilePage/profilePage.tsx index 5ac9fe5..1e849c3 100644 --- a/packages/web/src/components/profilePage/profilePage.tsx +++ b/packages/web/src/components/profilePage/profilePage.tsx @@ -15,7 +15,8 @@ import { LogoutSwitchThemeWrapper, LogoutSwitchButton, Description, - SubmitMessage + SubmitMessage, + Select } from "./style"; export const ProfilePage = () => { @@ -36,6 +37,7 @@ export const ProfilePage = () => { }); const [editDescription, setEditDescription] = useState(false); const [descriptionEditorValue, setDescriptionEditorValue] = useState(""); + const [changeFlagEditor, setchangeFlagEditor] = useState(false); const submitMessageRef = useRef(null); @@ -57,7 +59,6 @@ export const ProfilePage = () => { // eslint-disable-next-line @typescript-eslint/no-use-before-define getUserGames(userId); // eslint-disable-next-line @typescript-eslint/no-use-before-define - setDefaultDescriptionEditorValue(); }, [userData?.data?.country, userData?.data?.xp]); const updateCountryList = async () => { @@ -101,10 +102,6 @@ export const ProfilePage = () => { }); }; - const setDefaultDescriptionEditorValue = () => { - setDescriptionEditorValue(userData?.data?.description); - }; - const getUserPBS = async (id: string) => { const result = await ( await fetch(`${apiUrl}/users/userpbs/${id}`, { @@ -248,6 +245,49 @@ export const ProfilePage = () => { + {changeFlagEditor ? ( + + ) : ( + "" + )} + { + if (!changeFlagEditor) { + setchangeFlagEditor(true); + } else { + await ( + await fetch( + `${apiUrl}/users/updateCountry`, + { + method: "POST", + credentials: "include", + headers: { + "Content-Type": + "application/json" + }, + body: JSON.stringify({ + country: countryValue + }) + } + ) + ).text(); + updateCountryFlagUrl(); + updateUserData(); + setchangeFlagEditor(false); + } + }} + > + {changeFlagEditor + ? `Submit ${countryValue}` + : "Change Flag"} + { await fetch(`${apiUrl}/auth/logout`, { @@ -314,32 +354,6 @@ export const ProfilePage = () => { )} - -