Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit01c4165

Browse files
committed
refactor: split in two views, compete link and default
1 parent7178c20 commit01c4165

File tree

5 files changed

+49
-18
lines changed

5 files changed

+49
-18
lines changed

‎app/compete/page.tsx‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
importfetchTemplatesfrom'../../actions/fetchTemplates';
2+
importStartFormfrom'../../components/forms/StartForm';
3+
4+
exportdefaultasyncfunctionPage(){
5+
consttemplates=awaitfetchTemplates();
6+
return<StartFormtemplates={templates}></StartForm>;
7+
}

‎app/page.tsx‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
1-
importfetchTemplatesfrom'../actions/fetchTemplates';
2-
importTemplateFormfrom'../components/templates/TemplateForm';
1+
importStartFormfrom'../components/forms/StartForm';
2+
import{TemplateInformations,templatesDictionary}from'../config/templates';
33

44
exportdefaultasyncfunctionPage(){
5-
consttemplates=awaitfetchTemplates();
6-
return<TemplateFormtemplates={templates}></TemplateForm>;
5+
consttemplates:TemplateInformations[]=Object.entries(
6+
templatesDictionary
7+
).map(([key,value])=>({
8+
...value,
9+
eventName:key,
10+
}));
11+
return<StartFormtemplates={templates}></StartForm>;
712
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import{TemplateInformations}from'../../config/templates';
2+
3+
import{useFetchTemplates}from'../../hooks/useFetchTemplates';
4+
importCodeInTheDarkInitialFormfrom'./StartForm';
5+
6+
exportdefaultfunctionCompetitionStartingForm({
7+
templates:newTemplates,
8+
}:{
9+
templates:TemplateInformations[];
10+
}){
11+
const{ templates=newTemplates}=useFetchTemplates();
12+
13+
return<CodeInTheDarkInitialFormtemplates={templates}/>;
14+
}

‎components/templates/TemplateForm.tsx‎renamed to ‎components/forms/StartForm.tsx‎

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,12 @@ import { TemplateInformations } from '../../config/templates';
88
import{useEntryStore}from'../../hooks/useEntryStore';
99

1010
importstylesfrom'../../styles/register.module.scss';
11-
importuseSWRfrom'swr';
12-
importfetchTemplatesfrom'../../actions/fetchTemplates';
1311

14-
exportdefaultfunctionTemplateForm({
15-
templates:newTemplates,
12+
exportdefaultfunctionStartForm({
13+
templates,
1614
}:{
1715
templates:TemplateInformations[];
1816
}){
19-
const{data:templates=newTemplates}=useSWR(
20-
'templates',
21-
async()=>{
22-
returnawaitfetchTemplates();
23-
},
24-
{
25-
refreshInterval:2000,
26-
}
27-
);
28-
2917
constrouter=useRouter();
3018
const[selectedTemplateIndex,setSelectedTemplateIndex]=useState<number>(0);
3119
const{ entry, updateFullName, updateId, updateIsLoading, updateTemplate}=

‎hooks/useFetchTemplates.ts‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
'use client';
2+
importuseSWRfrom'swr';
3+
importfetchTemplatesfrom'../actions/fetchTemplates';
4+
5+
exportfunctionuseFetchTemplates(){
6+
const{data:templates}=useSWR(
7+
'templates',
8+
async()=>{
9+
returnawaitfetchTemplates();
10+
},
11+
{
12+
refreshInterval:2000,
13+
}
14+
);
15+
16+
return{ templates};
17+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp