From 61eb728442355888057c26dc5c0e8da8bbe503c2 Mon Sep 17 00:00:00 2001 From: Kentai Radiquum Date: Fri, 20 Sep 2024 14:27:09 +0500 Subject: [PATCH] feat: add social editing --- app/api/config.ts | 16 +- app/components/Profile/Profile.EditModal.tsx | 16 +- .../Profile/Profile.EditPrivacyModal.tsx | 9 +- .../Profile/Profile.EditSocialModal.tsx | 206 ++++++++++++++++++ .../Profile/Profile.EditStatusModal.tsx | 2 +- 5 files changed, 237 insertions(+), 12 deletions(-) create mode 100644 app/components/Profile/Profile.EditSocialModal.tsx diff --git a/app/api/config.ts b/app/api/config.ts index e4036f3..4457a65 100644 --- a/app/api/config.ts +++ b/app/api/config.ts @@ -23,11 +23,17 @@ export const ENDPOINTS = { history: `${API_PREFIX}/profile/login/history/all`, // // change: `${API_PREFIX}/profile/preference/login/change`, // ?login= }, - statusEdit: `${API_PREFIX}/profile/preference/status/edit`, - statsEdit: `${API_PREFIX}/profile/preference/privacy/stats/edit`, - countsEdit: `${API_PREFIX}/profile/preference/privacy/counts/edit`, - socialEdit: `${API_PREFIX}/profile/preference/privacy/social/edit`, - friendRequestsEdit: `${API_PREFIX}/profile/preference/privacy/friendRequests/edit`, + status: `${API_PREFIX}/profile/preference/status/edit`, + privacy: { + stats: `${API_PREFIX}/profile/preference/privacy/stats/edit`, + counts: `${API_PREFIX}/profile/preference/privacy/counts/edit`, + socials: `${API_PREFIX}/profile/preference/privacy/social/edit`, + friendRequests: `${API_PREFIX}/profile/preference/privacy/friendRequests/edit`, + }, + socials: { + info: `${API_PREFIX}/profile/preference/social`, + edit: `${API_PREFIX}/profile/preference/social/edit`, + }, } }, filter: `${API_PREFIX}/filter`, diff --git a/app/components/Profile/Profile.EditModal.tsx b/app/components/Profile/Profile.EditModal.tsx index e889e85..ffee2c8 100644 --- a/app/components/Profile/Profile.EditModal.tsx +++ b/app/components/Profile/Profile.EditModal.tsx @@ -5,9 +5,10 @@ import { Spinner } from "../Spinner/Spinner"; import useSWR from "swr"; import { ENDPOINTS } from "#/api/config"; import { useEffect, useState } from "react"; +import { unixToDate } from "#/api/utils"; import { ProfileEditPrivacyModal } from "./Profile.EditPrivacyModal"; import { ProfileEditStatusModal } from "./Profile.EditStatusModal"; -import { unixToDate } from "#/api/utils"; +import { ProfileEditSocialModal } from "./Profile.EditSocialModal"; const fetcher = async (url: string) => { const res = await fetch(url); @@ -30,6 +31,7 @@ export const ProfileEditModal = (props: { }) => { const [privacyModalOpen, setPrivacyModalOpen] = useState(false); const [statusModalOpen, setStatusModalOpen] = useState(false); + const [socialModalOpen, setSocialModalOpen] = useState(false); const [privacyModalSetting, setPrivacyModalSetting] = useState("none"); const [privacySettings, setPrivacySettings] = useState({ privacy_stats: 9, @@ -152,7 +154,12 @@ export const ProfileEditModal = (props: { : login}

- + + + + ); +}; diff --git a/app/components/Profile/Profile.EditStatusModal.tsx b/app/components/Profile/Profile.EditStatusModal.tsx index c6ee1c0..df60589 100644 --- a/app/components/Profile/Profile.EditStatusModal.tsx +++ b/app/components/Profile/Profile.EditStatusModal.tsx @@ -27,7 +27,7 @@ export const ProfileEditStatusModal = (props: { function _setStatusSetting() { setLoading(true); - fetch(`${ENDPOINTS.user.settings.statusEdit}?token=${props.token}`, { + fetch(`${ENDPOINTS.user.settings.status}?token=${props.token}`, { method: "POST", headers: { "Content-Type": "application/json",