Compare commits
2 Commits
0fae625913
...
143e3513da
Author | SHA1 | Date | |
---|---|---|---|
143e3513da | |||
69ab5c0002 |
@ -66,11 +66,11 @@
|
|||||||
],
|
],
|
||||||
"prettier/prettier": [
|
"prettier/prettier": [
|
||||||
"error",
|
"error",
|
||||||
{},
|
|
||||||
{
|
{
|
||||||
"usePrettierrc": true,
|
"usePrettierrc": true,
|
||||||
"endOfLine": "auto"
|
"singleQuote": true
|
||||||
}
|
},
|
||||||
|
{}
|
||||||
],
|
],
|
||||||
"jest/valid-title": "off",
|
"jest/valid-title": "off",
|
||||||
"react/button-has-type": "off",
|
"react/button-has-type": "off",
|
||||||
|
@ -1 +1 @@
|
|||||||
import "@testing-library/jest-dom";
|
import '@testing-library/jest-dom';
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
import Places from "../entity/placeEntity";
|
import Places from '../entity/placeEntity';
|
||||||
|
|
||||||
class PlacesModel {
|
class PlacesModel {
|
||||||
private placesList: Places[];
|
private placesList: Places[];
|
||||||
|
|
||||||
private modelTitle = "places";
|
private modelTitle = 'places';
|
||||||
|
|
||||||
constructor(data: Places[]) {
|
constructor(data: Places[]) {
|
||||||
this.placesList = data;
|
this.placesList = data;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import PlacesModel from "../../../common/model/placesModel";
|
import PlacesModel from '../../../common/model/placesModel';
|
||||||
import getPlacesRO from "../response-object/getPlacesRO";
|
import getPlacesRO from '../response-object/getPlacesRO';
|
||||||
import { GetPlacesResponse } from "../response-object/protocols";
|
import { GetPlacesResponse } from '../response-object/protocols';
|
||||||
|
|
||||||
const getPlacesRepo = async (httpHandler: () => Promise<GetPlacesResponse>) => {
|
const getPlacesRepo = async (httpHandler: () => Promise<GetPlacesResponse>) => {
|
||||||
// call httpHandler
|
// call httpHandler
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import PlacesModel from "../../../common/model/placesModel";
|
import PlacesModel from '../../../common/model/placesModel';
|
||||||
|
|
||||||
type IGetPlacesRepo = () => Promise<PlacesModel>;
|
type IGetPlacesRepo = () => Promise<PlacesModel>;
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* eslint-disable no-underscore-dangle */
|
/* eslint-disable no-underscore-dangle */
|
||||||
import { GetPlacesRO, GetPlacesResponse } from "./protocols";
|
import { GetPlacesRO, GetPlacesResponse } from './protocols';
|
||||||
|
|
||||||
const getPlacesRO = (placesResponse: GetPlacesResponse): GetPlacesRO => {
|
const getPlacesRO = (placesResponse: GetPlacesResponse): GetPlacesRO => {
|
||||||
return placesResponse.map((placeResponse) => {
|
return placesResponse.map((placeResponse) => {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import Places from "../../../common/entity/placeEntity";
|
import Places from '../../../common/entity/placeEntity';
|
||||||
|
|
||||||
export type GetPlacesResponse = {
|
export type GetPlacesResponse = {
|
||||||
_id: string;
|
_id: string;
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
import getPlaces from "./infra/getPlacesInfra";
|
import getPlaces from './infra/getPlacesInfra';
|
||||||
|
|
||||||
export default getPlaces;
|
export default getPlaces;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import getPlacesRepo from "../data/repository/GetPlacesRepo";
|
import getPlacesRepo from '../data/repository/GetPlacesRepo';
|
||||||
import IGetPlacesRepo from "../data/repository/IGetPlacesRepo";
|
import IGetPlacesRepo from '../data/repository/IGetPlacesRepo';
|
||||||
import GettingPlacesUsecase from "../usecase/getPlaceUsecase";
|
import GettingPlacesUsecase from '../usecase/getPlaceUsecase';
|
||||||
import { IgetPlacesInfra, getPlacesReturnType } from "./protocols";
|
import { IgetPlacesInfra, getPlacesReturnType } from './protocols';
|
||||||
|
|
||||||
const getPlaces = ({ httpHandler }: IgetPlacesInfra): getPlacesReturnType => {
|
const getPlaces = ({ httpHandler }: IgetPlacesInfra): getPlacesReturnType => {
|
||||||
// get httpHandler
|
// get httpHandler
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import PlacesModel from "../../common/model/placesModel";
|
import PlacesModel from '../../common/model/placesModel';
|
||||||
import { GetPlacesResponse } from "../data/response-object/protocols";
|
import { GetPlacesResponse } from '../data/response-object/protocols';
|
||||||
|
|
||||||
export interface IgetPlacesInfra {
|
export interface IgetPlacesInfra {
|
||||||
httpHandler: () => Promise<GetPlacesResponse>;
|
httpHandler: () => Promise<GetPlacesResponse>;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { getPlacesReturnType, type IgetPlacesInfra } from "./infra/protocols";
|
import { getPlacesReturnType, type IgetPlacesInfra } from './infra/protocols';
|
||||||
|
|
||||||
export default IgetPlacesInfra;
|
export default IgetPlacesInfra;
|
||||||
|
|
||||||
|
@ -1,26 +1,24 @@
|
|||||||
import PlacesModel from "../../../common/model/placesModel";
|
import PlacesModel from '../../../common/model/placesModel';
|
||||||
import IGetPlacesRepo from "../../data/repository/IGetPlacesRepo";
|
import IGetPlacesRepo from '../../data/repository/IGetPlacesRepo';
|
||||||
import { GetPlacesRO } from "../../data/response-object/protocols";
|
import { GetPlacesRO } from '../../data/response-object/protocols';
|
||||||
import GettingPlacesUsecase from "../getPlaceUsecase";
|
import GettingPlacesUsecase from '../getPlaceUsecase';
|
||||||
|
|
||||||
const mockedRO: GetPlacesRO = {
|
const mockedRO: GetPlacesRO = {
|
||||||
availableServices: [""],
|
availableServices: [''],
|
||||||
createdAt: "createdAt",
|
createdAt: 'createdAt',
|
||||||
id: "id",
|
id: 'id',
|
||||||
name: "name",
|
name: 'name',
|
||||||
parentId: null,
|
parentId: null,
|
||||||
placeType: "continent",
|
placeType: 'continent',
|
||||||
updatedAt: "updatedTime",
|
updatedAt: 'updatedTime',
|
||||||
qr: null,
|
qr: null,
|
||||||
};
|
};
|
||||||
|
|
||||||
const model = new PlacesModel(mockedRO);
|
const model = new PlacesModel(mockedRO);
|
||||||
const mockedRepo: IGetPlacesRepo = jest
|
const mockedRepo: IGetPlacesRepo = jest.fn().mockImplementation(async () => model);
|
||||||
.fn()
|
|
||||||
.mockImplementation(async () => model);
|
|
||||||
|
|
||||||
describe("getting places usecase tests", () => {
|
describe('getting places usecase tests', () => {
|
||||||
it("call repository on execute usecase", async () => {
|
it('call repository on execute usecase', async () => {
|
||||||
const usecase = new GettingPlacesUsecase(mockedRepo);
|
const usecase = new GettingPlacesUsecase(mockedRepo);
|
||||||
await usecase.execute();
|
await usecase.execute();
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import PlacesModel from "../../common/model/placesModel";
|
import PlacesModel from '../../common/model/placesModel';
|
||||||
import IGetPlacesRepo from "../data/repository/IGetPlacesRepo";
|
import IGetPlacesRepo from '../data/repository/IGetPlacesRepo';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* this usecase is responsible for calling the repo and returning the places data from the repository
|
* this usecase is responsible for calling the repo and returning the places data from the repository
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
import Users from "../../entity/entity";
|
import Users from '../../entity/entity';
|
||||||
|
|
||||||
class UsersModel {
|
class UsersModel {
|
||||||
private usersList: Users[];
|
private usersList: Users[];
|
||||||
|
|
||||||
private modelTitle = "users";
|
private modelTitle = 'users';
|
||||||
|
|
||||||
constructor(data: Users[]) {
|
constructor(data: Users[]) {
|
||||||
this.usersList = data;
|
this.usersList = data;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import UsersModel from "../../../common/data/model/usersModel";
|
import UsersModel from '../../../common/data/model/usersModel';
|
||||||
|
|
||||||
type IGetUsersRepo = () => Promise<UsersModel>;
|
type IGetUsersRepo = () => Promise<UsersModel>;
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import UsersModel from "../../../common/data/model/usersModel";
|
import UsersModel from '../../../common/data/model/usersModel';
|
||||||
import getUsersResponseObject from "../response-object/usersRO";
|
import getUsersResponseObject from '../response-object/usersRO';
|
||||||
import { GetUsersResponse } from "../response-object/protocols";
|
import { GetUsersResponse } from '../response-object/protocols';
|
||||||
|
|
||||||
const getUsersRepo = async (httpHandler: () => Promise<GetUsersResponse>) => {
|
const getUsersRepo = async (httpHandler: () => Promise<GetUsersResponse>) => {
|
||||||
// call httpHandler
|
// call httpHandler
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/* eslint-disable no-underscore-dangle */
|
/* eslint-disable no-underscore-dangle */
|
||||||
import Users from "../../../common/entity/entity";
|
import Users from '../../../common/entity/entity';
|
||||||
import { GetUsersResponse } from "./protocols";
|
import { GetUsersResponse } from './protocols';
|
||||||
|
|
||||||
const getUsersResponseObject = (apiResponse: GetUsersResponse): Users[] => {
|
const getUsersResponseObject = (apiResponse: GetUsersResponse): Users[] => {
|
||||||
return apiResponse.map((userItem) => {
|
return apiResponse.map((userItem) => {
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
import getUsers from "./infra/getUsersInfra";
|
import getUsers from './infra/getUsersInfra';
|
||||||
|
|
||||||
export default getUsers;
|
export default getUsers;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import IGetUsersRepo from "../data/repository/IGetUserRepo";
|
import IGetUsersRepo from '../data/repository/IGetUserRepo';
|
||||||
import getUsersRepo from "../data/repository/getUserRepo";
|
import getUsersRepo from '../data/repository/getUserRepo';
|
||||||
import GettingUsersUsecase from "../usecase/getUsersUsecase";
|
import GettingUsersUsecase from '../usecase/getUsersUsecase';
|
||||||
import { IgetusersInfra, getusersReturnType } from "./protocols";
|
import { IgetusersInfra, getusersReturnType } from './protocols';
|
||||||
|
|
||||||
const getUsers = ({ httpHandler }: IgetusersInfra): getusersReturnType => {
|
const getUsers = ({ httpHandler }: IgetusersInfra): getusersReturnType => {
|
||||||
// get httpHandler
|
// get httpHandler
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import UsersModel from "../../common/data/model/usersModel";
|
import UsersModel from '../../common/data/model/usersModel';
|
||||||
import { GetUsersResponse } from "../data/response-object/protocols";
|
import { GetUsersResponse } from '../data/response-object/protocols';
|
||||||
|
|
||||||
export interface IgetusersInfra {
|
export interface IgetUsersInfra {
|
||||||
httpHandler: () => Promise<GetUsersResponse>;
|
httpHandler: () => Promise<GetUsersResponse>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type getusersReturnType = () => Promise<UsersModel>;
|
export type getUsersReturnType = () => Promise<UsersModel>;
|
||||||
|
5
src/business-logic/core/users/get-users/ports.ts
Normal file
5
src/business-logic/core/users/get-users/ports.ts
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
import { getUsersReturnType, type IgetUsersInfra } from './infra/protocols';
|
||||||
|
|
||||||
|
export default IgetUsersInfra;
|
||||||
|
|
||||||
|
export type getUsersReturnPort = getUsersReturnType;
|
@ -1,5 +1,5 @@
|
|||||||
import UsersModel from "../../common/data/model/usersModel";
|
import UsersModel from '../../common/data/model/usersModel';
|
||||||
import IGetUsersRepo from "../data/repository/IGetUserRepo";
|
import IGetUsersRepo from '../data/repository/IGetUserRepo';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* this usecase is responsible for calling the repo and returning the users data from the repository
|
* this usecase is responsible for calling the repo and returning the users data from the repository
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
import { GetPlacesResponse } from "~/business-logic/core/places/get-places/data/response-object/protocols";
|
import { GetPlacesResponse } from '~/business-logic/core/places/get-places/data/response-object/protocols';
|
||||||
import IGetPlacesPort from "~/business-logic/core/places/get-places/port";
|
import IGetPlacesPort from '~/business-logic/core/places/get-places/port';
|
||||||
import { HTTPPovider } from "~/driven/boundaries/http-boundary/httpBoundary";
|
import { HTTPPovider } from '~/driven/boundaries/http-boundary/httpBoundary';
|
||||||
import { HttpOptionsType } from "~/driven/boundaries/http-boundary/protocols";
|
import { HttpOptionsType } from '~/driven/boundaries/http-boundary/protocols';
|
||||||
import { apiUrls } from "~/driven/utils/configs/appConfig";
|
import { apiUrls } from '~/driven/utils/configs/appConfig';
|
||||||
import { getPlacesAdapterReturnType } from "./protocols";
|
import { getPlacesAdapterReturnType } from './protocols';
|
||||||
|
|
||||||
const getPlacesAdapter = (): IGetPlacesPort & getPlacesAdapterReturnType => {
|
const getPlacesAdapter = (): IGetPlacesPort & getPlacesAdapterReturnType => {
|
||||||
// url of api
|
// url of api
|
||||||
@ -11,7 +11,7 @@ const getPlacesAdapter = (): IGetPlacesPort & getPlacesAdapterReturnType => {
|
|||||||
// make the options of request
|
// make the options of request
|
||||||
const options: HttpOptionsType = {
|
const options: HttpOptionsType = {
|
||||||
url,
|
url,
|
||||||
method: "GET",
|
method: 'GET',
|
||||||
};
|
};
|
||||||
// make the httpHandler
|
// make the httpHandler
|
||||||
const httpProvider = new HTTPPovider();
|
const httpProvider = new HTTPPovider();
|
||||||
|
29
src/driven/adapters/get-users-adapter/getUsersAdapter.ts
Normal file
29
src/driven/adapters/get-users-adapter/getUsersAdapter.ts
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
import { apiUrls } from '~/driven/utils/configs/appConfig';
|
||||||
|
import { HttpOptionsType } from '~/driven/boundaries/http-boundary/protocols';
|
||||||
|
import { HTTPPovider } from '~/driven/boundaries/http-boundary/httpBoundary';
|
||||||
|
import { GetUsersResponse } from '~/business-logic/core/users/get-users/data/response-object/protocols';
|
||||||
|
import IGetUsersPort from '~/business-logic/core/users/get-users/ports';
|
||||||
|
import { getUsersAdapterReturnType } from './protocols';
|
||||||
|
|
||||||
|
const getUsersAdapter = (): IGetUsersPort & getUsersAdapterReturnType => {
|
||||||
|
// url of api
|
||||||
|
const url = apiUrls.core.getUsers;
|
||||||
|
// make the options of request
|
||||||
|
const options: HttpOptionsType = {
|
||||||
|
url,
|
||||||
|
method: 'GET',
|
||||||
|
};
|
||||||
|
// make the httpHandler
|
||||||
|
const httpProvider = new HTTPPovider();
|
||||||
|
|
||||||
|
const httpHandler = async () =>
|
||||||
|
httpProvider.request<GetUsersResponse>(options);
|
||||||
|
|
||||||
|
// return the method
|
||||||
|
return {
|
||||||
|
httpHandler,
|
||||||
|
url,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
export default getUsersAdapter;
|
3
src/driven/adapters/get-users-adapter/protocols.ts
Normal file
3
src/driven/adapters/get-users-adapter/protocols.ts
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
export type getUsersAdapterReturnType = {
|
||||||
|
url: string;
|
||||||
|
};
|
@ -1,7 +1,7 @@
|
|||||||
import axios from "axios";
|
import axios from 'axios';
|
||||||
import { staticMessages } from "~/driven/utils/constants/staticMessages";
|
import { staticMessages } from '~/driven/utils/constants/staticMessages';
|
||||||
import { ApiGlobalResponseObject } from "~/driven/utils/protocols/serviceProtocols";
|
import { ApiGlobalResponseObject } from '~/driven/utils/protocols/serviceProtocols';
|
||||||
import { HttpOptionsType } from "./protocols";
|
import { HttpOptionsType } from './protocols';
|
||||||
|
|
||||||
export class HTTPPovider {
|
export class HTTPPovider {
|
||||||
async request<R>(customOptions: HttpOptionsType) {
|
async request<R>(customOptions: HttpOptionsType) {
|
||||||
@ -9,8 +9,8 @@ export class HTTPPovider {
|
|||||||
...customOptions,
|
...customOptions,
|
||||||
headers: {
|
headers: {
|
||||||
...customOptions.headers,
|
...customOptions.headers,
|
||||||
mode: "cors",
|
mode: 'cors',
|
||||||
credentials: "include",
|
credentials: 'include',
|
||||||
Authorization: `Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICI4NXh0WnA5eThxVDBXVDkwUFpuUkRja3N4LWw0clVyM0tHQW5JSU9DckJNIn0.eyJleHAiOjE2ODQ2Njc2MTEsImlhdCI6MTY4NDU4MTIxMSwianRpIjoiN2VlNzQ5ZTMtMjdhOC00ZTc1LWE4MTAtOTU0MGY5NDdmNjlkIiwiaXNzIjoiaHR0cDovL2xvY2FsaG9zdDo4MDgwL3JlYWxtcy9kaXBhbF9kZXYiLCJhdWQiOiJhY2NvdW50Iiwic3ViIjoiY2RmYzY3YzQtZGJkOC00NGVhLWI0OWEtYjQ3MjZhMzNmOTAxIiwidHlwIjoiQmVhcmVyIiwiYXpwIjoiY29tZm9ydGVjaCIsInNlc3Npb25fc3RhdGUiOiI3YTFlZDk2OS1lNWY2LTQzZTctOThhMy05OGQ3Zjk3YWM1NDgiLCJyZWFsbV9hY2Nlc3MiOnsicm9sZXMiOlsiZGVmYXVsdC1yb2xlcy1tYXN0ZXIiLCJvZmZsaW5lX2FjY2VzcyIsInVtYV9hdXRob3JpemF0aW9uIl19LCJyZXNvdXJjZV9hY2Nlc3MiOnsiY29tZm9ydGVjaCI6eyJyb2xlcyI6WyJ1c2VyIiwib3BlcmF0b3IiXX0sImFjY291bnQiOnsicm9sZXMiOlsibWFuYWdlLWFjY291bnQiLCJtYW5hZ2UtYWNjb3VudC1saW5rcyIsInZpZXctcHJvZmlsZSJdfX0sInNjb3BlIjoiZW1haWwgcHJvZmlsZSIsInNpZCI6IjdhMWVkOTY5LWU1ZjYtNDNlNy05OGEzLTk4ZDdmOTdhYzU0OCIsImVtYWlsX3ZlcmlmaWVkIjpmYWxzZSwicHJlZmVycmVkX3VzZXJuYW1lIjoiKzc3Nzc3Nzc3Nzc3In0.qp1GetUEy2LOZWy6Aaiwf_0d0U8wBqXJQhhuSgIO4RkkEgUnwYZ5fFupkp1iTXZMpqWAsmbRp-C0Z8nYT8Hor6XjnE73XwAVVY0Jbx6HSxtcTBOqo2IT0SmVm6z-TFpgYnErHiFZZgsqP4KYkc12xlQH4SrpN-h-oXN4ZtwuOIG65ixt2yKC-8KTyZzfZGa_8llAtnthQBtxX00MdivFpRP-NU1KfCtJqHSTKn40RNs-Nt8Gi_x7vWv9OKD8h-IIp27oOCJZNyL4aa237cuPw9IWbdiDuUAOgxkPw30i9LIDPA70GvdpRKWgLq0-itcT_hpf2RguuALDafaqoGgoGQ`,
|
Authorization: `Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICI4NXh0WnA5eThxVDBXVDkwUFpuUkRja3N4LWw0clVyM0tHQW5JSU9DckJNIn0.eyJleHAiOjE2ODQ2Njc2MTEsImlhdCI6MTY4NDU4MTIxMSwianRpIjoiN2VlNzQ5ZTMtMjdhOC00ZTc1LWE4MTAtOTU0MGY5NDdmNjlkIiwiaXNzIjoiaHR0cDovL2xvY2FsaG9zdDo4MDgwL3JlYWxtcy9kaXBhbF9kZXYiLCJhdWQiOiJhY2NvdW50Iiwic3ViIjoiY2RmYzY3YzQtZGJkOC00NGVhLWI0OWEtYjQ3MjZhMzNmOTAxIiwidHlwIjoiQmVhcmVyIiwiYXpwIjoiY29tZm9ydGVjaCIsInNlc3Npb25fc3RhdGUiOiI3YTFlZDk2OS1lNWY2LTQzZTctOThhMy05OGQ3Zjk3YWM1NDgiLCJyZWFsbV9hY2Nlc3MiOnsicm9sZXMiOlsiZGVmYXVsdC1yb2xlcy1tYXN0ZXIiLCJvZmZsaW5lX2FjY2VzcyIsInVtYV9hdXRob3JpemF0aW9uIl19LCJyZXNvdXJjZV9hY2Nlc3MiOnsiY29tZm9ydGVjaCI6eyJyb2xlcyI6WyJ1c2VyIiwib3BlcmF0b3IiXX0sImFjY291bnQiOnsicm9sZXMiOlsibWFuYWdlLWFjY291bnQiLCJtYW5hZ2UtYWNjb3VudC1saW5rcyIsInZpZXctcHJvZmlsZSJdfX0sInNjb3BlIjoiZW1haWwgcHJvZmlsZSIsInNpZCI6IjdhMWVkOTY5LWU1ZjYtNDNlNy05OGEzLTk4ZDdmOTdhYzU0OCIsImVtYWlsX3ZlcmlmaWVkIjpmYWxzZSwicHJlZmVycmVkX3VzZXJuYW1lIjoiKzc3Nzc3Nzc3Nzc3In0.qp1GetUEy2LOZWy6Aaiwf_0d0U8wBqXJQhhuSgIO4RkkEgUnwYZ5fFupkp1iTXZMpqWAsmbRp-C0Z8nYT8Hor6XjnE73XwAVVY0Jbx6HSxtcTBOqo2IT0SmVm6z-TFpgYnErHiFZZgsqP4KYkc12xlQH4SrpN-h-oXN4ZtwuOIG65ixt2yKC-8KTyZzfZGa_8llAtnthQBtxX00MdivFpRP-NU1KfCtJqHSTKn40RNs-Nt8Gi_x7vWv9OKD8h-IIp27oOCJZNyL4aa237cuPw9IWbdiDuUAOgxkPw30i9LIDPA70GvdpRKWgLq0-itcT_hpf2RguuALDafaqoGgoGQ`,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
import { AxiosRequestConfig } from "axios";
|
import { AxiosRequestConfig } from 'axios';
|
||||||
|
|
||||||
export type HttpOptionsType = AxiosRequestConfig;
|
export type HttpOptionsType = AxiosRequestConfig;
|
||||||
|
@ -1,9 +1,4 @@
|
|||||||
import {
|
import { NavigateFunction, Outlet, useLocation, useNavigate } from 'react-router-dom';
|
||||||
NavigateFunction,
|
|
||||||
Outlet,
|
|
||||||
useLocation,
|
|
||||||
useNavigate,
|
|
||||||
} from "react-router-dom";
|
|
||||||
|
|
||||||
class RouterBoundary {
|
class RouterBoundary {
|
||||||
outletRoute = () => <Outlet />;
|
outletRoute = () => <Outlet />;
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
import StateManagementService from "./stateManagementService";
|
import StateManagementService from './stateManagementService';
|
||||||
|
|
||||||
export default StateManagementService;
|
export default StateManagementService;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import StateManagementProvider from "./stateManagementProvider";
|
import StateManagementProvider from './stateManagementProvider';
|
||||||
import SwrBoundary from "./swrBoundary";
|
import SwrBoundary from './swrBoundary';
|
||||||
|
|
||||||
export default class StateManagementService implements StateManagementProvider {
|
export default class StateManagementService implements StateManagementProvider {
|
||||||
private provider: StateManagementProvider;
|
private provider: StateManagementProvider;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import useSwr from "swr";
|
import useSwr from 'swr';
|
||||||
import StateManagementProvider from "./stateManagementProvider";
|
import StateManagementProvider from './stateManagementProvider';
|
||||||
|
|
||||||
export default class SwrBoundary implements StateManagementProvider {
|
export default class SwrBoundary implements StateManagementProvider {
|
||||||
useGetQuery<DataType>(
|
useGetQuery<DataType>(
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import React from "react";
|
import React from 'react';
|
||||||
|
|
||||||
interface IPrimaryButtonProps {
|
interface IPrimaryButtonProps {
|
||||||
title: string;
|
title: string;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import React from "react";
|
import React from 'react';
|
||||||
|
|
||||||
interface ISimpleInput {
|
interface ISimpleInput {
|
||||||
title: string;
|
title: string;
|
||||||
@ -9,13 +9,10 @@ export default function SimpleInput(props: ISimpleInput) {
|
|||||||
const { title, className } = props;
|
const { title, className } = props;
|
||||||
return (
|
return (
|
||||||
<div className={`flex flex-col ${className}`}>
|
<div className={`flex flex-col ${className}`}>
|
||||||
<label className="mb-1 text-txt-second text-xs" htmlFor={title}>
|
<label className='mb-1 text-txt-second text-xs' htmlFor={title}>
|
||||||
{title}
|
{title}
|
||||||
</label>
|
</label>
|
||||||
<input
|
<input className='bg-bg-gray h-11 rounded-lg focus:outline-0 px-2 text-txt-medium' id={title} />
|
||||||
className="bg-bg-gray h-11 rounded-lg focus:outline-0 px-2 text-txt-medium"
|
|
||||||
id={title}
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import React from "react";
|
import React from 'react';
|
||||||
import style from "./style.module.css";
|
import style from './style.module.css';
|
||||||
|
|
||||||
export default function Loading() {
|
export default function Loading() {
|
||||||
return (
|
return (
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import React from "react";
|
import React from 'react';
|
||||||
|
|
||||||
interface IPageTitleProps {
|
interface IPageTitleProps {
|
||||||
title: string;
|
title: string;
|
||||||
@ -7,11 +7,5 @@ interface IPageTitleProps {
|
|||||||
|
|
||||||
export default function PageTitle(props: IPageTitleProps) {
|
export default function PageTitle(props: IPageTitleProps) {
|
||||||
const { title, className } = props;
|
const { title, className } = props;
|
||||||
return (
|
return <div className={`w-full shadow-sm shadow-txt-light font-semibold ${className}`}>{title}</div>;
|
||||||
<div
|
|
||||||
className={`w-full shadow-sm shadow-txt-light font-semibold ${className}`}
|
|
||||||
>
|
|
||||||
{title}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
import { icons } from "../constants/assertUrls";
|
import { icons } from '../constants/assertUrls';
|
||||||
import { ENVs } from "../constants/envs";
|
import { ENVs } from '../constants/envs';
|
||||||
import { staticMessages } from "../constants/staticMessages";
|
import { staticMessages } from '../constants/staticMessages';
|
||||||
|
|
||||||
export const appConfig = {};
|
export const appConfig = {};
|
||||||
|
|
||||||
export const routes = {
|
export const routes = {
|
||||||
usersList: "/",
|
usersList: '/',
|
||||||
createUser: "/create-user",
|
createUser: '/create-user',
|
||||||
};
|
};
|
||||||
|
|
||||||
export const routesData = {
|
export const routesData = {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
const baseAssetsUrl = "assets/";
|
const baseAssetsUrl = 'assets/';
|
||||||
const baseIconsUrl = `${baseAssetsUrl}icons/`;
|
const baseIconsUrl = `${baseAssetsUrl}icons/`;
|
||||||
export const icons = {
|
export const icons = {
|
||||||
logo: `${baseIconsUrl}logo.svg`,
|
logo: `${baseIconsUrl}logo.svg`,
|
||||||
|
@ -1,24 +1,24 @@
|
|||||||
export const staticMessages = {
|
export const staticMessages = {
|
||||||
global: {
|
global: {
|
||||||
errors: {
|
errors: {
|
||||||
input: "please fill all inputs correctly",
|
input: 'please fill all inputs correctly',
|
||||||
},
|
},
|
||||||
users: "Users",
|
users: 'Users',
|
||||||
submit: "Submit",
|
submit: 'Submit',
|
||||||
fistname: "Firstname",
|
fistname: 'Firstname',
|
||||||
lastname: "Lastname",
|
lastname: 'Lastname',
|
||||||
place_id: "Place id",
|
place_id: 'Place id',
|
||||||
title: "title",
|
title: 'title',
|
||||||
status: "Status",
|
status: 'Status',
|
||||||
address: "Address",
|
address: 'Address',
|
||||||
qrCode: "qrCode",
|
qrCode: 'qrCode',
|
||||||
createUser: "Create user",
|
createUser: 'Create user',
|
||||||
phoneNumber: "Phone Number",
|
phoneNumber: 'Phone Number',
|
||||||
},
|
},
|
||||||
service: {
|
service: {
|
||||||
errors: {
|
errors: {
|
||||||
500: "server not respond please try again later!",
|
500: 'server not respond please try again later!',
|
||||||
401: "Authentication error!",
|
401: 'Authentication error!',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
|
import StateManagementService from '~/driven/boundaries/state-management';
|
||||||
import {
|
import {
|
||||||
errorHandlingStateTypes,
|
errorHandlingStateTypes,
|
||||||
UIErrorHandling,
|
UIErrorHandling,
|
||||||
} from "./protocols/globalHelpersProtocols";
|
} from './protocols/globalHelpersProtocols';
|
||||||
|
|
||||||
export const UIErrorHandlingFactory = <DATA_RESPONSE>({
|
export const UIErrorHandlingFactory = <DATA_RESPONSE>({
|
||||||
state,
|
state,
|
||||||
@ -16,3 +17,14 @@ export const UIErrorHandlingFactory = <DATA_RESPONSE>({
|
|||||||
message,
|
message,
|
||||||
state,
|
state,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export const prepareStateManagementForVM = <ReturnType>(
|
||||||
|
apiUrl: string,
|
||||||
|
model: () => Promise<ReturnType>
|
||||||
|
) => {
|
||||||
|
const stateManagement = StateManagementService.swr();
|
||||||
|
|
||||||
|
const useGetPlacesList = () => stateManagement.useGetQuery(apiUrl, model);
|
||||||
|
|
||||||
|
return useGetPlacesList;
|
||||||
|
};
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
export enum errorHandlingStateTypes {
|
export enum errorHandlingStateTypes {
|
||||||
error = "error",
|
error = 'error',
|
||||||
warning = "warning",
|
warning = 'warning',
|
||||||
success = "success",
|
success = 'success',
|
||||||
}
|
}
|
||||||
|
|
||||||
export type UIErrorHandling<DATA_RESPONSE> = {
|
export type UIErrorHandling<DATA_RESPONSE> = {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
export type RequestMethods = "get" | "post" | "put" | "delete";
|
export type RequestMethods = 'get' | 'post' | 'put' | 'delete';
|
||||||
|
|
||||||
export type ApiGlobalResponseObject<DataType> = {
|
export type ApiGlobalResponseObject<DataType> = {
|
||||||
type: "Success" | "client Error" | string;
|
type: 'Success' | 'client Error' | string;
|
||||||
status: 200 | 400 | 401 | 500 | number;
|
status: 200 | 400 | 401 | 500 | number;
|
||||||
message: string;
|
message: string;
|
||||||
description: string;
|
description: string;
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
import TableRow from "./infra/TableRowInfra";
|
import TableRow from './infra/TableRowInfra';
|
||||||
|
|
||||||
export default TableRow;
|
export default TableRow;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import React from "react";
|
import React from 'react';
|
||||||
import useTableRowVM from "../viewmodel/tableRowVM";
|
import useTableRowVM from '../viewmodel/tableRowVM';
|
||||||
import TableRowView from "../view/TableRow";
|
import TableRowView from '../view/TableRow';
|
||||||
import { ITableRowInfra } from "./protocols";
|
import { ITableRowInfra } from './protocols';
|
||||||
|
|
||||||
export default function TableRow(props: ITableRowInfra) {
|
export default function TableRow(props: ITableRowInfra) {
|
||||||
const { rowData, selectedRowId, setSelectedRowId } = props;
|
const { rowData, selectedRowId, setSelectedRowId } = props;
|
||||||
@ -9,11 +9,5 @@ export default function TableRow(props: ITableRowInfra) {
|
|||||||
|
|
||||||
const { isRowSelected } = useTableRowVM({ selectedRowId, rowId });
|
const { isRowSelected } = useTableRowVM({ selectedRowId, rowId });
|
||||||
|
|
||||||
return (
|
return <TableRowView isSelected={isRowSelected} rowData={rowData} setSelectedRowId={setSelectedRowId} />;
|
||||||
<TableRowView
|
|
||||||
isSelected={isRowSelected}
|
|
||||||
rowData={rowData}
|
|
||||||
setSelectedRowId={setSelectedRowId}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
@ -1,19 +1,12 @@
|
|||||||
import React from "react";
|
import React from 'react';
|
||||||
import RowItem from "./table-row-item/view/RowItem";
|
import RowItem from './table-row-item/view/RowItem';
|
||||||
import { ITableRowProps } from "./protocols";
|
import { ITableRowProps } from './protocols';
|
||||||
|
|
||||||
export default function TableRowView(props: ITableRowProps) {
|
export default function TableRowView(props: ITableRowProps) {
|
||||||
const { isSelected, setSelectedRowId, rowData } = props;
|
const { isSelected, setSelectedRowId, rowData } = props;
|
||||||
const { rowId, rowItemsTitle } = rowData;
|
const { rowId, rowItemsTitle } = rowData;
|
||||||
const columns = rowItemsTitle.map((rowItemTitle, index) => {
|
const columns = rowItemsTitle.map((rowItemTitle, index) => {
|
||||||
return (
|
return <RowItem key={rowItemTitle} hasCheckbox={index === 0} isSelected={isSelected} title={rowItemTitle} />;
|
||||||
<RowItem
|
|
||||||
key={rowItemTitle}
|
|
||||||
hasCheckbox={index === 0}
|
|
||||||
isSelected={isSelected}
|
|
||||||
title={rowItemTitle}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return <tr onClick={() => setSelectedRowId(rowId)}>{columns}</tr>;
|
return <tr onClick={() => setSelectedRowId(rowId)}>{columns}</tr>;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import React from "react";
|
import React from 'react';
|
||||||
|
|
||||||
interface IRowItemProp {
|
interface IRowItemProp {
|
||||||
title: string;
|
title: string;
|
||||||
@ -9,19 +9,15 @@ interface IRowItemProp {
|
|||||||
export default function RowItem(props: IRowItemProp) {
|
export default function RowItem(props: IRowItemProp) {
|
||||||
const { title, hasCheckbox, isSelected } = props;
|
const { title, hasCheckbox, isSelected } = props;
|
||||||
return (
|
return (
|
||||||
<td className={`px-1 py-2 ${isSelected ? "bg-primary-100" : ""}`}>
|
<td className={`px-1 py-2 ${isSelected ? 'bg-primary-100' : ''}`}>
|
||||||
<div className="w-full flex">
|
<div className='w-full flex'>
|
||||||
{hasCheckbox && (
|
{hasCheckbox && (
|
||||||
<span
|
<span
|
||||||
className={`checkmak-container flex justify-center items-center mr-2 transition-all ${
|
className={`checkmak-container flex justify-center items-center mr-2 transition-all ${
|
||||||
isSelected ? "opacity-100" : "opacity-0"
|
isSelected ? 'opacity-100' : 'opacity-0'
|
||||||
}`}
|
}`}
|
||||||
>
|
>
|
||||||
<span
|
<span className={`${isSelected ? 'visible' : 'hidden'} transition-all`}>✓</span>
|
||||||
className={`${isSelected ? "visible" : "hidden"} transition-all`}
|
|
||||||
>
|
|
||||||
✓
|
|
||||||
</span>
|
|
||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
{title}
|
{title}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { IUserTableRowVM, tableRowVMReturnType } from "./protocols";
|
import { IUserTableRowVM, tableRowVMReturnType } from './protocols';
|
||||||
|
|
||||||
const useTableRowVM = (dependencies: IUserTableRowVM): tableRowVMReturnType => {
|
const useTableRowVM = (dependencies: IUserTableRowVM): tableRowVMReturnType => {
|
||||||
const { rowId, selectedRowId } = dependencies;
|
const { rowId, selectedRowId } = dependencies;
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
import CreateUser from "./infra/CreateUser";
|
import CreateUser from './infra/CreateUser';
|
||||||
|
|
||||||
export default CreateUser;
|
export default CreateUser;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import React from "react";
|
import React from 'react';
|
||||||
import CreateUserView from "../view/CreateUserView";
|
import CreateUserView from '../view/CreateUserView';
|
||||||
|
|
||||||
export default function CreateUser() {
|
export default function CreateUser() {
|
||||||
return <CreateUserView />;
|
return <CreateUserView />;
|
||||||
|
@ -1,30 +1,18 @@
|
|||||||
import React from "react";
|
import React from 'react';
|
||||||
import PrimaryButton from "~/driven/utils/components/buttons/primary-button/PrimaryButton";
|
import PrimaryButton from '~/driven/utils/components/buttons/primary-button/PrimaryButton';
|
||||||
import SimpleInput from "~/driven/utils/components/inputs/simple-input/SimpleInput";
|
import SimpleInput from '~/driven/utils/components/inputs/simple-input/SimpleInput';
|
||||||
import { staticMessages } from "~/driven/utils/constants/staticMessages";
|
import { staticMessages } from '~/driven/utils/constants/staticMessages';
|
||||||
|
|
||||||
export default function CreateUserView() {
|
export default function CreateUserView() {
|
||||||
return (
|
return (
|
||||||
<div className="px-4 my-8">
|
<div className='px-4 my-8'>
|
||||||
<div className="flex flex-wrap w-full gap-4">
|
<div className='flex flex-wrap w-full gap-4'>
|
||||||
<SimpleInput
|
<SimpleInput title={staticMessages.global.fistname} className='mb-4 w-[48%]' />
|
||||||
title={staticMessages.global.fistname}
|
<SimpleInput title={staticMessages.global.lastname} className='mb-4 w-[48%]' />
|
||||||
className="mb-4 w-[48%]"
|
<SimpleInput title={staticMessages.global.phoneNumber} className='mb-4 w-[48%]' />
|
||||||
/>
|
|
||||||
<SimpleInput
|
|
||||||
title={staticMessages.global.lastname}
|
|
||||||
className="mb-4 w-[48%]"
|
|
||||||
/>
|
|
||||||
<SimpleInput
|
|
||||||
title={staticMessages.global.phoneNumber}
|
|
||||||
className="mb-4 w-[48%]"
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
<div className="flex">
|
<div className='flex'>
|
||||||
<PrimaryButton
|
<PrimaryButton onClick={() => null} title={staticMessages.global.submit} />
|
||||||
onClick={() => null}
|
|
||||||
title={staticMessages.global.submit}
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
import PlacesList from "./infra/PlacesList";
|
import PlacesList from './infra/PlacesList';
|
||||||
|
|
||||||
export default PlacesList;
|
export default PlacesList;
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
import React from "react";
|
import React from 'react';
|
||||||
import getPlaces from "~/business-logic/core/places/get-places";
|
import getPlaces from '~/business-logic/core/places/get-places';
|
||||||
import getPlacesAdapter from "~/driven/adapters/get-places-adapter/getPlacesAdapter";
|
import getPlacesAdapter from '~/driven/adapters/get-places-adapter/getPlacesAdapter';
|
||||||
import StateManagementService from "~/driven/boundaries/state-management";
|
import PlacesModel from '~/business-logic/core/places/common/model/placesModel';
|
||||||
import PlacesModel from "~/business-logic/core/places/common/model/placesModel";
|
import { prepareStateManagementForVM } from '~/driven/utils/helpers/globalHelpers';
|
||||||
import PlacesListView from "../view/PlacesListView";
|
import PlacesListView from '../view/PlacesListView';
|
||||||
import usePlacesListVM from "../viewmodel/placesListVM";
|
import usePlacesListVM from '../viewmodel/placesListVM';
|
||||||
import placesListModel from "../model/placesListModel";
|
import placesListModel from '../model/placesListModel';
|
||||||
|
|
||||||
const prepareTheLogicForModel = () => {
|
const prepareTheLogicForModel = () => {
|
||||||
const gettingPlacesDrivenAdapter = getPlacesAdapter();
|
const gettingPlacesDrivenAdapter = getPlacesAdapter();
|
||||||
@ -14,23 +14,14 @@ const prepareTheLogicForModel = () => {
|
|||||||
return { getingPlacesLogic, url };
|
return { getingPlacesLogic, url };
|
||||||
};
|
};
|
||||||
|
|
||||||
const prepareStateManagementForVM = (
|
|
||||||
apiUrl: string,
|
|
||||||
placesModel: () => Promise<PlacesModel>
|
|
||||||
) => {
|
|
||||||
const stateManagement = StateManagementService.swr();
|
|
||||||
|
|
||||||
const useGetPlacesList = () =>
|
|
||||||
stateManagement.useGetQuery(apiUrl, placesModel);
|
|
||||||
|
|
||||||
return useGetPlacesList;
|
|
||||||
};
|
|
||||||
|
|
||||||
export default function PlacessList() {
|
export default function PlacessList() {
|
||||||
const { getingPlacesLogic, url } = prepareTheLogicForModel();
|
const { getingPlacesLogic, url } = prepareTheLogicForModel();
|
||||||
const placesModel = async () => await placesListModel(getingPlacesLogic);
|
const placesModel = async () => await placesListModel(getingPlacesLogic);
|
||||||
|
|
||||||
const useGetPlacesList = prepareStateManagementForVM(url, placesModel);
|
const useGetPlacesList = prepareStateManagementForVM<PlacesModel>(
|
||||||
|
url,
|
||||||
|
placesModel
|
||||||
|
);
|
||||||
const { selectedRowId, setSelectedRowId, placesData } = usePlacesListVM({
|
const { selectedRowId, setSelectedRowId, placesData } = usePlacesListVM({
|
||||||
useGetPlacesList,
|
useGetPlacesList,
|
||||||
});
|
});
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { getPlacesModel } from "./protocols";
|
import { getPlacesModel } from './protocols';
|
||||||
|
|
||||||
const placesListModel: getPlacesModel = async (getPlaces) => {
|
const placesListModel: getPlacesModel = async (getPlaces) => {
|
||||||
// get the method for handling the logic
|
// get the method for handling the logic
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
import PlacesModel from "~/business-logic/core/places/common/model/placesModel";
|
import PlacesModel from '~/business-logic/core/places/common/model/placesModel';
|
||||||
import { getPlacesReturnPort } from "~/business-logic/core/places/get-places/port";
|
import { getPlacesReturnPort } from '~/business-logic/core/places/get-places/port';
|
||||||
|
|
||||||
export type getPlacesModel = (
|
export type getPlacesModel = (getPlaces: getPlacesReturnPort) => Promise<PlacesModel>;
|
||||||
getPlaces: getPlacesReturnPort
|
|
||||||
) => Promise<PlacesModel>;
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import React from "react";
|
import React from 'react';
|
||||||
import { staticMessages } from "~/driven/utils/constants/staticMessages";
|
import { staticMessages } from '~/driven/utils/constants/staticMessages';
|
||||||
import Loading from "~/driven/utils/components/loading/Loading";
|
import Loading from '~/driven/utils/components/loading/Loading';
|
||||||
import TableRow from "../../common/table-row";
|
import TableRow from '../../common/table-row';
|
||||||
import { IPlacesListProps } from "./protocols";
|
import { IPlacesListProps } from './protocols';
|
||||||
|
|
||||||
export default function UsersListView(props: IPlacesListProps) {
|
export default function UsersListView(props: IPlacesListProps) {
|
||||||
const { selectedRowId, setSelectedRowId, placesList } = props;
|
const { selectedRowId, setSelectedRowId, placesList } = props;
|
||||||
@ -10,18 +10,18 @@ export default function UsersListView(props: IPlacesListProps) {
|
|||||||
const rows = () => {
|
const rows = () => {
|
||||||
const placesdata = [
|
const placesdata = [
|
||||||
{
|
{
|
||||||
id: "1",
|
id: '1',
|
||||||
place_id: "6440020b89366fdcaf15a8c2",
|
place_id: '6440020b89366fdcaf15a8c2',
|
||||||
title: "flat demoplace ",
|
title: 'flat demoplace ',
|
||||||
status: "demo",
|
status: 'demo',
|
||||||
address: "demoplace",
|
address: 'demoplace',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: "2",
|
id: '2',
|
||||||
place_id: "6440020b89366fdcaf15asdfa",
|
place_id: '6440020b89366fdcaf15asdfa',
|
||||||
title: "flat demoplace second ",
|
title: 'flat demoplace second ',
|
||||||
status: "demo second",
|
status: 'demo second',
|
||||||
address: "demoplace second",
|
address: 'demoplace second',
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
@ -32,7 +32,7 @@ export default function UsersListView(props: IPlacesListProps) {
|
|||||||
places.title,
|
places.title,
|
||||||
places.status,
|
places.status,
|
||||||
places.address,
|
places.address,
|
||||||
"",
|
'',
|
||||||
],
|
],
|
||||||
rowId: places.id,
|
rowId: places.id,
|
||||||
};
|
};
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import PlacesModel from "~/business-logic/core/places/common/model/placesModel";
|
import PlacesModel from '~/business-logic/core/places/common/model/placesModel';
|
||||||
|
|
||||||
export interface IPlacesListProps {
|
export interface IPlacesListProps {
|
||||||
placesList: {
|
placesList: {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { useState } from "react";
|
import { useState } from 'react';
|
||||||
import PlacesModel from "~/business-logic/core/places/common/model/placesModel";
|
import PlacesModel from '~/business-logic/core/places/common/model/placesModel';
|
||||||
import { placesListReturnType } from "./protocols";
|
import { placesListReturnType } from './protocols';
|
||||||
|
|
||||||
interface IPlacesListVM {
|
interface IPlacesListVM {
|
||||||
useGetPlacesList: () => {
|
useGetPlacesList: () => {
|
||||||
@ -12,7 +12,7 @@ interface IPlacesListVM {
|
|||||||
const usePlacesListVM = (dependencies: IPlacesListVM): placesListReturnType => {
|
const usePlacesListVM = (dependencies: IPlacesListVM): placesListReturnType => {
|
||||||
const { useGetPlacesList } = dependencies;
|
const { useGetPlacesList } = dependencies;
|
||||||
const placesData = useGetPlacesList();
|
const placesData = useGetPlacesList();
|
||||||
const [selectedRowId, setSelectedRowId] = useState<string>("");
|
const [selectedRowId, setSelectedRowId] = useState<string>('');
|
||||||
|
|
||||||
return {
|
return {
|
||||||
selectedRowId,
|
selectedRowId,
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import React from "react";
|
import React from 'react';
|
||||||
import PlacesModel from "~/business-logic/core/places/common/model/placesModel";
|
import PlacesModel from '~/business-logic/core/places/common/model/placesModel';
|
||||||
|
|
||||||
export type placesListReturnType = {
|
export type placesListReturnType = {
|
||||||
selectedRowId: string;
|
selectedRowId: string;
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
import UsersList from "./infra/UsersList";
|
import UsersList from './infra/UsersList';
|
||||||
|
|
||||||
export default UsersList;
|
export default UsersList;
|
||||||
|
@ -1,11 +1,32 @@
|
|||||||
import React from "react";
|
import React from 'react';
|
||||||
import useUsersListVM from "../viewmodel/usersListVM";
|
import getUsersAdapter from '~/driven/adapters/get-users-adapter/getUsersAdapter';
|
||||||
import UsersListView from "../view/UsersListView";
|
import getUsers from '~/business-logic/core/users/get-users';
|
||||||
|
import UsersModel from '~/business-logic/core/users/common/data/model/usersModel';
|
||||||
|
import { prepareStateManagementForVM } from '~/driven/utils/helpers/globalHelpers';
|
||||||
|
import useUsersListVM from '../viewmodel/usersListVM';
|
||||||
|
import UsersListView from '../view/UsersListView';
|
||||||
|
import usersListModel from '../model/usersListModel';
|
||||||
|
|
||||||
|
const prepareTheLogicForModel = () => {
|
||||||
|
const gettingUsersDrivenAdapter = getUsersAdapter();
|
||||||
|
const { url } = gettingUsersDrivenAdapter;
|
||||||
|
const getingusersLogic = getUsers(gettingUsersDrivenAdapter);
|
||||||
|
return { getingusersLogic, url };
|
||||||
|
};
|
||||||
|
|
||||||
export default function UsersList() {
|
export default function UsersList() {
|
||||||
const { selectedRowId, setSelectedRowId } = useUsersListVM();
|
const { getingusersLogic, url } = prepareTheLogicForModel();
|
||||||
|
const usersModel = async () => await usersListModel(getingusersLogic);
|
||||||
|
const useGetusersList = prepareStateManagementForVM<UsersModel>(
|
||||||
|
url,
|
||||||
|
usersModel
|
||||||
|
);
|
||||||
|
const { selectedRowId, setSelectedRowId, usersData } = useUsersListVM({
|
||||||
|
useGetusersList,
|
||||||
|
});
|
||||||
return (
|
return (
|
||||||
<UsersListView
|
<UsersListView
|
||||||
|
usersList={usersData}
|
||||||
selectedRowId={selectedRowId}
|
selectedRowId={selectedRowId}
|
||||||
setSelectedRowId={setSelectedRowId}
|
setSelectedRowId={setSelectedRowId}
|
||||||
/>
|
/>
|
||||||
|
@ -0,0 +1,6 @@
|
|||||||
|
import UsersModel from '~/business-logic/core/users/common/data/model/usersModel';
|
||||||
|
import { getUsersReturnPort } from '~/business-logic/core/users/get-users/ports';
|
||||||
|
|
||||||
|
export type getUsersModel = (
|
||||||
|
getUsers: getUsersReturnPort
|
||||||
|
) => Promise<UsersModel>;
|
@ -0,0 +1,10 @@
|
|||||||
|
import { getUsersModel } from './protocols';
|
||||||
|
|
||||||
|
const usersListModel: getUsersModel = async (getUsers) => {
|
||||||
|
// get the method for handling the logic
|
||||||
|
const users = await getUsers();
|
||||||
|
return users;
|
||||||
|
// handling the errors
|
||||||
|
};
|
||||||
|
|
||||||
|
export default usersListModel;
|
@ -1,22 +1,22 @@
|
|||||||
import React from "react";
|
import React from 'react';
|
||||||
import { staticMessages } from "~/driven/utils/constants/staticMessages";
|
import { staticMessages } from '~/driven/utils/constants/staticMessages';
|
||||||
import TableRow from "../../common/table-row";
|
import TableRow from '../../common/table-row';
|
||||||
import { IUserListProps } from "./protocols";
|
import { IUserListProps } from './protocols';
|
||||||
|
|
||||||
export default function UsersListView(props: IUserListProps) {
|
export default function UsersListView(props: IUserListProps) {
|
||||||
const { selectedRowId, setSelectedRowId } = props;
|
const { selectedRowId, setSelectedRowId, usersList } = props;
|
||||||
|
console.log(usersList.data);
|
||||||
const rows = () => {
|
const rows = () => {
|
||||||
const userdata = [
|
const userdata = [
|
||||||
{
|
{
|
||||||
id: "1",
|
id: '1',
|
||||||
firstname: "behnam",
|
firstname: 'behnam',
|
||||||
lastname: "rahimpour",
|
lastname: 'rahimpour',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: "2",
|
id: '2',
|
||||||
firstname: "Salar",
|
firstname: 'Salar',
|
||||||
lastname: "Sali",
|
lastname: 'Sali',
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -1,4 +1,11 @@
|
|||||||
|
import UsersModel from '~/business-logic/core/users/common/data/model/usersModel';
|
||||||
|
|
||||||
export interface IUserListProps {
|
export interface IUserListProps {
|
||||||
selectedRowId: string;
|
selectedRowId: string;
|
||||||
setSelectedRowId: React.Dispatch<React.SetStateAction<string>>;
|
setSelectedRowId: React.Dispatch<React.SetStateAction<string>>;
|
||||||
|
usersList: {
|
||||||
|
data: UsersModel | undefined;
|
||||||
|
isLoading: boolean;
|
||||||
|
error?: string | undefined;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,12 @@
|
|||||||
import React from "react";
|
import React from 'react';
|
||||||
|
import UsersModel from '~/business-logic/core/users/common/data/model/usersModel';
|
||||||
|
|
||||||
export type userListReturnType = {
|
export type userListReturnType = {
|
||||||
selectedRowId: string;
|
selectedRowId: string;
|
||||||
setSelectedRowId: React.Dispatch<React.SetStateAction<string>>;
|
setSelectedRowId: React.Dispatch<React.SetStateAction<string>>;
|
||||||
|
usersData: {
|
||||||
|
data: UsersModel | undefined;
|
||||||
|
isLoading: boolean;
|
||||||
|
error?: string | undefined;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
@ -1,12 +1,23 @@
|
|||||||
import { useState } from "react";
|
import { useState } from 'react';
|
||||||
import { userListReturnType } from "./protocols";
|
import UsersModel from '~/business-logic/core/users/common/data/model/usersModel';
|
||||||
|
import { userListReturnType } from './protocols';
|
||||||
|
|
||||||
const useUsersListVM = (): userListReturnType => {
|
interface IUsersListVM {
|
||||||
const [selectedRowId, setSelectedRowId] = useState<string>("");
|
useGetusersList: () => {
|
||||||
|
data: UsersModel | undefined;
|
||||||
|
isLoading: boolean;
|
||||||
|
error?: string | undefined;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
const useUsersListVM = (dependencies: IUsersListVM): userListReturnType => {
|
||||||
|
const { useGetusersList } = dependencies;
|
||||||
|
const [selectedRowId, setSelectedRowId] = useState<string>('');
|
||||||
|
const usersData = useGetusersList();
|
||||||
|
|
||||||
return {
|
return {
|
||||||
selectedRowId,
|
selectedRowId,
|
||||||
setSelectedRowId,
|
setSelectedRowId,
|
||||||
|
usersData,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
import Sidebar from "./view/Sidebar";
|
import Sidebar from './view/Sidebar';
|
||||||
|
|
||||||
export default Sidebar;
|
export default Sidebar;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import React from "react";
|
import React from 'react';
|
||||||
import { Link, useLocation } from "react-router-dom";
|
import { Link, useLocation } from 'react-router-dom';
|
||||||
import { routesData } from "~/driven/utils/configs/appConfig";
|
import { routesData } from '~/driven/utils/configs/appConfig';
|
||||||
import { icons } from "~/driven/utils/constants/assertUrls";
|
import { icons } from '~/driven/utils/constants/assertUrls';
|
||||||
|
|
||||||
export default function Sidebar() {
|
export default function Sidebar() {
|
||||||
const isCurrentPage = useLocation();
|
const isCurrentPage = useLocation();
|
||||||
@ -13,23 +13,21 @@ export default function Sidebar() {
|
|||||||
key={key}
|
key={key}
|
||||||
to={routesData[key].path}
|
to={routesData[key].path}
|
||||||
className={`flex text-white mb-6 text-sm w-full py-2 pl-2 rounded-lg ${
|
className={`flex text-white mb-6 text-sm w-full py-2 pl-2 rounded-lg ${
|
||||||
isCurrentPage.pathname === routesData[key].path
|
isCurrentPage.pathname === routesData[key].path ? 'bg-primary-300' : ''
|
||||||
? "bg-primary-300"
|
|
||||||
: ""
|
|
||||||
}`}
|
}`}
|
||||||
>
|
>
|
||||||
<img src={routesData[key].icon} alt="page icon" className="mr-2" />
|
<img src={routesData[key].icon} alt='page icon' className='mr-2' />
|
||||||
<div>{routesData[key].title}</div>
|
<div>{routesData[key].title}</div>
|
||||||
</Link>
|
</Link>
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<aside className="w-[15rem] min-w-[10rem] [background:var(--color-gradient-primary-dark)] p-4 pt-6">
|
<aside className='w-[15rem] min-w-[10rem] [background:var(--color-gradient-primary-dark)] p-4 pt-6'>
|
||||||
<div className="logo">
|
<div className='logo'>
|
||||||
<img src={icons.logo} alt="logo icon" />
|
<img src={icons.logo} alt='logo icon' />
|
||||||
</div>
|
</div>
|
||||||
<div className="mt-14 flex flex-col items-baseline">{pages}</div>
|
<div className='mt-14 flex flex-col items-baseline'>{pages}</div>
|
||||||
</aside>
|
</aside>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { BrowserRouter as RouterWrapper } from "react-router-dom";
|
import { BrowserRouter as RouterWrapper } from 'react-router-dom';
|
||||||
import Router from "./Router/Router";
|
import Router from './Router/Router';
|
||||||
import "./style/App.css";
|
import './style/App.css';
|
||||||
|
|
||||||
function App() {
|
function App() {
|
||||||
return (
|
return (
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import { Navigate, Route, Routes, useLocation } from "react-router-dom";
|
import { Navigate, Route, Routes, useLocation } from 'react-router-dom';
|
||||||
import Home from "~/driving/main/pages";
|
import Home from '~/driving/main/pages';
|
||||||
import { routes } from "~/driven/utils/configs/appConfig";
|
import { routes } from '~/driven/utils/configs/appConfig';
|
||||||
import CreateUser from "../pages/CreateUser";
|
import CreateUser from '../pages/CreateUser';
|
||||||
import MainPageLayout from "../pages/layouts/MainPageLayout";
|
import MainPageLayout from '../pages/layouts/MainPageLayout';
|
||||||
|
|
||||||
export default function Router() {
|
export default function Router() {
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
@ -13,7 +13,7 @@ export default function Router() {
|
|||||||
<Route index element={<Home />} />
|
<Route index element={<Home />} />
|
||||||
<Route path={routes.createUser} element={<CreateUser />} />
|
<Route path={routes.createUser} element={<CreateUser />} />
|
||||||
</Route>
|
</Route>
|
||||||
<Route path="*" element={<Navigate to={routes.usersList} replace />} />
|
<Route path='*' element={<Navigate to={routes.usersList} replace />} />
|
||||||
</Routes>
|
</Routes>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
import ReactDOM from "react-dom/client";
|
import ReactDOM from 'react-dom/client';
|
||||||
import App from "./App";
|
import App from './App';
|
||||||
|
|
||||||
ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render(
|
ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render(<App />);
|
||||||
<App />
|
|
||||||
);
|
|
||||||
|
@ -1,15 +1,12 @@
|
|||||||
import React from "react";
|
import React from 'react';
|
||||||
import PageTitle from "~/driven/utils/components/page-title/pageTitle";
|
import PageTitle from '~/driven/utils/components/page-title/pageTitle';
|
||||||
import { staticMessages } from "~/driven/utils/constants/staticMessages";
|
import { staticMessages } from '~/driven/utils/constants/staticMessages';
|
||||||
import CreateUser from "~/driving/application/core/create-user";
|
import CreateUser from '~/driving/application/core/create-user';
|
||||||
|
|
||||||
export default function CreateUserPage() {
|
export default function CreateUserPage() {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<PageTitle
|
<PageTitle className='px-4 py-5' title={staticMessages.global.createUser} />
|
||||||
className="px-4 py-5"
|
|
||||||
title={staticMessages.global.createUser}
|
|
||||||
/>
|
|
||||||
<CreateUser />
|
<CreateUser />
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
@ -1,23 +1,19 @@
|
|||||||
import React from "react";
|
import React from 'react';
|
||||||
import PrimaryButton from "~/driven/utils/components/buttons/primary-button/PrimaryButton";
|
import PrimaryButton from '~/driven/utils/components/buttons/primary-button/PrimaryButton';
|
||||||
import PageTitle from "~/driven/utils/components/page-title/pageTitle";
|
import PageTitle from '~/driven/utils/components/page-title/pageTitle';
|
||||||
import { staticMessages } from "~/driven/utils/constants/staticMessages";
|
import { staticMessages } from '~/driven/utils/constants/staticMessages';
|
||||||
import PlacesList from "~/driving/application/core/places-list";
|
import PlacesList from '~/driving/application/core/places-list';
|
||||||
import UsersList from "~/driving/application/core/users-list";
|
import UsersList from '~/driving/application/core/users-list';
|
||||||
|
|
||||||
export default function index() {
|
export default function index() {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<PageTitle className="px-4 py-5" title={staticMessages.global.users} />
|
<PageTitle className='px-4 py-5' title={staticMessages.global.users} />
|
||||||
<div className="container mx-auto px-4">
|
<div className='container mx-auto px-4'>
|
||||||
<div className="w-full flex flex-row-reverse items-center py-2">
|
<div className='w-full flex flex-row-reverse items-center py-2'>
|
||||||
<PrimaryButton
|
<PrimaryButton className='text-sm' title={staticMessages.global.submit} onClick={() => null} />
|
||||||
className="text-sm"
|
|
||||||
title={staticMessages.global.submit}
|
|
||||||
onClick={() => null}
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
<div className="md:grid-cols-2 gap-x-4 grid grid-cols-1 mx-auto">
|
<div className='md:grid-cols-2 gap-x-4 grid grid-cols-1 mx-auto'>
|
||||||
<UsersList />
|
<UsersList />
|
||||||
<PlacesList />
|
<PlacesList />
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
import React from "react";
|
import React from 'react';
|
||||||
import { Outlet } from "react-router-dom";
|
import { Outlet } from 'react-router-dom';
|
||||||
import Sidebar from "~/driving/application/support/sidebar";
|
import Sidebar from '~/driving/application/support/sidebar';
|
||||||
|
|
||||||
export default function MainPageLayout() {
|
export default function MainPageLayout() {
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-nowrap h-screen">
|
<div className='flex flex-nowrap h-screen'>
|
||||||
<Sidebar />
|
<Sidebar />
|
||||||
<main className="dipal-panel w-full text-black bg-white h-fit">
|
<main className='dipal-panel w-full text-black bg-white h-fit'>
|
||||||
<Outlet />
|
<Outlet />
|
||||||
</main>
|
</main>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user