// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the GNU Affero General Public License v3.0.
// See the LICENCE file in the repository root for full licence text.

import StringWithComponent from 'components/string-with-component';
import BeatmapsetDiscussionPostJson from 'interfaces/beatmapset-discussion-post-json';
import UserJson from 'interfaces/user-json';
import { route } from 'laroute';
import * as React from 'react';
import { classWithModifiers } from 'utils/css';

interface Props {
  post: BeatmapsetDiscussionPostJson;
  user: UserJson;
}

export default function SystemPost({ post, user }: Props) {
  if (!post.system) return null;
  if (post.message.type !== 'resolved') {
    console.error(`unknown type: ${post.message.type}`);
  }

  const className = classWithModifiers('beatmap-discussion-system-post', post.message.type, {
    deleted: post.deleted_at != null,
  });

  return (
    <div className={className}>
      <div className='beatmap-discussion-system-post__content'>
        {post.message.type === 'resolved' && (
          <StringWithComponent
            mappings={{
              user: <a
                className='beatmap-discussion-system-post__user'
                href={route('users.show', { user: user.id })}
              >
                {user.username}
              </a>,
            }}
            pattern={osu.trans(`beatmap_discussions.system.resolved.${post.message.value}`)}
          />
        )}
      </div>
    </div>
  );
}

// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the GNU Affero General Public License v3.0.
// See the LICENCE file in the repository root for full licence text.

import StringWithComponent from 'components/string-with-component';
import BeatmapsetDiscussionPostJson from 'interfaces/beatmapset-discussion-post-json';
import UserJson from 'interfaces/user-json';
import { route } from 'laroute';
import * as React from 'react';
import { classWithModifiers } from 'utils/css';

interface Props {
  post: BeatmapsetDiscussionPostJson;
  user: UserJson;
}

export default function SystemPost({ post, user }: Props) {
  if (!post.system) return null;
  if (post.message.type !== 'resolved') return null;

  const className = classWithModifiers('beatmap-discussion-system-post', post.message.type, {
    deleted: post.deleted_at != null,
  });

  return (
    <div className={className}>
      <div className='beatmap-discussion-system-post__content'>
        <StringWithComponent
          mappings={{
            user: <a
              className='beatmap-discussion-system-post__user'
              href={route('users.show', { user: user.id })}
            >
              {user.username}
            </a>,
          }}
          pattern={osu.trans(`beatmap_discussions.system.resolved.${post.message.value}`)}
        />
      </div>
    </div>
  );
}

Revert "render blank content for unknown types"
Revert "render blank content for unknown types"

This reverts commit 3459caadd2a8f4b2ad08b323f77ca2d4570f34bb.
