Skip to content
Open
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
11 changes: 10 additions & 1 deletion atomic/atom/icon/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export function AdIcon({
size,
className = '',
style,
adType,
...rest
}: IconInterface & { style?: CSSProperties }): JSX.Element | null {
if (!icon) return null
Expand All @@ -28,6 +29,7 @@ export function AdIcon({
icon={icon}
className={cx(styles['iconify-icon'], className)}
style={mergedStyle}
{...(adType ? { 'data-ad-type': adType } : {})}
{...rest}
/>
)
Expand All @@ -36,5 +38,12 @@ export function AdIcon({
const iconClass = `pi pi-${icon.replace('prime:', '')}`
const mergedClassName = cx(iconClass, styles['prime-icon'], className)

return <i className={mergedClassName} style={mergedStyle} {...rest} />
return (
<i
className={mergedClassName}
style={mergedStyle}
{...(adType ? { 'data-ad-type': adType } : {})}
{...rest}
/>
)
}
36 changes: 20 additions & 16 deletions modules/nuc_charts/atomic/template/entity-chart/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use client'
import type { ChartData } from 'chart.js'
import React, { useEffect, useMemo, useState } from 'react'
import React, { useMemo } from 'react'

import { AdChart, type ChartType } from 'nucleify'

Expand All @@ -10,17 +10,15 @@ import { useChart } from './utils/use_chart'
export const NucEntityChart: React.FC<NucEntityChartInterface> = (props) => {
const { setChartData, setChartOptions } = useChart()

const [chartData, setChartDataState] = useState<ChartData | null>(null)

const chartOptions = useMemo(() => {
if (!props.type) return {}

return setChartOptions(props.type as ChartType, props.direction)
}, [props.type, props.direction, setChartOptions])

useEffect(() => {
const updateData = () => {
const dataToSet = setChartData(
const chartData: ChartData | undefined = useMemo(() => {
return (
setChartData(
props.chartMethodType,
props.data?.activity,
props.data?.article,
Expand All @@ -31,19 +29,25 @@ export const NucEntityChart: React.FC<NucEntityChartInterface> = (props) => {
props.data?.technology,
props.data?.user,
props.example
)

if (dataToSet) {
setChartDataState(dataToSet)
}
}

updateData()
}, [props.chartMethodType, props.example, props.data, setChartData])
) ?? undefined
)
}, [
props.chartMethodType,
props.data?.activity,
props.data?.article,
props.data?.contact,
props.data?.file,
props.data?.money,
props.data?.question,
props.data?.technology,
props.data?.user,
props.example,
setChartData,
])

return (
<AdChart
data={chartData ?? undefined}
data={chartData}
options={chartOptions}
type={props.type}
chartMethodType={props.chartMethodType}
Expand Down
4 changes: 2 additions & 2 deletions modules/nuc_dialog/types/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import type {
} from './functions'

export interface NucDialogInterface extends DialogInterface {
entity?: ObjectType
action?: ActionType
entity?: AdTypeType
action?: ActionType | 'share'
title?: string
fields?: Array<{
name: string
Expand Down
11 changes: 11 additions & 0 deletions modules/nuc_entities_structural/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# <img src="https://nucleify.io/favicon.ico" width="17" height="17" /> &nbsp; nuc_entities_structural

Module for all structural entities in Nucleify.

<br>

<h2> &nbsp; <img src="https://nucleify.io/img/technologies/github.svg" width="25"> &nbsp; Contributors </h2> <br>

<a href="https://github.com/SzymCode" target="_blank"><img src="https://nucleify.io/img/contributors/szymcode.svg" width="30" height="30" /></a>
<a href="https://github.com/kbloski" target="_blank"><img src="https://nucleify.io/img/contributors/kbloski.svg" width="30" height="30" /></a>
<a href="https://github.com/kbujak09" target="_blank"><img src="https://nucleify.io/img/contributors/kbujak09.svg" width="30" height="30" /></a>
24 changes: 24 additions & 0 deletions modules/nuc_entities_structural/app/Contracts/QuestionContract.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

namespace App\Contracts;

interface QuestionContract
{
public function getId(): int;

public function getIndex(): int;

public function getContent(): string;

public function getAnswer(): string;

public function getCategory(): ?string;

public function getOnSite(): bool;

public function getDisplay(): bool;

public function getCreatedAt(): string;

public function getUpdatedAt(): string;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

namespace App\Contracts;

interface TechnologyContract
{
public function getId(): int;

public function getLabel(): string;

public function getDescription(): ?string;

public function getHref(): string;

public function getSrc(): string;

public function getCategory(): ?string;

public function getDisplay(): bool;

public function getCreatedAt(): string;

public function getUpdatedAt(): string;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
<?php

namespace App\Http\Controllers;

use App\Http\Requests\Question\PostRequest;
use App\Http\Requests\Question\PutRequest;
use App\Models\Question;
use App\Services\QuestionService;
use Exception;
use Illuminate\Contracts\Support\Renderable;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;

class QuestionController extends Controller
{
private QuestionService $service;

public function __construct(QuestionService $service)
{
$this->service = $service;
}

/**
* Show the application dashboard.
*/
public function render(): Renderable
{
return view('questions');
}

public function index(Request $request): JsonResponse
{
try {
$result = $this->service->index($request);

return response()->json($result);
} catch (Exception $e) {
return response()->json(['error' => $e->getMessage()], 500);
}
}

public function countByCreatedLastWeek(Request $request): JsonResponse
{
try {
$result = $this->service->countByCreatedLastWeek($request);

return response()->json($result);
} catch (Exception $e) {
return response()->json(['error' => $e->getMessage()], 500);
}
}

public function getByCategory(string $category): JsonResponse
{
try {
$result = $this->service->getByCategory($category);

return response()->json($result);
} catch (Exception $e) {
return response()->json(['error' => $e->getMessage()], 500);
}
}

public function getSiteQuestions(string $site): JsonResponse
{
try {
$result = $this->service->getSiteQuestions($site);

return response()->json($result);
} catch (Exception $e) {
return response()->json(['error' => $e->getMessage()], 500);
}
}

public function getSiteQuestionsByLang(string $site, string $lang): JsonResponse
{
try {
$result = $this->service->getSiteQuestionsByLang($site, $lang);

return response()->json($result);
} catch (Exception $e) {
return response()->json(['error' => $e->getMessage()], 500);
}
}

public function show($id): JsonResponse
{
try {
$result = $this->service->show($id);

return response()->json($result);
} catch (Exception $e) {
return response()->json(['error' => $e->getMessage()], 500);
}
}

public function store(PostRequest $request): JsonResponse
{
try {
$input = $request->validated();
$result = $this->service->create($input);

return response()->json([
$result,
'message' => 'Successfully created: ' . $result['content'] . ' question',
]);
} catch (Exception $e) {
return response()->json(['error' => $e->getMessage()], 500);
}
}

public function update(PutRequest $request, $id): JsonResponse
{
try {
$input = $request->validated();
$result = $this->service->update($id, $input);

return response()->json([
$result,
'message' => 'Successfully updated: ' . $result['content'] . ' question',
]);
} catch (Exception $e) {
return response()->json(['error' => $e->getMessage()], 500);
}
}

public function destroy($id): JsonResponse
{
$result = Question::findOrFail($id);

try {
$this->service->delete($id);

return response()->json([
'deleted' => true,
'message' => 'Successfully deleted: ' . $result->getContent() . ' question',
]);
} catch (Exception $e) {
return response()->json(['error' => $e->getMessage()], 500);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

namespace App\Http\Controllers;

use Illuminate\Contracts\Support\Renderable;

class StructuralController extends Controller
{
/**
* Render the view for the specified structural.
*/
public function renderStructural(string $structural): Renderable
{
$viewName = 'structural.' . $structural;

if (!view()->exists($viewName)) {
abort(404, 'View not found.');
}

return view($viewName);
}
}
Loading