mirror of
https://github.com/rzmk/learnhouse.git
synced 2025-12-19 04:19:25 +00:00
feat: format with prettier
This commit is contained in:
parent
03fb09c3d6
commit
a147ad6610
164 changed files with 11257 additions and 8154 deletions
|
|
@ -1,23 +1,30 @@
|
|||
"use client"; //todo: use server components
|
||||
import Link from "next/link";
|
||||
import React from "react";
|
||||
import { deleteOrganizationFromBackend } from "@services/organizations/orgs";
|
||||
import useSWR, { mutate } from "swr";
|
||||
import { swrFetcher } from "@services/utils/ts/requests";
|
||||
import { getAPIUrl, getUriWithOrg } from "@services/config/config";
|
||||
'use client' //todo: use server components
|
||||
import Link from 'next/link'
|
||||
import React from 'react'
|
||||
import { deleteOrganizationFromBackend } from '@services/organizations/orgs'
|
||||
import useSWR, { mutate } from 'swr'
|
||||
import { swrFetcher } from '@services/utils/ts/requests'
|
||||
import { getAPIUrl, getUriWithOrg } from '@services/config/config'
|
||||
|
||||
const Organizations = () => {
|
||||
const { data: organizations, error } = useSWR(`${getAPIUrl()}orgs/user/page/1/limit/10`, swrFetcher)
|
||||
const { data: organizations, error } = useSWR(
|
||||
`${getAPIUrl()}orgs/user/page/1/limit/10`,
|
||||
swrFetcher
|
||||
)
|
||||
|
||||
async function deleteOrganization(org_id: any) {
|
||||
const response = await deleteOrganizationFromBackend(org_id);
|
||||
response && mutate(`${getAPIUrl()}orgs/user/page/1/limit/10`, organizations.filter((org: any) => org.org_id !== org_id));
|
||||
const response = await deleteOrganizationFromBackend(org_id)
|
||||
response &&
|
||||
mutate(
|
||||
`${getAPIUrl()}orgs/user/page/1/limit/10`,
|
||||
organizations.filter((org: any) => org.org_id !== org_id)
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="font-bold text-lg">
|
||||
Your Organizations{" "}
|
||||
Your Organizations{' '}
|
||||
<Link href="/organizations/new">
|
||||
<button className="bg-blue-500 text-white px-2 py-1 rounded-md hover:bg-blue-600 focus:outline-none">
|
||||
+
|
||||
|
|
@ -32,9 +39,14 @@ const Organizations = () => {
|
|||
) : (
|
||||
<div>
|
||||
{organizations.map((org: any) => (
|
||||
<div key={org.org_id} className="flex items-center justify-between mb-4">
|
||||
<Link href={getUriWithOrg(org.slug, "/")}>
|
||||
<h3 className="text-blue-500 cursor-pointer hover:underline">{org.name}</h3>
|
||||
<div
|
||||
key={org.org_id}
|
||||
className="flex items-center justify-between mb-4"
|
||||
>
|
||||
<Link href={getUriWithOrg(org.slug, '/')}>
|
||||
<h3 className="text-blue-500 cursor-pointer hover:underline">
|
||||
{org.name}
|
||||
</h3>
|
||||
</Link>
|
||||
<button
|
||||
onClick={() => deleteOrganization(org.org_id)}
|
||||
|
|
@ -46,9 +58,8 @@ const Organizations = () => {
|
|||
))}
|
||||
</div>
|
||||
)}
|
||||
|
||||
</>
|
||||
);
|
||||
};
|
||||
)
|
||||
}
|
||||
|
||||
export default Organizations;
|
||||
export default Organizations
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue