Skip to content

Commit

Permalink
Merge pull request #132 from FltSv/develop
Browse files Browse the repository at this point in the history
v0.3.0リリース
  • Loading branch information
FltSv authored Aug 26, 2024
2 parents 4f8d72c + cef094c commit 2b4ba8c
Show file tree
Hide file tree
Showing 25 changed files with 791 additions and 76 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/hosting-pr-actions.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
name: hosting-pr-actions
on:
pull_request:
push:
branches:
- master
branches-ignore:
- "master"

defaults:
run:
Expand Down
52 changes: 52 additions & 0 deletions Hosting/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Hosting/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
"author": "suna",
"license": "ISC",
"dependencies": {
"@dnd-kit/core": "^6.1.0",
"@dnd-kit/sortable": "^8.0.0",
"@dnd-kit/utilities": "^3.2.2",
"@emotion/react": "^11.11.4",
"@emotion/styled": "^11.11.5",
"@mui/joy": "^5.0.0-dev.240424162023-9968b4889d",
Expand Down
27 changes: 27 additions & 0 deletions Hosting/src/Auth.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
import {
createUserWithEmailAndPassword,
FacebookAuthProvider,
getAuth,
GoogleAuthProvider,
sendEmailVerification,
signInWithEmailAndPassword,
signInWithPopup,
} from 'firebase/auth';

type providerTypes = 'google' | 'facebook' | 'email';

/**
* メール・パスワードによるログイン処理
* @param email メールアドレス
Expand Down Expand Up @@ -32,6 +37,28 @@ export async function signupWithEmail(email: string, pass: string) {
return userCredential;
}

/** Googleログイン・新規登録 */
export async function loginWith(providerType: providerTypes) {
let provider;
switch (providerType) {
case 'google':
provider = new GoogleAuthProvider();
break;

case 'facebook':
provider = new FacebookAuthProvider();
break;

default:
throw new Error('Invalid provider type');
}

// ポップアップでログイン
return await signInWithPopup(getAuth(), provider).catch((error: unknown) => {
console.error(error);
});
}

/**
* ログアウト
*/
Expand Down
27 changes: 26 additions & 1 deletion Hosting/src/Data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ export async function getCreatorData(user: User) {
const creatorUrl = getCreatorStorageUrl(userId);
const creator: Creator = {
name: '',
profile: '',
links: [],
products: [],
exhibits: [],
};
Expand All @@ -67,11 +69,15 @@ export async function getCreatorData(user: User) {
console.debug('docSnap.data:', data);

creator.name = data.name ?? '';
creator.profile = data.profile ?? '';
creator.links = data.links ?? [];

// 発表作品
const fbProducts = data.products ?? [];
creator.products = fbProducts.map(x => ({
id: x.id,
title: x.title ?? '',
detail: x.detail ?? '',
srcImage: x.image,
imageUrl: creatorUrl + x.image,
tmpImageData: '',
Expand Down Expand Up @@ -112,7 +118,14 @@ export async function setCreatorData(user: User, data: Creator) {
);
await setDoc(docRef, {
name: data.name,
products: data.products.map(x => ({ id: x.id, image: x.srcImage })),
profile: data.profile,
links: data.links,
products: data.products.map(x => ({
id: x.id,
title: x.title,
detail: x.detail,
image: x.srcImage,
})),
exhibits: data.exhibits.map(x => ({
id: x.id,
title: x.title,
Expand Down Expand Up @@ -307,6 +320,12 @@ export interface Creator {
/** 表示名 */
name: string;

/** プロフィール */
profile: string;

/** SNSリンク */
links: string[];

/** 発表作品一覧 */
products: Product[];

Expand All @@ -317,6 +336,12 @@ export interface Creator {
/** 発表作品 */
export interface Product extends ImageStatus {
id: string;

/** 作品名 */
title: string;

/** 作品説明、他 */
detail: string;
}

/** 展示 */
Expand Down
12 changes: 6 additions & 6 deletions Hosting/src/components/pages/Login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { FcGoogle } from 'react-icons/fc';
import { FaFacebook } from 'react-icons/fa';
import { FirebaseError } from 'firebase/app';
import { Button, SubmitButton, Textbox } from '../ui/Input';
import { loginWithEmail, signupWithEmail } from '../../Auth';
import { loginWithEmail, loginWith, signupWithEmail } from '../../Auth';
import { useAuthContext } from '../AuthContext';

interface Inputs {
Expand Down Expand Up @@ -147,18 +147,18 @@ export const Login = () => {

{/* ソーシャルログイン */}
<Divider className="text-base">or</Divider>
{/* 実装まで無効化 */}
<div className="flex gap-4">
<Button
disabled
startDecorator={<FcGoogle />}
className="w-fit bg-white text-black">
className="w-fit bg-white text-black"
onClick={() => void loginWith('google')}>
Continue with Google
</Button>
{/* 法人化が必要そうなので非表示 */}
<Button
disabled
startDecorator={<FaFacebook color="#1877F2" />}
className="w-fit bg-white text-black">
className="hidden w-fit bg-white text-black"
onClick={() => void loginWith('facebook')}>
Continue with Facebook
</Button>
</div>
Expand Down
Loading

0 comments on commit 2b4ba8c

Please sign in to comment.