Skip to content

Commit

Permalink
Merge pull request #7694 from fjordllc/main
Browse files Browse the repository at this point in the history
Release 2024-04-17 02:48:52
  • Loading branch information
komagata authored Apr 18, 2024
2 parents 0d29c2b + 4a093d5 commit 113db79
Show file tree
Hide file tree
Showing 80 changed files with 1,153 additions and 542 deletions.
5 changes: 3 additions & 2 deletions app/controllers/admin/companies_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def edit; end

def update
if @company.update(company_params)
redirect_to admin_companies_url, notice: '企業を更新しました。'
redirect_to @company, notice: '企業を更新しました。'
else
render 'edit'
end
Expand Down Expand Up @@ -51,7 +51,8 @@ def company_params
:description,
:website,
:logo,
:blog_url
:blog_url,
:memo
)
end
end
10 changes: 10 additions & 0 deletions app/controllers/connection/discord_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# frozen_string_literal: true

class Connection::DiscordController < ApplicationController
skip_before_action :require_active_user_login, raise: false

def destroy
current_user.discord_profile.update(account_name: nil)
redirect_to root_path, notice: 'Discordとの連携を解除しました。'
end
end
1 change: 1 addition & 0 deletions app/controllers/works_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ def work_params
:description,
:url,
:repository,
:launch_article,
:thumbnail
)
end
Expand Down
157 changes: 157 additions & 0 deletions app/javascript/components/Following.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
import React, { useState, useRef } from 'react'
import CSRF from '../csrf.js'

export default function Following({ isFollowing, userId, isWatching }) {
const [following, setFollowing] = useState(isFollowing)
const [watching, setWatching] = useState(isWatching)
const followingDetailsRef = useRef(null)

const followOrChangeFollow = (watch) => {
const params = { id: userId, watch: watch }
const method = following ? 'PATCH' : 'POST'
const url = following ? `/api/followings/${userId}` : `/api/followings`
fetch(url, {
method: method,
headers: {
'Content-Type': 'application/json; charset=utf-8',
'X-Requested-With': 'XMLHttpRequest',
'X-CSRF-Token': CSRF.getToken()
},
credentials: 'same-origin',
redirect: 'manual',
body: JSON.stringify(params)
})
.then((response) => {
if (response.ok) {
setFollowing(true)
setWatching(watch)
} else {
alert('フォロー処理に失敗しました')
}
})
.catch((error) => {
console.warn(error)
})
.finally(() => {
followingDetailsRef.current.open = false
})
}

const unfollow = () => {
const params = { id: userId }
fetch(`/api/followings/${userId}`, {
method: 'DELETE',
headers: {
'Content-Type': 'application/json; charset=utf-8',
'X-Requested-With': 'XMLHttpRequest',
'X-CSRF-Token': CSRF.getToken()
},
credentials: 'same-origin',
redirect: 'manual',
body: JSON.stringify(params)
})
.then((response) => {
if (response.ok) {
setFollowing(false)
setWatching(false)
} else {
alert('フォロー処理に失敗しました')
}
})
.catch((error) => {
console.warn(error)
})
.finally(() => {
followingDetailsRef.current.open = false
})
}

return (
<details ref={followingDetailsRef} className="following">
<summary className="following__summary">
{following && watching ? (
<span className="a-button is-warning is-sm is-block">
<i className="fa-solid fa-check"></i>
<span>コメントあり</span>
</span>
) : following && !watching ? (
<span className="a-button is-warning is-sm is-block">
<i className="fa-solid fa-check"></i>
<span>コメントなし</span>
</span>
) : (
<span className="a-button is-secondary is-sm is-block">
フォローする
</span>
)}
</summary>
<div className="following__dropdown a-dropdown">
<ul className="a-dropdown__items">
<li className="following__dropdown-item a-dropdown__item">
{following && watching ? (
<button className="following-option a-dropdown__item-inner is-active">
<div className="following-option__inner">
<div className="following-option__label">コメントあり</div>
<div className="following-option__desciption">
フォローしたユーザーの日報を自動でWatch状態にします。日報投稿時の通知と日報にコメントが来た際に通知を受け取ります。
</div>
</div>
</button>
) : (
<button
className="following-option a-dropdown__item-inner"
onClick={() => followOrChangeFollow(true)}>
<div className="following-option__inner">
<div className="following-option__label">コメントあり</div>
<div className="following-option__desciption">
フォローしたユーザーの日報を自動でWatch状態にします。日報投稿時の通知と日報にコメントが来た際に通知を受け取ります。
</div>
</div>
</button>
)}
</li>
<li className="following__dropdown-item a-dropdown__item">
{following && !watching ? (
<button className="following-option a-dropdown__item-inner is-active">
<div className="following-option__inner">
<div className="following-option__label">コメントなし</div>
<div className="following-option__desciption">
フォローしたユーザーの日報はWatch状態にしません。日報投稿時の通知だけ通知を受けとります。
</div>
</div>
</button>
) : (
<button
className="following-option a-dropdown__item-inner"
onClick={() => followOrChangeFollow(false)}>
<div className="following-option__inner">
<div className="following-option__label">コメントなし</div>
<div className="following-option__desciption">
フォローしたユーザーの日報はWatch状態にしません。日報投稿時の通知だけ通知を受けとります。
</div>
</div>
</button>
)}
</li>
<li className="following__dropdown-item a-dropdown__item">
{!following && !watching ? (
<button className="following-option a-dropdown__item-inner is-active">
<div className="following-option__inner">
<div className="following-option__label">フォローしない</div>
</div>
</button>
) : (
<button
className="following-option a-dropdown__item-inner"
onClick={unfollow}>
<div className="following-option__inner">
<div className="following-option__label">フォローしない</div>
</div>
</button>
)}
</li>
</ul>
</div>
</details>
)
}
64 changes: 64 additions & 0 deletions app/javascript/components/GenerationUsers.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import React from 'react'
import useSWR from 'swr'
import User from './User.jsx'
import Pagination from './Pagination'
import usePage from './hooks/usePage'
import fetcher from '../fetcher'

