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: 0 additions & 2 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ jobs:
uses: actions/checkout@v4
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 10
- name: Setup Node.js
uses: actions/setup-node@v4
with:
Expand Down
2 changes: 1 addition & 1 deletion app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ export default function Home() {

useEffect(() => {
if (!emblaApi) return;
onSelect();
emblaApi.on("select", onSelect);
emblaApi.on("reInit", onSelect);
emblaApi.emit("select");

return () => {
emblaApi.off("select", onSelect);
Expand Down
1 change: 1 addition & 0 deletions components/mini-lt/ManageTalks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ export function ManageTalks({
{/* 編集中または未登録の場合のみフォームを表示 */}
{editingTalk || !hasRegistered ? (
<SubmitForm
key={editingTalk?.id ?? "new"}
weekId={weekId}
onSubmit={async (data) => {
await onAction(data);
Expand Down
27 changes: 10 additions & 17 deletions components/mini-lt/SubmitForm.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"use client";

import { useState, useEffect } from "react";
import { useState } from "react";
import {
Button,
Input,
Expand All @@ -25,29 +25,22 @@ interface SubmitFormProps {
}

const DURATION_OPTIONS = [1, 3, 5, 7, 10, 15] as const;
const DEFAULT_DURATION = 5;

export function SubmitForm({
onSubmit,
editingTalk,
onCancelEdit,
}: SubmitFormProps) {
const [title, setTitle] = useState("");
const [description, setDescription] = useState("");
const [duration, setDuration] = useState<number>(5); // Default 5 minutes
const [title, setTitle] = useState(editingTalk?.title ?? "");
const [description, setDescription] = useState(
editingTalk?.description ?? "",
);
const [duration, setDuration] = useState<number>(
editingTalk?.duration ?? DEFAULT_DURATION,
);
const [loading, setLoading] = useState(false);

useEffect(() => {
if (editingTalk) {
setTitle(editingTalk.title);
setDescription(editingTalk.description);
setDuration(editingTalk.duration);
} else {
setTitle("");
setDescription("");
setDuration(5); // Reset to default
}
}, [editingTalk]);

const handleSubmit = async (e: React.FormEvent) => {
e.preventDefault();
setLoading(true);
Expand All @@ -56,7 +49,7 @@ export function SubmitForm({
if (!editingTalk) {
setTitle("");
setDescription("");
setDuration(5);
setDuration(DEFAULT_DURATION);
}
} finally {
setLoading(false);
Expand Down
24 changes: 15 additions & 9 deletions components/onboarding-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -314,9 +314,9 @@ export default function OnboardingForm({
const stepParam = searchParams.get("step");

if (success === "line_linked") {
setLineLinked(true);
fetchProfile()
.then((data) => {
setLineLinked(true);
if (data?.line) {
setLineUsername(data.line);
setLineAvatar(data.lineAvatar ?? "");
Expand All @@ -340,31 +340,37 @@ export default function OnboardingForm({
})
.catch(console.error);
} else if (success === "github_linked") {
setGithubLinked(true);
fetchProfile()
.then((data) => {
setGithubLinked(true);
if (data?.github) {
setGithubUsername(data.github);
setGithubAvatar(data.githubAvatar ?? "");
}
})
.catch(console.error);
} else if (success === "x_linked") {
setXLinked(true);
fetchProfile()
.then((data) => {
setXLinked(true);
if (data?.x) {
setXUsername(data.x);
setXAvatar(data.xAvatar ?? "");
}
})
.catch(console.error);
} else if (error === "line_link_failed") {
setStep3Error("LINE連携に失敗しました。もう一度お試しください。");
} else if (error === "github_link_failed") {
setStep3Error("GitHub連携に失敗しました。もう一度お試しください。");
} else if (error === "x_link_failed") {
setStep3Error("X連携に失敗しました。もう一度お試しください。");
} else if (error) {
const errorMessage =
error === "line_link_failed"
? "LINE連携に失敗しました。もう一度お試しください。"
: error === "github_link_failed"
? "GitHub連携に失敗しました。もう一度お試しください。"
: error === "x_link_failed"
? "X連携に失敗しました。もう一度お試しください。"
: null;
if (errorMessage) {
queueMicrotask(() => setStep3Error(errorMessage));
}
}

if (success || error) {
Expand Down
2 changes: 1 addition & 1 deletion components/ui/carousel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,9 @@ const Carousel = React.forwardRef<
return;
}

onSelect(api);
api.on("reInit", onSelect);
api.on("select", onSelect);
api.emit("select");

return () => {
api?.off("select", onSelect);
Expand Down
28 changes: 14 additions & 14 deletions components/ui/use-mobile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@ import * as React from "react";

const MOBILE_BREAKPOINT = 768;

export function useIsMobile() {
const [isMobile, setIsMobile] = React.useState<boolean | undefined>(
undefined,
);
function subscribe(callback: () => void) {
const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`);
mql.addEventListener("change", callback);
return () => mql.removeEventListener("change", callback);
}

function getSnapshot() {
return window.innerWidth < MOBILE_BREAKPOINT;
}

React.useEffect(() => {
const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`);
const onChange = () => {
setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
};
mql.addEventListener("change", onChange);
setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
return () => mql.removeEventListener("change", onChange);
}, []);
function getServerSnapshot() {
return false;
}

return !!isMobile;
export function useIsMobile() {
return React.useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
}
28 changes: 14 additions & 14 deletions hooks/use-mobile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@ import * as React from "react";

const MOBILE_BREAKPOINT = 768;

export function useIsMobile() {
const [isMobile, setIsMobile] = React.useState<boolean | undefined>(
undefined,
);
function subscribe(callback: () => void) {
const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`);
mql.addEventListener("change", callback);
return () => mql.removeEventListener("change", callback);
}

function getSnapshot() {
return window.innerWidth < MOBILE_BREAKPOINT;
}

React.useEffect(() => {
const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`);
const onChange = () => {
setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
};
mql.addEventListener("change", onChange);
setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
return () => mql.removeEventListener("change", onChange);
}, []);
function getServerSnapshot() {
return false;
}

return !!isMobile;
export function useIsMobile() {
return React.useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "my-v0-project",
"version": "0.1.0",
"private": true,
"packageManager": "pnpm@10.33.0",
"scripts": {
"dev": "next dev",
"build": "next build",
Expand Down
Loading