-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(rsc): Add ServerDelayForm to rsc-caching fixture (missing files) (
- Loading branch information
Showing
3 changed files
with
50 additions
and
0 deletions.
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
__fixtures__/rsc-caching/web/src/components/ServerDelayForm/ServerDelayForm.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
.server-delay-form { | ||
padding: 1rem; | ||
|
||
label div { | ||
margin-bottom: 4px; | ||
} | ||
|
||
input { | ||
margin-right: 4px; | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
__fixtures__/rsc-caching/web/src/components/ServerDelayForm/ServerDelayForm.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import fs from 'node:fs' | ||
|
||
import { formAction } from './actions' | ||
|
||
import './ServerDelayForm.css' | ||
|
||
const ServerDelayForm = () => { | ||
let delay = 0 | ||
|
||
if (fs.existsSync('settings.json')) { | ||
delay = JSON.parse(fs.readFileSync('settings.json', 'utf8')).delay || 0 | ||
} | ||
|
||
return ( | ||
<div className="server-delay-form"> | ||
<form action={formAction}> | ||
<label htmlFor="delay"> | ||
<div>Delay ({delay}ms)</div> | ||
<input type="number" id="delay" name="delay" /> | ||
</label> | ||
<button type="submit">Set</button> | ||
</form> | ||
</div> | ||
) | ||
} | ||
|
||
export default ServerDelayForm |
12 changes: 12 additions & 0 deletions
12
__fixtures__/rsc-caching/web/src/components/ServerDelayForm/actions.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
'use server' | ||
|
||
import fs from 'node:fs' | ||
|
||
export async function formAction(formData: FormData) { | ||
console.log(formData.get('delay')) | ||
console.log('cwd', process.cwd()) | ||
await fs.promises.writeFile( | ||
'settings.json', | ||
`{ "delay": ${formData.get('delay')} }\n` | ||
) | ||
} |