Skip to content

Commit

Permalink
feat: attr changes
Browse files Browse the repository at this point in the history
  • Loading branch information
josetano2 committed Aug 23, 2024
1 parent 3baa15c commit 8e7fe87
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 52 deletions.
3 changes: 2 additions & 1 deletion mops.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[dependencies]
base = "0.11.2"
vector = "0.4.0"
vector = "0.4.0"
uuid = "1.0.0"
31 changes: 26 additions & 5 deletions src/ss_backend/main.mo
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ import TrieMap "mo:base/TrieMap";
import Principal "mo:base/Principal";
import Result "mo:base/Result";
import Text "mo:base/Text";
import Blob "mo:base/Blob";
import Vector "mo:vector/Class";
import UUID "mo:uuid/UUID";
import Source "mo:uuid/async/SourceV4";
import Nat "mo:base/Nat";

actor {
public query func greet(name : Text) : async Text {
Expand All @@ -25,10 +29,22 @@ actor {
type Post = {
id : Text;
description : Text;
sender: Text;
sender : Principal;
category : Text;
timestamp : Time.Time;
images : [Text];
comments: [Text];
positive: Nat;
negative: Nat;
positiveVotes: Nat;
negativeVotes: Nat;
likes: [Principal];
};

type Comment = {
id: Text;
sender: Principal;
comment: Text;
};

type Friend = {
Expand All @@ -41,7 +57,12 @@ actor {
let posts = TrieMap.TrieMap<Text, Post>(Text.equal, Text.hash);
let friends = TrieMap.TrieMap<Text, Friend>(Text.equal, Text.hash);

public shared query func getPfp(userId : Principal) : async Text {
public func generateUUID() : async Text {
let g = Source.Source();
return UUID.toText(await g.new());
};

public query func getPfp(userId : Principal) : async Text {
let user : ?User = users.get(userId);
switch (user) {
case (?user) {
Expand All @@ -54,7 +75,7 @@ actor {
};
};

public shared func register(userId : Principal, name : Text, username : Text, email : Text, description : Text, dob : Text, profileUrl : Text) : async Bool {
public func register(userId : Principal, name : Text, username : Text, email : Text, description : Text, dob : Text, profileUrl : Text) : async Bool {

if (users.get(userId) != null) {
return false;
Expand Down Expand Up @@ -89,7 +110,7 @@ actor {
};
};

public shared query func getAllUsers() : async Result.Result<[User], Text> {
public query func getAllUsers() : async Result.Result<[User], Text> {

var allUsers = Vector.Vector<User>();

Expand All @@ -100,6 +121,6 @@ actor {
return #ok(Vector.toArray(allUsers));
};

// post


};
95 changes: 49 additions & 46 deletions src/ss_frontend/src/pages/ProfileForm/ProfileForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import FormTemplate from "../../templates/FormTemplate";
import { useAuth } from "../../hooks/UseAuth";
import { useNavigate } from "react-router-dom";
import { ss_backend } from "../../../../declarations/ss_backend";
import MainTemplate from "../../templates/MainTemplate";

export default function ProfileForm() {
const { user, principal } = useAuth();
Expand All @@ -30,56 +31,58 @@ export default function ProfileForm() {
console.log(resp);

if (resp) {
navigate(`/profile`);
navigate(`/`);
}
};

return (
<div className="h-full w-full flex justify-center items-center">
<div className="w-1/2 mt-[15%]">
{step === 1 ? (
<FormTemplate
title={"Enter your name"}
placeholder={"Name"}
fieldType={"text"}
step={step}
setStep={setStep}
value={name}
setValue={setName}
/>
) : step === 2 ? (
<FormTemplate
title={"Enter your username (Not Changeable)"}
placeholder={"Username"}
fieldType={"text"}
step={step}
setStep={setStep}
value={username}
setValue={setUsername}
/>
) : step === 3 ? (
<FormTemplate
title={"Enter your email"}
placeholder={"Email"}
fieldType={"text"}
step={step}
setStep={setStep}
value={email}
setValue={setEmail}
/>
) : (
<FormTemplate
title={"Enter your date of birth"}
placeholder={""}
fieldType={"date"}
step={step}
setStep={setStep}
value={dob}
setValue={setDob}
finalize={finalize}
/>
)}
<MainTemplate>
<div className="h-full w-full flex justify-center items-center">
<div className="w-1/2 mt-[15%]">
{step === 1 ? (
<FormTemplate
title={"Enter your name"}
placeholder={"Name"}
fieldType={"text"}
step={step}
setStep={setStep}
value={name}
setValue={setName}
/>
) : step === 2 ? (
<FormTemplate
title={"Enter your username (Not Changeable)"}
placeholder={"Username"}
fieldType={"text"}
step={step}
setStep={setStep}
value={username}
setValue={setUsername}
/>
) : step === 3 ? (
<FormTemplate
title={"Enter your email"}
placeholder={"Email"}
fieldType={"text"}
step={step}
setStep={setStep}
value={email}
setValue={setEmail}
/>
) : (
<FormTemplate
title={"Enter your date of birth"}
placeholder={""}
fieldType={"date"}
step={step}
setStep={setStep}
value={dob}
setValue={setDob}
finalize={finalize}
/>
)}
</div>
</div>
</div>
</MainTemplate>
);
}

0 comments on commit 8e7fe87

Please sign in to comment.