Compare commits
No commits in common. "bec2d73114130e49870ab0ed0a5158c38d13b943" and "ab43920e4f65a40e9bcc4d317d17d0571e64d1f7" have entirely different histories.
bec2d73114
...
ab43920e4f
|
|
@ -8,7 +8,7 @@
|
||||||
"build": "astro build",
|
"build": "astro build",
|
||||||
"preview": "astro preview",
|
"preview": "astro preview",
|
||||||
"astro": "astro",
|
"astro": "astro",
|
||||||
"typegen": "pocketbase-typegen --out ./src/types/pb_types.d.ts --env"
|
"typegen": "npm run pocketbase --out ./src/types/pb_types.d.ts --env"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@astrojs/preact": "^3.0.0",
|
"@astrojs/preact": "^3.0.0",
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,7 @@
|
||||||
import { FaCog } from "react-icons/fa";
|
import { FaCog } from "react-icons/fa";
|
||||||
import { Pb } from "../../EspaceMembres";
|
|
||||||
import { useContext, useState } from "preact/hooks";
|
|
||||||
import type { ChannelsRecord } from "../../../types/pb_types";
|
|
||||||
|
|
||||||
export default function Channels() {
|
export default function Channels() {
|
||||||
const pb = useContext(Pb);
|
const channels = ["Discussion", "Nature", "Portrait", "Architecture"];
|
||||||
const [channels, setChannels] = useState<Array<ChannelsRecord>>([]);
|
|
||||||
pb.collection('channels').getFullList<ChannelsRecord>().then((data) => {
|
|
||||||
if (!data) return;
|
|
||||||
setChannels(data);
|
|
||||||
});
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-col flex-grow border-b-2 border-b-gray-200">
|
<div className="flex flex-col flex-grow border-b-2 border-b-gray-200">
|
||||||
|
|
@ -23,7 +15,7 @@ export default function Channels() {
|
||||||
{channels.map((channel) => (
|
{channels.map((channel) => (
|
||||||
<li className="p-2 hover:bg-gray-100 cursor-pointer text-xl flex items-center" key={channel}>
|
<li className="p-2 hover:bg-gray-100 cursor-pointer text-xl flex items-center" key={channel}>
|
||||||
<p className="flex-grow">
|
<p className="flex-grow">
|
||||||
<span className="text-gray-400">#</span> {channel.name}
|
<span className="text-gray-400">#</span> {channel}
|
||||||
</p>
|
</p>
|
||||||
<FaCog className="transition hover:text-gray-700" />
|
<FaCog className="transition hover:text-gray-700" />
|
||||||
</li>
|
</li>
|
||||||
|
|
|
||||||
|
|
@ -6,11 +6,9 @@ import type PocketBase from 'pocketbase'
|
||||||
import type { RecordService } from 'pocketbase'
|
import type { RecordService } from 'pocketbase'
|
||||||
|
|
||||||
export enum Collections {
|
export enum Collections {
|
||||||
Albums = "albums",
|
|
||||||
Channels = "channels",
|
Channels = "channels",
|
||||||
Messages = "messages",
|
Files = "files",
|
||||||
Pages = "pages",
|
Pages = "pages",
|
||||||
Photos = "photos",
|
|
||||||
Users = "users",
|
Users = "users",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -38,22 +36,14 @@ export type AuthSystemFields<T = never> = {
|
||||||
|
|
||||||
// Record types for each collection
|
// Record types for each collection
|
||||||
|
|
||||||
export type AlbumsRecord = {
|
|
||||||
description?: string
|
|
||||||
pictures?: RecordIdString[]
|
|
||||||
title?: string
|
|
||||||
}
|
|
||||||
|
|
||||||
export type ChannelsRecord = {
|
export type ChannelsRecord = {
|
||||||
creator?: RecordIdString
|
field1?: RecordIdString[]
|
||||||
name?: string
|
name?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export type MessagesRecord = {
|
export type FilesRecord = {
|
||||||
attachment?: string
|
alt?: string
|
||||||
author?: RecordIdString
|
file: string
|
||||||
channel?: RecordIdString
|
|
||||||
content?: string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export type PagesRecord<Tcontent = unknown> = {
|
export type PagesRecord<Tcontent = unknown> = {
|
||||||
|
|
@ -62,13 +52,6 @@ export type PagesRecord<Tcontent = unknown> = {
|
||||||
title?: string
|
title?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export type PhotosRecord = {
|
|
||||||
alt?: string
|
|
||||||
description?: string
|
|
||||||
image?: string
|
|
||||||
title?: string
|
|
||||||
}
|
|
||||||
|
|
||||||
export type UsersRecord = {
|
export type UsersRecord = {
|
||||||
avatar?: string
|
avatar?: string
|
||||||
firstname?: string
|
firstname?: string
|
||||||
|
|
@ -76,30 +59,24 @@ export type UsersRecord = {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Response types include system fields and match responses from the PocketBase API
|
// Response types include system fields and match responses from the PocketBase API
|
||||||
export type AlbumsResponse<Texpand = unknown> = Required<AlbumsRecord> & BaseSystemFields<Texpand>
|
|
||||||
export type ChannelsResponse<Texpand = unknown> = Required<ChannelsRecord> & BaseSystemFields<Texpand>
|
export type ChannelsResponse<Texpand = unknown> = Required<ChannelsRecord> & BaseSystemFields<Texpand>
|
||||||
export type MessagesResponse<Texpand = unknown> = Required<MessagesRecord> & BaseSystemFields<Texpand>
|
export type FilesResponse<Texpand = unknown> = Required<FilesRecord> & BaseSystemFields<Texpand>
|
||||||
export type PagesResponse<Tcontent = unknown, Texpand = unknown> = Required<PagesRecord<Tcontent>> & BaseSystemFields<Texpand>
|
export type PagesResponse<Tcontent = unknown, Texpand = unknown> = Required<PagesRecord<Tcontent>> & BaseSystemFields<Texpand>
|
||||||
export type PhotosResponse<Texpand = unknown> = Required<PhotosRecord> & BaseSystemFields<Texpand>
|
|
||||||
export type UsersResponse<Texpand = unknown> = Required<UsersRecord> & AuthSystemFields<Texpand>
|
export type UsersResponse<Texpand = unknown> = Required<UsersRecord> & AuthSystemFields<Texpand>
|
||||||
|
|
||||||
// Types containing all Records and Responses, useful for creating typing helper functions
|
// Types containing all Records and Responses, useful for creating typing helper functions
|
||||||
|
|
||||||
export type CollectionRecords = {
|
export type CollectionRecords = {
|
||||||
albums: AlbumsRecord
|
|
||||||
channels: ChannelsRecord
|
channels: ChannelsRecord
|
||||||
messages: MessagesRecord
|
files: FilesRecord
|
||||||
pages: PagesRecord
|
pages: PagesRecord
|
||||||
photos: PhotosRecord
|
|
||||||
users: UsersRecord
|
users: UsersRecord
|
||||||
}
|
}
|
||||||
|
|
||||||
export type CollectionResponses = {
|
export type CollectionResponses = {
|
||||||
albums: AlbumsResponse
|
|
||||||
channels: ChannelsResponse
|
channels: ChannelsResponse
|
||||||
messages: MessagesResponse
|
files: FilesResponse
|
||||||
pages: PagesResponse
|
pages: PagesResponse
|
||||||
photos: PhotosResponse
|
|
||||||
users: UsersResponse
|
users: UsersResponse
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -107,10 +84,8 @@ export type CollectionResponses = {
|
||||||
// https://github.com/pocketbase/js-sdk#specify-typescript-definitions
|
// https://github.com/pocketbase/js-sdk#specify-typescript-definitions
|
||||||
|
|
||||||
export type TypedPocketBase = PocketBase & {
|
export type TypedPocketBase = PocketBase & {
|
||||||
collection(idOrName: 'albums'): RecordService<AlbumsResponse>
|
|
||||||
collection(idOrName: 'channels'): RecordService<ChannelsResponse>
|
collection(idOrName: 'channels'): RecordService<ChannelsResponse>
|
||||||
collection(idOrName: 'messages'): RecordService<MessagesResponse>
|
collection(idOrName: 'files'): RecordService<FilesResponse>
|
||||||
collection(idOrName: 'pages'): RecordService<PagesResponse>
|
collection(idOrName: 'pages'): RecordService<PagesResponse>
|
||||||
collection(idOrName: 'photos'): RecordService<PhotosResponse>
|
|
||||||
collection(idOrName: 'users'): RecordService<UsersResponse>
|
collection(idOrName: 'users'): RecordService<UsersResponse>
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue