Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

npm run lint-staged
4 changes: 2 additions & 2 deletions apps/desktop/app/app.css
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
@import "tailwindcss";
@import "@tsumugi/ui/index.css";
@import 'tailwindcss';
@import '@tsumugi/ui/index.css';
2 changes: 1 addition & 1 deletion apps/desktop/app/constants/path.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export const PATH_TOP = '/';
export const PATH_HOME = '/home';
export const PATH_WORKSPACE = '/workspace';
export const PATH_WORKSPACE = '/workspace';
22 changes: 13 additions & 9 deletions apps/desktop/app/hooks/characters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import type { ContentItemKey, ContentTreeKey } from '~/hooks/keys';

type CharacterTreeKey = ContentTreeKey<'character'>;


/**
* プロジェクト内のキャラクターツリーを取得する
* @param projectId - プロジェクトID
Expand All @@ -26,7 +25,10 @@ type CharacterKey = ContentItemKey<'character'>;
* @param id - キャラクターID
* @param config
*/
export function useCharacter(id: string, config?: SWRConfiguration<Character | null, Error>) {
export function useCharacter(
id: string,
config?: SWRConfiguration<Character | null, Error>,
) {
const adapter = useAdapter();
return useSWR<Character | null, Error, CharacterKey>(
{ type: 'character', id },
Expand Down Expand Up @@ -122,11 +124,13 @@ interface ReorderCharactersArg {
*/
export function useReorderCharacters(projectId: string) {
const adapter = useAdapter();
return useSWRMutation<undefined, Error, CharacterTreeKey, ReorderCharactersArg>(
{ type: 'characterTree', projectId },
async (_, { arg }) => {
await adapter.characters.reorder(arg.parentId, arg.orderedIds);
return undefined;
},
);
return useSWRMutation<
undefined,
Error,
CharacterTreeKey,
ReorderCharactersArg
>({ type: 'characterTree', projectId }, async (_, { arg }) => {
await adapter.characters.reorder(arg.parentId, arg.orderedIds);
return undefined;
});
}
34 changes: 22 additions & 12 deletions apps/desktop/app/hooks/memos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ import type { ContentItemKey, ContentTreeKey } from '~/hooks/keys';

type MemoTreeKey = ContentTreeKey<'memo'>;


/**
* プロジェクト内のメモツリーを取得する
* @param projectId - プロジェクトID
*/
export function useMemoTree(projectId: string) {
const adapter = useAdapter();
return useSWR<TreeNode[], Error, MemoTreeKey>({ type: 'memoTree', projectId }, ({ projectId }) =>
adapter.memos.getTreeByProjectId(projectId),
return useSWR<TreeNode[], Error, MemoTreeKey>(
{ type: 'memoTree', projectId },
({ projectId }) => adapter.memos.getTreeByProjectId(projectId),
);
}

Expand All @@ -25,7 +25,10 @@ type MemoKey = ContentItemKey<'memo'>;
* @param id - メモID
* @param config
*/
export function useMemo(id: string, config?: SWRConfiguration<Memo | null, Error>) {
export function useMemo(
id: string,
config?: SWRConfiguration<Memo | null, Error>,
) {
const adapter = useAdapter();
return useSWR<Memo | null, Error, MemoKey>(
{ type: 'memo', id },
Expand All @@ -34,7 +37,10 @@ export function useMemo(id: string, config?: SWRConfiguration<Memo | null, Error
);
}

type CreateMemoData = Omit<Memo, 'projectId' | 'id' | 'createdAt' | 'updatedAt'>;
type CreateMemoData = Omit<
Memo,
'projectId' | 'id' | 'createdAt' | 'updatedAt'
>;

/**
* メモを作成する
Expand All @@ -45,14 +51,17 @@ export function useCreateMemo(projectId: string) {
const adapter = useAdapter();
return useSWRMutation<Memo, Error, MemoTreeKey, CreateMemoData>(
{ type: 'memoTree', projectId },
({ projectId }, { arg }) => adapter.memos.create({
projectId,
...arg,
}),
({ projectId }, { arg }) =>
adapter.memos.create({
projectId,
...arg,
}),
);
}

type UpdateMemoData = Partial<Omit<Memo, 'id' | 'projectId' | 'createdAt' | 'updatedAt'>>;
type UpdateMemoData = Partial<
Omit<Memo, 'id' | 'projectId' | 'createdAt' | 'updatedAt'>
>;

/**
* メモを更新する
Expand Down Expand Up @@ -134,7 +143,8 @@ interface MemosByTagKey {
*/
export function useMemosByTag(projectId: string, tag: string) {
const adapter = useAdapter();
return useSWR<Memo[], Error, MemosByTagKey>({ type: 'memosByTag', projectId, tag }, ({ projectId, tag }) =>
adapter.memos.getByTag(projectId, tag),
return useSWR<Memo[], Error, MemosByTagKey>(
{ type: 'memosByTag', projectId, tag },
({ projectId, tag }) => adapter.memos.getByTag(projectId, tag),
);
}
29 changes: 19 additions & 10 deletions apps/desktop/app/hooks/plots.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ import type { ContentItemKey, ContentTreeKey } from '~/hooks/keys';

type PlotTreeKey = ContentTreeKey<'plot'>;


/**
* プロジェクト内のプロットツリーを取得する
* @param projectId - プロジェクトID
*/
export function usePlotTree(projectId: string) {
const adapter = useAdapter();
return useSWR<TreeNode[], Error, PlotTreeKey>({ type: 'plotTree', projectId }, ({ projectId }) =>
adapter.plots.getTreeByProjectId(projectId),
return useSWR<TreeNode[], Error, PlotTreeKey>(
{ type: 'plotTree', projectId },
({ projectId }) => adapter.plots.getTreeByProjectId(projectId),
);
}

Expand All @@ -25,7 +25,10 @@ type PlotKey = ContentItemKey<'plot'>;
* @param id - プロットID
* @param config
*/
export function usePlot(id: string, config?: SWRConfiguration<Plot | null, Error>) {
export function usePlot(
id: string,
config?: SWRConfiguration<Plot | null, Error>,
) {
const adapter = useAdapter();
return useSWR<Plot | null, Error, PlotKey>(
{ type: 'plot', id },
Expand All @@ -34,7 +37,10 @@ export function usePlot(id: string, config?: SWRConfiguration<Plot | null, Error
);
}

type CreatePlotData = Omit<Plot, 'projectId' | 'id' | 'createdAt' | 'updatedAt'>;
type CreatePlotData = Omit<
Plot,
'projectId' | 'id' | 'createdAt' | 'updatedAt'
>;

/**
* プロットを作成する
Expand All @@ -45,14 +51,17 @@ export function useCreatePlot(projectId: string) {
const adapter = useAdapter();
return useSWRMutation<Plot, Error, PlotTreeKey, CreatePlotData>(
{ type: 'plotTree', projectId },
({ projectId }, { arg }) => adapter.plots.create({
projectId,
...arg,
}),
({ projectId }, { arg }) =>
adapter.plots.create({
projectId,
...arg,
}),
);
}

type UpdatePlotData = Partial<Omit<Plot, 'id' | 'projectId' | 'createdAt' | 'updatedAt'>>;
type UpdatePlotData = Partial<
Omit<Plot, 'id' | 'projectId' | 'createdAt' | 'updatedAt'>
>;

/**
* プロットを更新する
Expand Down
9 changes: 7 additions & 2 deletions apps/desktop/app/hooks/projects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ interface ProjectKey {
* @param id - プロジェクトID
* @param config
*/
export function useProject(id: string, config?: SWRConfiguration<Project | null, Error>) {
export function useProject(
id: string,
config?: SWRConfiguration<Project | null, Error>,
) {
const adapter = useAdapter();
return useSWR<Project | null, Error, ProjectKey>(
{ type: 'project', id },
Expand All @@ -50,7 +53,9 @@ export function useCreateProject() {
);
}

type UpdateProjectData = Partial<Omit<Project, 'id' | 'createdAt' | 'updatedAt'>>;
type UpdateProjectData = Partial<
Omit<Project, 'id' | 'createdAt' | 'updatedAt'>
>;

/**
* プロジェクトを更新する
Expand Down
10 changes: 7 additions & 3 deletions apps/desktop/app/hooks/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,12 @@ export function useProjectSettings(projectId: string) {
*/
export function useUpdateProjectSettings(projectId: string) {
const adapter = useAdapter();
return useSWRMutation<ProjectSettings, Error, ProjectSettingKey, Partial<ProjectSettings>>(
{ type: 'projectSettings', projectId },
({ projectId }, { arg }) => adapter.settings.update(projectId, arg),
return useSWRMutation<
ProjectSettings,
Error,
ProjectSettingKey,
Partial<ProjectSettings>
>({ type: 'projectSettings', projectId }, ({ projectId }, { arg }) =>
adapter.settings.update(projectId, arg),
);
}
34 changes: 22 additions & 12 deletions apps/desktop/app/hooks/writings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ import type { ContentItemKey, ContentTreeKey } from '~/hooks/keys';

type WritingTreeKey = ContentTreeKey<'writing'>;


/**
* プロジェクト内の執筆ツリーを取得する
* @param projectId - プロジェクトID
*/
export function useWritingTree(projectId: string) {
const adapter = useAdapter();
return useSWR<TreeNode[], Error, WritingTreeKey>({ type: 'writingTree', projectId }, ({ projectId }) =>
adapter.writings.getTreeByProjectId(projectId),
return useSWR<TreeNode[], Error, WritingTreeKey>(
{ type: 'writingTree', projectId },
({ projectId }) => adapter.writings.getTreeByProjectId(projectId),
);
}

Expand All @@ -25,7 +25,10 @@ type WritingKey = ContentItemKey<'writing'>;
* @param id - 執筆ID
* @param config
*/
export function useWriting(id: string, config?: SWRConfiguration<Writing | null, Error>) {
export function useWriting(
id: string,
config?: SWRConfiguration<Writing | null, Error>,
) {
const adapter = useAdapter();
return useSWR<Writing | null, Error, WritingKey>(
{ type: 'writing', id },
Expand All @@ -34,7 +37,10 @@ export function useWriting(id: string, config?: SWRConfiguration<Writing | null,
);
}

type CreateWritingData = Omit<Writing, 'projectId' | 'id' | 'createdAt' | 'updatedAt'>;
type CreateWritingData = Omit<
Writing,
'projectId' | 'id' | 'createdAt' | 'updatedAt'
>;

/**
* 執筆を作成する
Expand All @@ -45,14 +51,17 @@ export function useCreateWriting(projectId: string) {
const adapter = useAdapter();
return useSWRMutation<Writing, Error, WritingTreeKey, CreateWritingData>(
{ type: 'writingTree', projectId },
({ projectId }, { arg }) => adapter.writings.create({
projectId,
...arg,
}),
({ projectId }, { arg }) =>
adapter.writings.create({
projectId,
...arg,
}),
);
}

type UpdateWritingData = Partial<Omit<Writing, 'id' | 'projectId' | 'createdAt' | 'updatedAt'>>;
type UpdateWritingData = Partial<
Omit<Writing, 'id' | 'projectId' | 'createdAt' | 'updatedAt'>
>;

/**
* 執筆を更新する
Expand Down Expand Up @@ -132,7 +141,8 @@ interface TotalWordCountKey {
*/
export function useTotalWordCount(projectId: string) {
const adapter = useAdapter();
return useSWR<number, Error, TotalWordCountKey>({ type: 'totalWordCount', projectId }, ({ projectId }) =>
adapter.writings.getTotalWordCount(projectId),
return useSWR<number, Error, TotalWordCountKey>(
{ type: 'totalWordCount', projectId },
({ projectId }) => adapter.writings.getTotalWordCount(projectId),
);
}
10 changes: 5 additions & 5 deletions apps/desktop/app/routes/(guest)/_components/feature-card.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import * as React from 'react';

interface FeatureCardProps {
icon: React.ReactNode
title: string
description: string
icon: React.ReactNode;
title: string;
description: string;
}

export function FeatureCard({ icon, title, description }: FeatureCardProps) {
Expand All @@ -17,5 +17,5 @@ export function FeatureCard({ icon, title, description }: FeatureCardProps) {
{description}
</p>
</div>
)
}
);
}
2 changes: 1 addition & 1 deletion apps/desktop/app/routes/(guest)/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default function Layout() {
return <LoadingPage message="ログイン情報を確認しています" />;
}
// ログイン状態の場合はホームにリダイレクト
if (data && data.isAuthenticated){
if (data && data.isAuthenticated) {
return <Navigate to={PATH_HOME} replace />;
}

Expand Down
Loading