|
| 1 | +<script lang="ts"> |
| 2 | + import { api, type Id } from "@packages/convex"; |
| 3 | + import { useQuery } from "convex-svelte"; |
| 4 | + import { goto } from "$app/navigation"; |
| 5 | + import Channel from "../channels/Channel.svelte"; |
| 6 | + import ChannelList from "../channels/ChannelList.svelte"; |
| 7 | +
|
| 8 | + interface Props { |
| 9 | + organizationId: Id<"organizations">; |
| 10 | + channelId?: Id<"channels">; |
| 11 | + } |
| 12 | +
|
| 13 | + const { organizationId, channelId }: Props = $props(); |
| 14 | +
|
| 15 | + const organization = useQuery(api.organizations.get, () => ({ |
| 16 | + id: organizationId, |
| 17 | + })); |
| 18 | +</script> |
| 19 | + |
| 20 | +<div class="bg-base-100 flex h-screen"> |
| 21 | + <div class="bg-base-200 border-base-300 w-80 border-r"> |
| 22 | + <div class="border-base-300 border-b p-4"> |
| 23 | + <div class="flex items-center justify-between"> |
| 24 | + <div> |
| 25 | + <h2 class="text-base-content text-lg font-bold"> |
| 26 | + {organization.data?.name || "組織"} |
| 27 | + </h2> |
| 28 | + {#if organization.data?.description} |
| 29 | + <p class="text-base-content/70 text-sm"> |
| 30 | + {organization.data.description} |
| 31 | + </p> |
| 32 | + {/if} |
| 33 | + </div> |
| 34 | + <div class="dropdown dropdown-end"> |
| 35 | + <div |
| 36 | + tabindex="0" |
| 37 | + role="button" |
| 38 | + class="btn btn-ghost btn-sm btn-circle" |
| 39 | + > |
| 40 | + <svg |
| 41 | + xmlns="http://www.w3.org/2000/svg" |
| 42 | + fill="none" |
| 43 | + viewBox="0 0 24 24" |
| 44 | + class="inline-block h-4 w-4 stroke-current" |
| 45 | + > |
| 46 | + <path |
| 47 | + stroke-linecap="round" |
| 48 | + stroke-linejoin="round" |
| 49 | + stroke-width="2" |
| 50 | + d="M12 6V4m0 2a2 2 0 100 4m0-4a2 2 0 110 4m-6 8a2 2 0 100-4m0 4a2 2 0 100 4m0-4v2m0-6V4m6 6v10m6-2a2 2 0 100-4m0 4a2 2 0 100 4m0-4v2m0-6V4" |
| 51 | + ></path> |
| 52 | + </svg> |
| 53 | + </div> |
| 54 | + <ul |
| 55 | + role="menu" |
| 56 | + tabindex="0" |
| 57 | + class="dropdown-content menu bg-base-100 rounded-box z-[1] w-52 p-2 shadow" |
| 58 | + > |
| 59 | + <li role="menuitem"> |
| 60 | + <a href="/orgs/{organizationId}/settings">組織設定</a> |
| 61 | + </li> |
| 62 | + <li role="menuitem"> |
| 63 | + <a href="/">組織選択</a> |
| 64 | + </li> |
| 65 | + </ul> |
| 66 | + </div> |
| 67 | + </div> |
| 68 | + {#if organization.data?.permission} |
| 69 | + <div class="badge badge-outline mt-2 capitalize"> |
| 70 | + {organization.data.permission} |
| 71 | + </div> |
| 72 | + {/if} |
| 73 | + </div> |
| 74 | + |
| 75 | + <ChannelList |
| 76 | + {organizationId} |
| 77 | + bind:selectedChannelId={ |
| 78 | + () => channelId, |
| 79 | + (id) => { |
| 80 | + goto(`/orgs/${organizationId}/chat/${id}`); |
| 81 | + } |
| 82 | + } |
| 83 | + /> |
| 84 | + </div> |
| 85 | + |
| 86 | + <div class="flex flex-1 flex-col"> |
| 87 | + {#if channelId} |
| 88 | + <Channel selectedChannelId={channelId} /> |
| 89 | + {:else} |
| 90 | + <div class="bg-base-200 flex flex-1 items-center justify-center"> |
| 91 | + <div class="text-center"> |
| 92 | + <h2 class="text-base-content/60 mb-2 text-2xl font-semibold"> |
| 93 | + {organization.data?.name || "組織"}へようこそ |
| 94 | + </h2> |
| 95 | + <p class="text-base-content/50"> |
| 96 | + 左からチャンネルを選択して会話を始めましょう |
| 97 | + </p> |
| 98 | + </div> |
| 99 | + </div> |
| 100 | + {/if} |
| 101 | + </div> |
| 102 | +</div> |
0 commit comments