export default function GenerationUsers({ generationID }) {
const itemsPerPage = 24
const { page, setPage } = usePage()
const { data, error } = useSWR(
`/api/generations/${generationID}.json?page=${page}&per=${itemsPerPage}`,
fetcher
)

if (error) return <>An error has occurred.</>
if (!data) return <>Loading...</>

return (
<div className="page-body">
{data.totalPages > 1 && (
<Pagination
sum={data.totalPages * itemsPerPage}
per={itemsPerPage}
page={page}
setPage={setPage}
/>
)}
<div className="container">
<div className="users row">
{data.users === null ? (
<div className="empty">
<i className="fa-solid fa-spinner fa-pulse" />
ロード中
</div>
) : data.users.length !== 0 ? (
data.users.map((user) => (
<User key={user.id} user={user} currentUser={data.currentUser} />
))
) : (
<div className="row">
<div className="o-empty-message">
<div className="o-empty-message__icon">
<i className="fa-regular fa-smile"></i>
</div>
<p className="o-empty-message_text">
{generationID}期のユーザー一覧はありません
</p>
</div>
</div>
)}
</div>
</div>
{data.totalPages > 1 && (
<Pagination
sum={data.totalPages * itemsPerPage}
per={itemsPerPage}
page={page}
setPage={setPage}
/>
)}
</div>
)
}
38 changes: 23 additions & 15 deletions app/javascript/components/Reports.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,21 +126,29 @@ export default function Reports({

const NoReports = ({ unchecked }) => {
return (
<div className="o-empty-message">
<div className="o-empty-message__icon">
{unchecked ? (
<>
<i className="fa-regular fa-smile" />
<p className="o-empty-message__text">
未チェックの日報はありません
</p>
</>
) : (
<>
<i className="fa-regular fa-sad-tear" />
<p className="o-empty-message__text">日報はまだありません。</p>
</>
)}
<div className="page-main">
<div className="page-body">
<div className="container is-md">
<div className="o-empty-message">
<div className="o-empty-message__icon">
{unchecked ? (
<>
<i className="fa-regular fa-smile" />
<p className="o-empty-message__text">
未チェックの日報はありません
</p>
</>
) : (
<>
<i className="fa-regular fa-sad-tear" />
<p className="o-empty-message__text">
日報はまだありません。
</p>
</>
)}
</div>
</div>
</div>
</div>
</div>
)
Expand Down
Loading

0 comments on commit 113db79

Please sign in to comment.