ADD:
continuous-integration/drone/push Build is failing
Details
continuous-integration/drone/push Build is failing
Details
Chat en fonction des conversations de l'utilisateurPersistance
parent
82adcd6756
commit
d779403b62
@ -0,0 +1,20 @@
|
||||
import React from "react";
|
||||
import create from "zustand";
|
||||
import { MANAGER_USER } from "../../App";
|
||||
import { Conversation } from "../core/conversation";
|
||||
|
||||
|
||||
// Define store types
|
||||
interface ConversationState {
|
||||
tabConv: Conversation[] | undefined;
|
||||
setTabConv: (tabConv: Conversation[]) => void;
|
||||
resetTabConv: () => void;
|
||||
}
|
||||
|
||||
// Define store data and methods
|
||||
export const useConversationStore = create<ConversationState>()((set, get) => ({
|
||||
tabConv: undefined,
|
||||
setTabConv: (tabConv) => set((state) => ({ tabConv: tabConv })),
|
||||
resetTabConv: () => set((state) => ({tabConv: undefined})),
|
||||
}));
|
||||
|
@ -0,0 +1,14 @@
|
||||
import { Conversation } from "../../core/conversation";
|
||||
import ISaverConversation from "./ISaverConversation";
|
||||
|
||||
export class FakeSaverConversation implements ISaverConversation{
|
||||
async saveConversation(c: Conversation): Promise<void> {
|
||||
return;
|
||||
}
|
||||
async deleteConversation(c: Conversation): Promise<void> {
|
||||
return;
|
||||
}
|
||||
async updateConversation(c: Conversation): Promise<void> {
|
||||
return;
|
||||
}
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
import { Conversation } from "../../core/conversation";
|
||||
import { Message } from "../../core/message";
|
||||
import { Skin } from "../../core/skin";
|
||||
import { User } from "../../core/User/user";
|
||||
import ILoaderConversation from "./ILoaderConversation";
|
||||
|
||||
export class LoaderConversationApi implements ILoaderConversation{
|
||||
|
||||
private axios = require('axios').default;
|
||||
|
||||
loadAllConversation(): Promise<Conversation[]> {
|
||||
throw new Error("Method not implemented.");
|
||||
}
|
||||
loadByID(id: string): Promise<Conversation | null> {
|
||||
throw new Error("Method not implemented.");
|
||||
}
|
||||
async loadByUser(u: User): Promise<Conversation[]> {
|
||||
|
||||
let tabConv:Conversation[]=[];
|
||||
await this.axios({
|
||||
method: 'get',
|
||||
url: 'https://jsonplaceholder.typicode.com/todos/1',
|
||||
params: {
|
||||
name: "getConversationByUser",
|
||||
//Les params genre nom de la fonction en php
|
||||
}
|
||||
})
|
||||
.then(function (response: any) {
|
||||
tabConv=[new Conversation("C0001",
|
||||
[new User("U0001", "Alban", "oui", "ouioui", "homme", new Date(2022,12,12), 555, 667, 12, new Skin("S0001", "Bob",require('bob_party/assets/BobsSkins/BobClassic.png'), 0), [new Skin("S0001", "Bob",require('bob_party/assets/BobsSkins/BobClassic.png'), 0)]),
|
||||
new User("U0002", "Fefe63", "jesuishm", "ouioui", "homme", new Date(2022,12,12), 12222, 123324, 12, new Skin("S0001", "Bob",require('bob_party/assets/BobsSkins/BobClassic.png'), 0), [new Skin("S0001", "Bob",require('bob_party/assets/BobsSkins/BobClassic.png'), 0)]),],
|
||||
[new Message("M0001", "bonjour", new User("U0001", "Alban", "oui", "ouioui", "homme", new Date(2022,12,12), 555, 667, 12, new Skin("S0001", "Bob",require('bob_party/assets/BobsSkins/BobClassic.png'), 0), [new Skin("S0001", "Bob",require('bob_party/assets/BobsSkins/BobClassic.png'), 0)]), new Date(2022,12,12)),
|
||||
new Message("M0002", "test", new User("U0002", "Fefe63", "oui", "ouioui", "homme", new Date(2022,12,12), 555, 667, 12, new Skin("S0002", "Bob Blue",require('bob_party/assets/BobsSkins/BobBlue.png'), 100), [new Skin("S0002", "Bob Blue",require('bob_party/assets/BobsSkins/BobBlue.png'), 100)]), new Date(2022,12,13))], "leNom")];
|
||||
});
|
||||
return tabConv;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
import { Conversation } from "../../core/conversation";
|
||||
import { User } from "../../core/User/user";
|
||||
import ILoaderConversation from "./ILoaderConversation";
|
||||
import ISaverConversation from "./ISaverConversation";
|
||||
|
||||
export default class ManagerConversation{
|
||||
|
||||
private currentTabConv:Conversation[]=[];
|
||||
|
||||
private loaderConversation: ILoaderConversation;
|
||||
|
||||
private saverConversation: ISaverConversation;
|
||||
|
||||
constructor(loaderConversation:ILoaderConversation, saverConversation:ISaverConversation){
|
||||
this.loaderConversation=loaderConversation;
|
||||
this.saverConversation=saverConversation;
|
||||
}
|
||||
|
||||
getCurrentTabConv(){
|
||||
return this.currentTabConv;
|
||||
}
|
||||
|
||||
setCurrentTabConv(c:Conversation[]){
|
||||
this.currentTabConv=c;
|
||||
}
|
||||
|
||||
getLoaderConversation(){
|
||||
return this.loaderConversation;
|
||||
}
|
||||
|
||||
getsaverConversation(){
|
||||
return this.saverConversation;
|
||||
}
|
||||
}
|
Loading…
Reference in new issue