+
©{" "}
- {site?.username}
+ {site?.name}
{" "}
ยท Powered by{" "}
+ {site?.connected_accounts && (
+
+ {site?.connected_accounts.map((account, index) => (
+
+ ))}
+
+ )}
{site?.ga && (
diff --git a/src/components/ui/Tooltip.tsx b/src/components/ui/Tooltip.tsx
index 1891743f..c36fa9f8 100644
--- a/src/components/ui/Tooltip.tsx
+++ b/src/components/ui/Tooltip.tsx
@@ -13,14 +13,21 @@ import {
useDismiss,
useTransitionStyles,
} from "@floating-ui/react"
+import clsx from "clsx"
interface Props {
label: string
placement?: Placement
children: JSX.Element
+ className?: string
}
-export const Tooltip = ({ children, label, placement = "top" }: Props) => {
+export const Tooltip = ({
+ children,
+ label,
+ placement = "top",
+ className,
+}: Props) => {
const [open, setOpen] = useState(false)
const { x, y, refs, strategy, context } = useFloating({
@@ -54,7 +61,10 @@ export const Tooltip = ({ children, label, placement = "top" }: Props) => {
{isMounted && (
["connected_accounts"][number] & {
+ id: string
+}
+
+type UpdateItem = (id: string, newItem: Partial
- ) => void
+
+type RemoveItem = (id: string) => void
+
+const SortableNavigationItem: React.FC<{
+ item: Item
+ updateItem: UpdateItem
+ removeItem: RemoveItem
+}> = ({ item, updateItem, removeItem }) => {
+ return (
+
+
+
) =>
+ updateItem(item.id, { platform: e.target.value })
+ }
+ />
+
) =>
+ updateItem(item.id, { identity: e.target.value })
+ }
+ />
+
+
+
+
+
+ )
+}
+
+export default function SiteSettingsNavigationPage() {
+ const router = useRouter()
+
+ const subdomain = router.query.subdomain as string
+
+ const updateSite = useUpdateSite()
+ const site = useGetSite(subdomain)
+
+ const [items, setItems] = useState- ([])
+
+ const itemsModified = useMemo(() => {
+ if (!site.isSuccess) return false
+ return !equal(items, site.data?.connected_accounts)
+ }, [items, site.data, site.isSuccess])
+
+ const updateItem: UpdateItem = (id, newItem) => {
+ setItems((items) => {
+ return items.map((item) => {
+ if (item.id === id) {
+ return { ...item, ...newItem }
+ }
+ return item
+ })
+ })
+ }
+
+ const newEmptyItem = () => {
+ setItems((items) => [
+ ...items,
+ { id: nanoid(), platform: "", identity: "" },
+ ])
+ }
+
+ const handleSubmit = (e: FormEvent) => {
+ e.preventDefault()
+ updateSite.mutate({
+ site: site.data?.username!,
+ connected_accounts: items.map(({ id, ...item }) => item),
+ })
+ }
+
+ useEffect(() => {
+ if (updateSite.isSuccess) {
+ if (updateSite.data?.code === 0) {
+ toast.success("Saved")
+ } else {
+ toast.error("Failed to save" + ": " + updateSite.data.message)
+ }
+ } else if (updateSite.isError) {
+ toast.error("Failed to save")
+ }
+ }, [updateSite.isSuccess, updateSite.isError])
+
+ const removeItem: RemoveItem = (id) => {
+ setItems((items) => items.filter((item) => item.id !== id))
+ }
+
+ const [hasSet, setHasSet] = useState(false)
+ useEffect(() => {
+ if (site.data?.connected_accounts && !hasSet) {
+ setHasSet(true)
+ setItems(
+ site.data?.connected_accounts.map((item) => ({
+ id: nanoid(),
+ ...item,
+ })),
+ )
+ }
+ }, [site.data?.connected_accounts, hasSet])
+
+ return (
+
+
+
Tips:
+
+
+ These social platforms will be displayed in the bottom right hand
+ corner of your xLog.
+
+
+
+
+ You can also connect to Twitter, Telegram Channel, Medium, Substack
+ and more and automatically sync content on{" "}
+
+ xSync
+
+ . When you have set up the sync there, it will also show here.
+
+
+
+
+
+ )
+}
+
+SiteSettingsNavigationPage.getLayout = (page: ReactElement) => {
+ return {page}
+}